Skip to content

Commit

Permalink
prefix beta impl continue
Browse files Browse the repository at this point in the history
  • Loading branch information
UriBuilder committed Feb 7, 2023
1 parent ce44da2 commit 9257f97
Show file tree
Hide file tree
Showing 10 changed files with 96 additions and 78 deletions.
21 changes: 16 additions & 5 deletions Common/ModPlayers/AequusPlayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ public partial class AequusPlayer : ModPlayer

public int projectileIdentity = -1;

public int extraHealingPotion;
public int negativeDefense;

public PlayerWingModifiers wingStats;

public int prevLife;
Expand Down Expand Up @@ -773,6 +776,8 @@ public void ResetArmor()

public void ResetStats()
{
extraHealingPotion = 0;
negativeDefense = 0;
wingStats.ResetEffects();
maxSpawnsDivider = 1f;
spawnrateMultiplier = 1f;
Expand Down Expand Up @@ -1028,6 +1033,10 @@ public override void PostUpdateBuffs()
public override void UpdateEquips()
{
UpdateEquips_Vampire();
if (accBloodCrownSlot != -1)
{
HandleSlotBoost(Player.armor[accBloodCrownSlot], accBloodCrownSlot < 10 ? Player.hideVisibleAccessory[accBloodCrownSlot] : false);
}
}

public override void PostUpdateEquips()
Expand Down Expand Up @@ -1086,11 +1095,6 @@ public override void PostUpdateEquips()
Player.endurance += 0.3f;
}

if (accBloodCrownSlot != -1)
{
HandleSlotBoost(Player.armor[accBloodCrownSlot], accBloodCrownSlot < 10 ? Player.hideVisibleAccessory[accBloodCrownSlot] : false);
}

Stormcloak.UpdateAccessory(accDustDevilExpert, Player, this);

debuffLifeSteal *= 120; // Due to how NPC.lifeRegen is programmed
Expand Down Expand Up @@ -1184,6 +1188,7 @@ public override void PostUpdateMiscEffects()
{
Player.endurance = Math.Min(Player.endurance, GameplayConfig.Instance.DamageReductionCap);
}
Player.statDefense -= negativeDefense;
}

public override bool PreItemCheck()
Expand Down Expand Up @@ -1571,6 +1576,12 @@ public override bool CanConsumeAmmo(Item weapon, Item ammo)
return true;
}

public override void GetHealLife(Item item, bool quickHeal, ref int healValue)
{
if (healValue > 0)
healValue += extraHealingPotion;
}

public override bool PreHurt(bool pvp, bool quiet, ref int damage, ref int hitDirection, ref bool crit, ref bool customDamage, ref bool playSound, ref bool genGore, ref PlayerDeathReason damageSource, ref int cooldownCounter)
{
if (sceneInvulnerability > 0)
Expand Down
16 changes: 14 additions & 2 deletions Content/ItemPrefixes/Armor/ArgonPrefix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,23 @@ public class ArgonPrefix : MossArmorPrefixBase
{
public override int MossItem => ItemID.ArgonMoss;

public int maxDefenseIncrease = 30;

public override void ModifyTooltips(Item item, List<TooltipLine> tooltips)
{
base.ModifyTooltips(item, tooltips);
AddPrefixLine(tooltips, new TooltipLine(Mod, "ArgonPrefixEffect", $"+{(item.defense < 30 ? 100 : Math.Floor((1f - (item.defense - 30f) / item.defense) * 100f))}% defense") { IsModifier = true, IsModifierBad = false,});
AddPrefixLine(tooltips, new TooltipLine(Mod, "ArgonPrefixEffect", $"-{MathHelper.Clamp(item.defense, 0, 30)}% damage") { IsModifier = true, IsModifierBad = true, });
AddPrefixLine(tooltips, new TooltipLine(Mod, "ArgonPrefixEffect", $"+{(item.defense < maxDefenseIncrease ? 100 : Math.Floor((1f - (item.defense - (float)maxDefenseIncrease) / item.defense) * 100f))}% defense") { IsModifier = true, IsModifierBad = false,});
AddPrefixLine(tooltips, new TooltipLine(Mod, "ArgonPrefixEffect", $"-{MathHelper.Clamp(item.defense, 0, maxDefenseIncrease)}% damage") { IsModifier = true, IsModifierBad = true, });
}

public override void Apply(Item item)
{
item.Aequus().defenseChange = (int)MathHelper.Clamp(item.defense, 0, maxDefenseIncrease);
}

public override void UpdateEquip(Item item, Player player)
{
player.GetDamage(DamageClass.Generic) *= 1f - MathHelper.Clamp(item.defense, 0, maxDefenseIncrease) / 100f;
}
}
}
10 changes: 10 additions & 0 deletions Content/ItemPrefixes/Armor/KryptonPrefix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,15 @@ public int GetEnduranceAmount(Item item)
{
return (int)Math.Round(item.defense / Divisor);
}

public override void Apply(Item item)
{
item.Aequus().defenseChange = -item.defense;
}

public override void UpdateEquip(Item item, Player player)
{
player.endurance += GetEnduranceAmount(item) / 100f;
}
}
}
12 changes: 11 additions & 1 deletion Content/ItemPrefixes/Armor/NeonPrefix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,18 @@ public class NeonPrefix : MossArmorPrefixBase
public override void ModifyTooltips(Item item, List<TooltipLine> tooltips)
{
base.ModifyTooltips(item, tooltips);
AddPrefixLine(tooltips, new TooltipLine(Mod, "NeonPrefixEffect", $"+{item.defense * 2} health from potions") { IsModifier = true, IsModifierBad = false, });
AddPrefixLine(tooltips, new TooltipLine(Mod, "NeonPrefixEffect", $"+{item.defense * 4} health from potions") { IsModifier = true, IsModifierBad = false, });
AddPrefixLine(tooltips, new TooltipLine(Mod, "NeonPrefixEffect", $"+{item.defense} seconds of potion sickness") { IsModifier = true, IsModifierBad = true, });
}

public override void Apply(Item item)
{
}

public override void UpdateEquip(Item item, Player player)
{
player.potionDelayTime += item.defense;
player.Aequus().extraHealingPotion += item.defense * 4;
}
}
}
10 changes: 10 additions & 0 deletions Content/ItemPrefixes/Armor/XenonPrefix.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,15 @@ public override void ModifyTooltips(Item item, List<TooltipLine> tooltips)
AddPrefixLine(tooltips, new TooltipLine(Mod, "XenonPrefixEffect", "+1 minion slot") { IsModifier = true, IsModifierBad = false, });
AddPrefixLine(tooltips, new TooltipLine(Mod, "XenonPrefixEffect", "-200% defense") { IsModifier = true, IsModifierBad = true, });
}

public override void Apply(Item item)
{
item.Aequus().defenseChange = -item.defense * 2;
}

public override void UpdateEquip(Item item, Player player)
{
player.maxMinions++;
}
}
}
26 changes: 26 additions & 0 deletions Items/AequusItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ public partial class AequusItem : GlobalItem, IPostSetupContent, IAddRecipes
public bool reversedGravity;
public byte noGravityTime;
public int accStacks;
public int defenseChange;
public bool naturallyDropped;
public bool unOpenedChestItem;
public bool prefixPotionsBounded;
Expand Down Expand Up @@ -493,13 +494,23 @@ public static void CheckItemAbsorber()
public override void UpdateEquip(Item item, Player player)
{
UpdateEquip_Prefixes(item, player);
if (defenseChange < 0)
{
player.Aequus().negativeDefense -= defenseChange;
}
}

public override void UpdateAccessory(Item item, Player player, bool hideVisual)
{
UpdateAccessory_Prefixes(item, player, hideVisual);
if (defenseChange < 0)
{
player.Aequus().negativeDefense -= defenseChange;
}
if (player.Aequus().accBloodCrownSlot != -2)
{
accStacks = 1;
}
if (item.type == ItemID.RoyalGel || player.npcTypeNoAggro[NPCID.BlueSlime])
{
player.npcTypeNoAggro[ModContent.NPCType<WhiteSlime>()] = true;
Expand All @@ -508,6 +519,21 @@ public override void UpdateAccessory(Item item, Player player, bool hideVisual)

public override void ModifyTooltips(Item item, List<TooltipLine> tooltips)
{
if (defenseChange != 0)
{
foreach (var t in tooltips)
{
if (t.Mod == "Terraria" && t.Name == "Defense")
{
var text = t.Text.Split(' ');
text[0] += defenseChange > 0 ?
TextHelper.ColorCommand($"(+{defenseChange})", TextHelper.PrefixGood, alphaPulse: true) :
TextHelper.ColorCommand($"({defenseChange})", TextHelper.PrefixBad, alphaPulse: true);
t.Text = string.Join(' ', text);
break;
}
}
}
ModifyTooltips_Prefixes(item, tooltips);
}

Expand Down
5 changes: 4 additions & 1 deletion Items/TesterItem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ public override void SetDefaults()
// Main.chest[Chest.FindChestByGuessing(x, y)].SquishAndStackContents();
//}
//Projectile.NewProjectile(null, player.Center + new Vector2(400f, 0f), Vector2.Zero, ModContent.ProjectileType<ModIconAnimation>(), 0, 0f, player.whoAmI);
ReforgeItems(player, ModContent.PrefixType<ArgonPrefix>());
ReforgeItems(player, ModContent.PrefixType<XenonPrefix>());
return true;
}

Expand All @@ -73,6 +73,9 @@ public static void ReforgeItems(Player player, int pre)
{
for (int i = 0; i < Main.InventorySlotsTotal; i++)
{
int stack = player.inventory[i].stack;
player.inventory[i].SetDefaults(player.inventory[i].type);
player.inventory[i].stack = stack;
player.inventory[i].Prefix(pre);
}
}
Expand Down
66 changes: 0 additions & 66 deletions Items/Weapons/Melee/SickBeat.cs
Original file line number Diff line number Diff line change
@@ -1,36 +1,13 @@
using Aequus.Projectiles.Melee;
using System.Collections.Generic;
using System.IO;
using Terraria;
using Terraria.ID;
using Terraria.ModLoader;
using Terraria.ModLoader.IO;

namespace Aequus.Items.Weapons.Melee
{
public class SickBeat : ModItem
{
public string musicSource;
public bool HasModdedMusicSource => !string.IsNullOrEmpty(musicSource);
public string MusicSource { get => HasModdedMusicSource ? "Terraria" : musicSource; }

public string GetMusicProviderName()
{
if (!HasModdedMusicSource)
{
return TextHelper.GetTextValue("Terraria");
}
if (TextHelper.TryGetText($"ModName.{musicSource}", out string name))
{
return name;
}
if (ModLoader.TryGetMod(name, out var mod))
{
return mod.DisplayName;
}
return musicSource;
}

public override void SetDefaults()
{
Item.width = 40;
Expand All @@ -55,48 +32,5 @@ public override bool CanUseItem(Player player)
{
return player.ownedProjectileCounts[Item.shoot] < 1;
}

public override void ModifyTooltips(List<TooltipLine> tooltips)
{
var obj = new { MusicSource = GetMusicProviderName(), };
foreach (var l in tooltips)
{
if (l.Name.StartsWith("Tooltip"))
{
l.Text = AequusHelpers.FormatWith(l.Text, obj);
}
}
}

public override void SaveData(TagCompound tag)
{
if (HasModdedMusicSource)
tag["MusicSource"] = musicSource;
}
public override void LoadData(TagCompound tag)
{
musicSource = tag.Get<string>("MusicSource");
}

public override void NetSend(BinaryWriter writer)
{
if (HasModdedMusicSource)
{
writer.Write(true);
writer.Write(musicSource);
}
else
{
writer.Write(false);
}
}

public override void NetReceive(BinaryReader reader)
{
if (reader.ReadBoolean())
{
musicSource = reader.ReadString();
}
}
}
}
2 changes: 1 addition & 1 deletion Localization/en-US.hjson
Original file line number Diff line number Diff line change
Expand Up @@ -805,7 +805,7 @@ Mods: {
SickBeat:
'''
Deals extra hits when returning back
'This beat comes straight from {MusicSource}!'
'This beat comes straight from Terraria!'
'''
PhaseDisc:
'''
Expand Down
6 changes: 4 additions & 2 deletions TextHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ public class TextHelper : IOnModLoad
{
public static FieldInfo translationsField;
public static Dictionary<string, ModTranslation> Text;
public static Color BossSummonMessage => new Color(175, 75, 255, 255);
public static Color EventMessage => new Color(50, 255, 130, 255);
public static Color BossSummonMessage = new Color(175, 75, 255, 255);
public static Color EventMessage = new Color(50, 255, 130, 255);
public static Color PrefixGood = new Color(120, 190, 120, 255);
public static Color PrefixBad = new Color(190, 120, 120, 255);

public static string Unknown => GetTextValue("Unknown");
public static string ArmorSetBonusKey => Language.GetTextValue(Main.ReversedUpDownArmorSetBonuses ? "Key.UP" : "Key.DOWN");
Expand Down

0 comments on commit 9257f97

Please sign in to comment.