feat: Add map teleport
This commit is contained in:
1 parent
9df9f0a322
commit
73998f1aaa
7 files changed
+32
-2
No files matched your search
@@ -76,6 +76,7 @@ public static class Hotkeys
|
||||
Toggle("World", "FreezeTime", "Freeze Time", () => Settings.FreezeTime, v => Settings.FreezeTime = v),
|
||||
Toggle("World", "SpawnRate", "Spawn Rate", () => Settings.SpawnRateBoost, v => Settings.SpawnRateBoost = v),
|
||||
new("World", "SavePosition", "Save Current Position", Waypoints.AddHere),
|
||||
Toggle("World", "MapTeleport", "Map Teleport", () => Settings.MapTeleport, v => Settings.MapTeleport = v),
|
||||
new("World", "RevealMap", "Reveal Map", MapFeatures.StartReveal),
|
||||
];
|
||||
|
||||
|
||||
@@ -122,6 +122,7 @@ public static partial class Settings
|
||||
[nameof(FreezeTime)] = "World.FreezeTime",
|
||||
[nameof(SpawnRateBoost)] = "World.SpawnRate.Enabled",
|
||||
[nameof(SpawnRateMult)] = "World.SpawnRate.Multiplier",
|
||||
[nameof(MapTeleport)] = "World.MapTeleport",
|
||||
|
||||
[nameof(LogBallistics)] = "Ballistics.Log",
|
||||
};
|
||||
|
||||
@@ -50,7 +50,7 @@ public static partial class Settings
|
||||
public static Color ColDamageMelee = new(255, 110, 60), ColDamageRanged = new(120, 230, 90), ColDamageMagic = new(90, 150, 255), ColDamageSummon = new(200, 110, 255);
|
||||
public static bool Spelunker, Hunter, Shine, NightOwl, DangerSense, BiomeSight, FullBright, ExtendedZoom;
|
||||
|
||||
public static bool FreezeTime, SpawnRateBoost;
|
||||
public static bool FreezeTime, SpawnRateBoost, MapTeleport = true;
|
||||
public static float SpawnRateMult = 5f;
|
||||
|
||||
public static bool LogBallistics = true;
|
||||
|
||||
@@ -1,16 +1,22 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using Terraria;
|
||||
using TerraSharp.Core;
|
||||
using TerraSharp.UI;
|
||||
|
||||
namespace TerraSharp.Features;
|
||||
|
||||
public static class MapFeatures
|
||||
{
|
||||
const int ColumnsPerTick = 24;
|
||||
const float WorldEdge = 42f;
|
||||
|
||||
// MapHelper.GetBackgroundType samples map tiles up to 36 away; WorldMap.UnlockMapSection keeps the same margin.
|
||||
const int Margin = 40;
|
||||
|
||||
static int _revealColumn = -1;
|
||||
static bool _rightWasDown;
|
||||
|
||||
public static bool Revealing => _revealColumn >= 0;
|
||||
|
||||
@@ -28,6 +34,8 @@ public static class MapFeatures
|
||||
}
|
||||
|
||||
RevealStep();
|
||||
if (Settings.MapTeleport)
|
||||
TeleportOnRightClick();
|
||||
}
|
||||
|
||||
// A large world is about 20 million map tiles, so the reveal is spread over ticks.
|
||||
@@ -45,4 +53,22 @@ public static class MapFeatures
|
||||
if (_revealColumn < 0)
|
||||
Main.refreshMap = true;
|
||||
}
|
||||
|
||||
// Main.DrawMap puts tile mapFullscreenPos at the screen center, scaled by mapFullscreenScale.
|
||||
static void TeleportOnRightClick()
|
||||
{
|
||||
MouseState mouse = Mouse.GetState();
|
||||
bool down = mouse.RightButton == ButtonState.Pressed;
|
||||
bool clicked = down && !_rightWasDown;
|
||||
_rightWasDown = down;
|
||||
if (!clicked || !Main.mapFullscreen || !Main.instance.IsActive || WindowManager.MouseOver)
|
||||
return;
|
||||
|
||||
Vector2 tile = Main.mapFullscreenPos + (new Vector2(mouse.X, mouse.Y) - new Vector2(Main.screenWidth, Main.screenHeight) / 2f) / Main.mapFullscreenScale;
|
||||
Vector2 feet = new Vector2(MathHelper.Clamp(tile.X, WorldEdge, Main.maxTilesX - WorldEdge), MathHelper.Clamp(tile.Y, WorldEdge, Main.maxTilesY - WorldEdge)) * 16f;
|
||||
Player player = Main.LocalPlayer;
|
||||
PlayerFeatures.TeleportTo(feet - new Vector2(player.width / 2f, player.height));
|
||||
Main.mapFullscreen = false;
|
||||
Widgets.Sound(2, -1, -1, 6);
|
||||
}
|
||||
}
|
||||
@@ -252,6 +252,7 @@ public sealed partial class MainWindow
|
||||
WorldFeatures.StopInvasion();
|
||||
|
||||
Group("Map");
|
||||
Toggle("Map Teleport", ref Settings.MapTeleport);
|
||||
if (Buttons(MapFeatures.Revealing ? $"Revealing... {MapFeatures.RevealProgress:0%}" : "Reveal Map") == 0 && !MapFeatures.Revealing)
|
||||
MapFeatures.StartReveal();
|
||||
|
||||
|
||||
@@ -57,6 +57,7 @@ public sealed partial class MainWindow
|
||||
["Biome Sight"] = "Makes Corruption, Crimson and Hallow blocks glow.",
|
||||
["Full Bright"] = "Lights everything at full brightness.",
|
||||
["Extended Zoom"] = "Zoom in up to 8x and out until the edge of what the game draws.",
|
||||
["Map Teleport"] = "Right-click the fullscreen map to teleport there.",
|
||||
["Reveal Map"] = "Reveals the whole map. Multiplayer only reveals areas the server has sent.",
|
||||
["Full Heal"] = "Refills health and mana.",
|
||||
["TP to Spawn"] = "Recalls like a Magic Mirror: to your bed if set, otherwise the world's spawn point.",
|
||||
|
||||
@@ -35,7 +35,7 @@ public sealed partial class MainWindow : Window
|
||||
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)),
|
||||
new Page("Items", ItemsPage, () => Count(Settings.InstantBreak, Settings.InfItems, Settings.ItemVacuum, 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)),
|
||||
new Page("World", WorldPage, () => Count(Settings.FreezeTime, Settings.SpawnRateBoost, Settings.MapTeleport)),
|
||||
new Page("Keys", KeysPage, () => 0),
|
||||
];
|
||||
|
||||
|
||||
Reference in new issue
Block a user