Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ Require's [MelonLoader](https://melonloader.co/download.html) to use.

[Insert] Key to show/Hide the UI.

Auto Cat Playing is still in testing, it doesnt work, pls ignore.

Credits to kaikai2020 from uc forum and other members that shared codes on this thread.
"https://www.unknowncheats.me/forum/other-games/736498-heartopia-buddy-teleport-auto-farm.html"

Expand Down
93 changes: 51 additions & 42 deletions buddy/HeartopiaComplete.cs
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,8 @@ public class UnifiedConfigData
private float autoEatStepTimer = 0f;
private int autoEatScrollAttempts = 0;
private int autoEatAttempts = 0;
// Resource-farm: pause when auto-repair triggered (seconds)
private float resourceAutoRepairPauseSeconds = 20f;
private float resourceRepairPauseUntil = 0f;
// Resource-farm: debounce window for repair triggers (in seconds)
private float resourceAutoRepairPauseSeconds = 42f;
// Timestamp of the last repair trigger to debounce repeated triggers
private float lastRepairTriggerTime = -999f;
// Distance to teleport player backward (meters) before starting repair
Expand Down Expand Up @@ -634,7 +633,7 @@ private void ApplyKeybindConfig(KeybindConfigData data)
this.areaLoadDelay = data.areaLoadDelay;
this.resourceTeleportCooldown = data.resourceTeleportCooldown;
this.resourceClickDuration = data.resourceClickDuration;
this.resourceAutoRepairPauseSeconds = data.resourceAutoRepairPauseSeconds;
// resourceAutoRepairPauseSeconds is hardcoded to 42f - never load from file
this.gameSpeed = data.gameSpeed;
this.customCameraFOVEnabled = data.customCameraFOVEnabled;
this.cameraFOV = data.cameraFOV;
Expand Down Expand Up @@ -840,7 +839,7 @@ private void LoadKeybinds()
else if (line.Contains("areaLoadDelay")) this.areaLoadDelay = GetJsonInt(line, "\"areaLoadDelay\":");
else if (line.Contains("resourceTeleportCooldown")) this.resourceTeleportCooldown = GetJsonFloat(line, "\"resourceTeleportCooldown\":");
else if (line.Contains("resourceClickDuration")) this.resourceClickDuration = GetJsonFloat(line, "\"resourceClickDuration\":");
else if (line.Contains("resourceAutoRepairPauseSeconds")) this.resourceAutoRepairPauseSeconds = GetJsonFloat(line, "\"resourceAutoRepairPauseSeconds\":");
// resourceAutoRepairPauseSeconds is hardcoded to 42f - never load from file
else if (line.Contains("gameSpeed")) this.gameSpeed = GetJsonFloat(line, "\"gameSpeed\":");
else if (line.Contains("customCameraFOVEnabled")) this.customCameraFOVEnabled = GetJsonInt(line, "\"customCameraFOVEnabled\":") != 0;
else if (line.Contains("cameraFOV")) this.cameraFOV = GetJsonFloat(line, "\"cameraFOV\":");
Expand Down Expand Up @@ -1296,6 +1295,10 @@ public override void OnInitializeMelon()
}
}
catch { }

// Set game speed to 1x on mod load, overriding any remembered speed
this.gameSpeed = 1f;
Time.timeScale = 1f;
}

// Token: 0x06000004 RID: 4 RVA: 0x00002390 File Offset: 0x00000590
Expand Down Expand Up @@ -1727,9 +1730,8 @@ public override void OnUpdate()
// to run the multi-use auto logic
this.lastStartWasAutoRepair = true;
this.StartRepair();
// Pause resource farm teleports for configured seconds
this.resourceRepairPauseUntil = Time.time + this.resourceAutoRepairPauseSeconds;
this.AddMenuNotification($"Auto Repair triggered by durability notification — pausing farm for {this.resourceAutoRepairPauseSeconds:F0}s", new Color(0.45f, 1f, 0.55f));
// Farm will auto-pause while repair is running (checked via IsResourceRepairPaused)
this.AddMenuNotification($"Auto Repair triggered by durability notification", new Color(0.45f, 1f, 0.55f));
}
}
if (CheckForEnergyNotification())
Expand Down Expand Up @@ -2463,7 +2465,7 @@ public void SetResourceAutoRepairPauseSeconds(float seconds)

public bool IsResourceRepairPaused()
{
return Time.time < this.resourceRepairPauseUntil;
return this.isRepairing;
}

// Public wrappers to allow other modules to trigger repair/eat flows
Expand Down Expand Up @@ -3561,13 +3563,6 @@ private float DrawTreeFarmTab(int startY)
this.resourceClickDuration = this.DrawAccentSlider(new Rect(20f, (float)num, 260f, 20f), this.resourceClickDuration, 0.1f, 5f);
if (Math.Abs(this.resourceClickDuration - prevResourceClick) > 0.0001f) { try { this.SaveKeybinds(false); } catch { } }
num += 30;
// Auto Repair pause slider: how long to pause teleports after a repair toast
GUI.Label(new Rect(20f, (float)num, 260f, 20f), $"Auto-Repair Tool (Paused TP FARM): {this.resourceAutoRepairPauseSeconds:F0}s");
num += 22;
float prevResourcePause = this.resourceAutoRepairPauseSeconds;
this.resourceAutoRepairPauseSeconds = this.DrawAccentSlider(new Rect(20f, (float)num, 260f, 20f), this.resourceAutoRepairPauseSeconds, 0f, 60f);
if (Math.Abs(this.resourceAutoRepairPauseSeconds - prevResourcePause) > 0.0001f) { try { this.SaveKeybinds(false); } catch { } }
num += 30;



Expand Down Expand Up @@ -3617,31 +3612,51 @@ private float DrawNewSubTab(int startY)
GUI.enabled = true;
num += 30;

// Single enable button
string buttonText = isAutoFishingEnabled ? "Disable Auto Fishing" : "Enable Auto Fishing";
if (this.DrawPrimaryActionButton(new Rect(20f, (float)num, 260f, 35f), buttonText))
// Mode-specific enable/disable buttons (only show one at a time)
if (this.autoFishTeleportEnabled)
{
if (isAutoFishingEnabled)
// Teleport fishing mode
bool farmEnabled = this.autoFishFarm != null && this.autoFishFarm.farmEnabled;
string buttonText = farmEnabled ? "Disable Teleport Fishing" : "Enable Teleport Fishing";
if (this.DrawPrimaryActionButton(new Rect(20f, (float)num, 260f, 35f), buttonText))
{
// Disable both
if (this.autoFishLogic != null) this.autoFishLogic.ToggleAutoFish();
if (this.autoFishFarm != null) this.autoFishFarm.ToggleFarm();
this.showFishShadowRadar = false;
if (farmEnabled)
{
// Disable farm
if (this.autoFishFarm != null) this.autoFishFarm.ToggleFarm();
this.showFishShadowRadar = false;
}
else
{
// Enable farm
if (this.autoFishFarm != null) this.autoFishFarm.ToggleFarm();
this.showFishShadowRadar = true;
this.isRadarActive = true;
this.RunRadar();
}
}
else
}
else
{
// Standard fishing mode
bool logicEnabled = this.autoFishLogic != null && this.autoFishLogic.autoFishEnabled;
string buttonText = logicEnabled ? "Disable Auto Fishing" : "Enable Auto Fishing";
if (this.DrawPrimaryActionButton(new Rect(20f, (float)num, 260f, 35f), buttonText))
{
// Enable based on teleport setting
if (this.autoFishTeleportEnabled)
if (logicEnabled)
{
if (this.autoFishFarm != null) this.autoFishFarm.ToggleFarm();
// Disable fishing
if (this.autoFishLogic != null) this.autoFishLogic.ToggleAutoFish();
this.showFishShadowRadar = false;
}
else
{
// Enable fishing
if (this.autoFishLogic != null) this.autoFishLogic.ToggleAutoFish();
this.showFishShadowRadar = true;
this.isRadarActive = true;
this.RunRadar();
}
this.showFishShadowRadar = true;
this.isRadarActive = true;
this.RunRadar();
}
}
num += 45;
Expand Down Expand Up @@ -3694,7 +3709,7 @@ private float DrawNewSubTab(int startY)
if (Math.Abs(this.autoFishFarm.teleportDelay - prevFishTp) > 0.001f) { try { this.SaveKeybinds(false); } catch { } }
num += 28;
}
else if (!this.autoFishTeleportEnabled && this.autoFishLogic != null)
if (this.autoFishLogic != null)
{
// Settings for standing fishing
GUI.Label(new Rect(20f, (float)num, 150f, 18f), "Fish Detect Range", small);
Expand Down Expand Up @@ -5965,8 +5980,8 @@ public void UpdateResourceFarm()
{
if (this.resourceMarkerPositions.Count > 0)
{
// If paused due to auto-repair, skip starting a teleport until pause expires
if (Time.time < this.resourceRepairPauseUntil)
// If paused due to auto-repair, skip starting a teleport until repair completes
if (this.IsResourceRepairPaused())
{
return;
}
Expand Down Expand Up @@ -11625,9 +11640,6 @@ void StartRepair()
repairStep = 0;
scrollAttempts = 0;
stepTimer = Time.time;

// Pause resource farm teleports while repairing to avoid overlapping actions
this.resourceRepairPauseUntil = Time.time + this.resourceAutoRepairPauseSeconds;
}

void StopRepair()
Expand Down Expand Up @@ -14400,8 +14412,7 @@ public void OnToastDetected(string msg)
MelonLogger.Msg("[AutoRepair] Durability toast requested StartRepair (hook)");
this.lastStartWasAutoRepair = true;
this.StartRepair();
this.resourceRepairPauseUntil = Time.time + this.resourceAutoRepairPauseSeconds;
this.AddMenuNotification($"Auto Repair triggered by durability notification — pausing farm for {this.resourceAutoRepairPauseSeconds:F0}s", new Color(0.45f, 1f, 0.55f));
this.AddMenuNotification($"Auto Repair triggered by durability notification", new Color(0.45f, 1f, 0.55f));
}
return;
}
Expand All @@ -14413,9 +14424,7 @@ public void OnToastDetected(string msg)
{
MelonLogger.Msg("[AutoEat] Energy toast requested StartAutoEat (hook)");
this.StartAutoEat();
// Pause farm teleports while auto-eat runs (reuse same pause setting)
this.resourceRepairPauseUntil = Time.time + this.resourceAutoRepairPauseSeconds;
this.AddMenuNotification($"Auto Eat triggered by energy low toast ({this.autoEatFoodOptions[this.autoEatFoodType]}) — pausing farm for {this.resourceAutoRepairPauseSeconds:F0}s", new Color(0.45f, 1f, 0.55f));
this.AddMenuNotification($"Auto Eat triggered by energy low toast ({this.autoEatFoodOptions[this.autoEatFoodType]})", new Color(0.45f, 1f, 0.55f));
}
return;
}
Expand Down