feat: Add Coins to Piggy Bank toggle
This commit is contained in:
1 parent
c5ff9a75fb
commit
cfe56356c4
8 files changed
+71
-2
No files matched your search
@@ -69,6 +69,7 @@ public static class Hotkeys
|
||||
Toggle("Items", "InstantBreak", "Instant Break", () => Settings.InstantBreak, v => Settings.InstantBreak = v),
|
||||
Toggle("Items", "InfItems", "Infinite Items", () => Settings.InfItems, v => Settings.InfItems = v),
|
||||
Toggle("Items", "AutoSell", "Auto Sell", () => Settings.AutoSell, v => Settings.AutoSell = v),
|
||||
Toggle("Items", "CoinsToBank", "Coins to Piggy Bank", () => Settings.CoinsToBank, v => Settings.CoinsToBank = v),
|
||||
new("Items", "MaxStack", "Max Stack", ItemFeatures.MaxStack),
|
||||
new("Items", "Duplicate", "Duplicate Item", ItemFeatures.Duplicate),
|
||||
|
||||
|
||||
@@ -70,6 +70,7 @@ public static partial class Settings
|
||||
[nameof(InfItems)] = "Items.InfiniteItems",
|
||||
[nameof(ItemVacuum)] = "Items.Vacuum",
|
||||
[nameof(AutoSell)] = "Items.AutoSell.Enabled",
|
||||
[nameof(CoinsToBank)] = "Items.CoinsToBank",
|
||||
[nameof(BankButtons)] = "Items.BankButtons",
|
||||
|
||||
[nameof(AutoFish)] = "Fishing.Enabled",
|
||||
|
||||
@@ -62,7 +62,7 @@ public static partial class Settings
|
||||
public static bool Aimbot, AimPrediction = true, AimDrawTarget = true, AutoAttack, AimExact = true, ShotPreview, MagicBullets, AutoDodge;
|
||||
public static float AimFov = 250f, AimRange = 60f;
|
||||
|
||||
public static bool InstantBreak, InfItems, ItemVacuum, AutoSell, BankButtons = true;
|
||||
public static bool InstantBreak, InfItems, ItemVacuum, AutoSell, CoinsToBank, BankButtons = true;
|
||||
public static readonly HashSet<int> SellList = [];
|
||||
public static bool AutoFish, AutoRecast = true, FishEnemies, Sonar;
|
||||
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Terraria;
|
||||
using Terraria.ID;
|
||||
using TerraSharp.Core;
|
||||
using TerraSharp.UI;
|
||||
|
||||
@@ -81,4 +84,64 @@ public static class ItemFeatures
|
||||
if (sold)
|
||||
Widgets.Sound(CoinSound);
|
||||
}
|
||||
|
||||
const int CarriedSlots = 58;
|
||||
static readonly int[] Coins = [ItemID.PlatinumCoin, ItemID.GoldCoin, ItemID.SilverCoin, ItemID.CopperCoin];
|
||||
|
||||
static long CoinValue(int type) => type switch
|
||||
{
|
||||
ItemID.CopperCoin => 1,
|
||||
ItemID.SilverCoin => 100,
|
||||
ItemID.GoldCoin => 10_000,
|
||||
ItemID.PlatinumCoin => 1_000_000,
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
public static void CoinsToBank(Player player)
|
||||
{
|
||||
if (player.HeldItem.useAmmo == AmmoID.Coin)
|
||||
return;
|
||||
|
||||
Item[] inventory = player.inventory;
|
||||
long total = 0;
|
||||
for (int i = 0; i < CarriedSlots; i++)
|
||||
if (!inventory[i].favorited)
|
||||
total += CoinValue(inventory[i].type) * inventory[i].stack;
|
||||
if (total == 0)
|
||||
return;
|
||||
|
||||
Item[] bank = player.bank.item;
|
||||
var slots = new List<int>();
|
||||
for (int i = 0; i < bank.Length; i++)
|
||||
{
|
||||
long value = CoinValue(bank[i].type);
|
||||
if (value > 0 || bank[i].type == 0)
|
||||
slots.Add(i);
|
||||
total += value * bank[i].stack;
|
||||
}
|
||||
|
||||
var stacks = new List<(int Type, int Stack)>();
|
||||
foreach (int coin in Coins)
|
||||
{
|
||||
long count = total / CoinValue(coin);
|
||||
total %= CoinValue(coin);
|
||||
int maxStack = ContentSamples.ItemsByType[coin].maxStack;
|
||||
for (; count > 0; count -= maxStack)
|
||||
stacks.Add((coin, (int)Math.Min(count, maxStack)));
|
||||
}
|
||||
|
||||
if (stacks.Count > slots.Count)
|
||||
return;
|
||||
|
||||
for (int i = 0; i < CarriedSlots; i++)
|
||||
if (!inventory[i].favorited && CoinValue(inventory[i].type) > 0)
|
||||
inventory[i].TurnToAir();
|
||||
foreach (int slot in slots)
|
||||
bank[slot].TurnToAir();
|
||||
for (int i = 0; i < stacks.Count; i++)
|
||||
{
|
||||
bank[slots[i]].SetDefaults(stacks[i].Type);
|
||||
bank[slots[i]].stack = stacks[i].Stack;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -147,6 +147,8 @@ public static class PlayerFeatures
|
||||
AutoPotions(player);
|
||||
if (Settings.AutoSell)
|
||||
ItemFeatures.AutoSell(player);
|
||||
if (Settings.CoinsToBank)
|
||||
ItemFeatures.CoinsToBank(player);
|
||||
}
|
||||
|
||||
if (Settings.InfFlight)
|
||||
|
||||
@@ -144,6 +144,7 @@ public sealed partial class MainWindow
|
||||
if (Buttons(WindowManager.SellList.Open ? "Close Sell List" : "Edit Sell List") == 0)
|
||||
WindowManager.Toggle(WindowManager.SellList);
|
||||
});
|
||||
Toggle("Coins to Piggy Bank", ref Settings.CoinsToBank);
|
||||
Toggle("Bank Buttons", ref Settings.BankButtons);
|
||||
Toggle("Infinite Items", ref Settings.InfItems);
|
||||
Toggle("Instant Break", ref Settings.InstantBreak);
|
||||
|
||||
@@ -41,6 +41,7 @@ public sealed partial class MainWindow
|
||||
["Instant Break"] = "Break blocks in one hit with your held pickaxe, axe or hammer.",
|
||||
["Infinite Items"] = "Keeps inventory stacks from shrinking.",
|
||||
["Item Vacuum"] = "Pulls all dropped items to you.",
|
||||
["Coins to Piggy Bank"] = "Sends all coins to the Piggy Bank.",
|
||||
["Bank Buttons"] = "Piggy Bank, Safe, Defender's Forge and Void Vault buttons left of the inventory.",
|
||||
["Auto Sell"] = "Turns listed items in your inventory into coins. Items worth nothing are deleted.",
|
||||
["Item Editor"] = "Change the prefix, stats and stack of the held or cursor item.",
|
||||
|
||||
@@ -33,7 +33,7 @@ public sealed partial class MainWindow : Window
|
||||
new Page("Player", PlayerPage, () => Count(Settings.GodMode, Settings.InfHealth, Settings.InfMana, Settings.InfBreath, Settings.InfFlight, Settings.InstantRespawn, Settings.AutoHeal, Settings.AutoMana, Settings.GhostMode, Settings.DefenseBoost, Settings.ShowStats, Settings.PartyFrames)),
|
||||
new Page("Movement", MovementPage, () => Count(Settings.Fly, Settings.SuperSpeed, Settings.HighJump, Settings.GravityFlip, Settings.NoFallDamage, Settings.LavaImmune, Settings.WaterWalk, Settings.NoKnockback, Settings.ExtendedReach)),
|
||||
new Page("Combat", CombatPage, () => Count(Settings.RapidAttack, Settings.AutoSwing, Settings.DamageBoost, Settings.NoManaCost, Settings.NoSpread, Settings.Aimbot, Settings.AutoAttack, Settings.KillAura, Settings.HitMagnet, Settings.FreezeEnemies, Settings.WeakenEnemies, Settings.MagicBullets, Settings.AutoDodge)),
|
||||
new Page("Items", ItemsPage, () => Count(Settings.InstantBreak, Settings.InfItems, Settings.ItemVacuum, Settings.AutoSell, Settings.AutoFish, Settings.Sonar)),
|
||||
new Page("Items", ItemsPage, () => Count(Settings.InstantBreak, Settings.InfItems, Settings.ItemVacuum, Settings.AutoSell, Settings.CoinsToBank, Settings.AutoFish, Settings.Sonar)),
|
||||
new Page("Visuals", VisualsPage, () => Count(Settings.Esp, Settings.Spelunker, Settings.Hunter, Settings.Shine, Settings.NightOwl, Settings.DangerSense, Settings.BiomeSight, Settings.FullBright, Settings.ExtendedZoom)),
|
||||
new Page("World", WorldPage, () => Count(Settings.FreezeTime, Settings.SpawnRateBoost, Settings.MapTeleport)),
|
||||
new Page("Keys", KeysPage, () => 0),
|
||||
|
||||
Reference in new issue
Block a user