Initial commit
A modern .NET 9 NativeAOT framework for Asheron's Call client modding. Self-contained injection system that hooks D3D9 EndScene to render an ImGui overlay inside the AC client process.
This commit is contained in:
commit
80b71d295d
179 changed files with 52858 additions and 0 deletions
483
Plugins/RynthAi/UI/AdvancedSettingsUI.cs
Normal file
483
Plugins/RynthAi/UI/AdvancedSettingsUI.cs
Normal file
|
|
@ -0,0 +1,483 @@
|
|||
using System;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
|
||||
namespace NexSuite.Plugins.RynthAi
|
||||
{
|
||||
public class AdvancedSettingsUI
|
||||
{
|
||||
private readonly UISettings _settings;
|
||||
private MissileCraftingManager _missileCraftingManager;
|
||||
public Action OnSettingsChanged;
|
||||
|
||||
private static readonly string[] _attackHeights = { "Low", "Medium", "High" };
|
||||
private static readonly string[] _lootOwnershipModes = { "My Kills Only", "Fellowship Kills", "All Corpses" };
|
||||
private static readonly string[] _movementModes = { "Legacy (Autorun)", "Tier 1 (CM_Movement)", "Tier 2 (MoveToPosition)" };
|
||||
|
||||
public AdvancedSettingsUI(UISettings settings)
|
||||
{
|
||||
_settings = settings;
|
||||
}
|
||||
|
||||
public void SetMissileCraftingManager(MissileCraftingManager mgr)
|
||||
{
|
||||
_missileCraftingManager = mgr;
|
||||
}
|
||||
|
||||
public void Render()
|
||||
{
|
||||
if (!_settings.ShowAdvancedWindow) return;
|
||||
|
||||
// Set a default size for the popup window
|
||||
ImGui.SetNextWindowSize(new Vector2(600, 400), ImGuiCond.FirstUseEver);
|
||||
|
||||
if (ImGui.Begin("RynthAi Advanced Settings", ref _settings.ShowAdvancedWindow))
|
||||
{
|
||||
// --- LEFT COLUMN (Sidebar) ---
|
||||
ImGui.BeginChild("AdvancedSidebar", new Vector2(150, 0), true);
|
||||
for (int i = 0; i < _settings.AdvancedTabs.Length; i++)
|
||||
{
|
||||
if (ImGui.Selectable(_settings.AdvancedTabs[i], _settings.SelectedAdvancedTab == i))
|
||||
{
|
||||
_settings.SelectedAdvancedTab = i;
|
||||
}
|
||||
}
|
||||
ImGui.EndChild();
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
// --- RIGHT COLUMN (Content) ---
|
||||
ImGui.BeginGroup();
|
||||
ImGui.BeginChild("AdvancedContent", new Vector2(0, -ImGui.GetFrameHeightWithSpacing()), true);
|
||||
|
||||
RenderTabContent(_settings.SelectedAdvancedTab);
|
||||
|
||||
ImGui.EndChild();
|
||||
|
||||
// Bottom Buttons
|
||||
if (ImGui.Button("Close")) _settings.ShowAdvancedWindow = false;
|
||||
ImGui.EndGroup();
|
||||
}
|
||||
ImGui.End();
|
||||
}
|
||||
|
||||
private void RenderTabContent(int tabIndex)
|
||||
{
|
||||
if (tabIndex < 0 || tabIndex >= _settings.AdvancedTabs.Length) return;
|
||||
|
||||
string tabName = _settings.AdvancedTabs[tabIndex];
|
||||
ImGui.TextColored(new System.Numerics.Vector4(0.4f, 0.7f, 1.0f, 1.0f), $"Advanced Settings > {tabName}");
|
||||
ImGui.Separator();
|
||||
ImGui.Spacing();
|
||||
|
||||
// Note: Ensure your AdvancedSettingsUI class has an 'Action OnSettingsChanged'
|
||||
// property that you set in the RynthAiUI constructor to handle auto-saving.
|
||||
|
||||
switch (tabName)
|
||||
{
|
||||
case "Misc":
|
||||
// --- FPS THROTTLING ---
|
||||
if (ImGui.Checkbox("Enable FPS Limit", ref _settings.EnableFPSLimit)) OnSettingsChanged?.Invoke();
|
||||
if (_settings.EnableFPSLimit)
|
||||
{
|
||||
ImGui.Indent();
|
||||
ImGui.SetNextItemWidth(150);
|
||||
if (ImGui.SliderInt("Focused FPS", ref _settings.TargetFPSFocused, 10, 240)) OnSettingsChanged?.Invoke();
|
||||
ImGui.SetNextItemWidth(150);
|
||||
if (ImGui.SliderInt("Background FPS", ref _settings.TargetFPSBackground, 5, 60)) OnSettingsChanged?.Invoke();
|
||||
ImGui.Unindent();
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
ImGui.Spacing();
|
||||
|
||||
// --- INVENTORY MANAGEMENT ---
|
||||
// Uses EnableAutocram from UISettings
|
||||
if (ImGui.Checkbox("Auto Cram", ref _settings.EnableAutocram)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.SetTooltip("Automatically moves items from your main pack into side packs.\n" +
|
||||
"Note: Recently used weapons will stay in the main pack for quick access.");
|
||||
}
|
||||
|
||||
ImGui.Spacing();
|
||||
|
||||
// --- GENERAL BEHAVIOR ---
|
||||
if (ImGui.Checkbox("Peace Mode When Idle", ref _settings.PeaceModeWhenIdle)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.Checkbox("Enable Raycasting", ref _settings.EnableRaycasting)) OnSettingsChanged?.Invoke();
|
||||
|
||||
ImGui.Separator();
|
||||
ImGui.Spacing();
|
||||
|
||||
// --- COMBAT BLACKLIST ---
|
||||
ImGui.Text("Monster Blacklist");
|
||||
ImGui.SetNextItemWidth(150);
|
||||
if (ImGui.SliderInt("Attempts Before Blacklist", ref _settings.BlacklistAttempts, 1, 20)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.SetTooltip("How many failed attack attempts on a mob before it gets blacklisted.\n" +
|
||||
"Helps avoid getting stuck on mobs clipped into walls or geometry.");
|
||||
}
|
||||
ImGui.SetNextItemWidth(150);
|
||||
if (ImGui.SliderInt("Blacklist Timeout (sec)", ref _settings.BlacklistTimeoutSec, 5, 120)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.SetTooltip("How long (seconds) a blacklisted mob is ignored before re-trying.");
|
||||
}
|
||||
break;
|
||||
|
||||
case "Recharge":
|
||||
ImGui.Text("Self Vitals (%)");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.SliderInt("Heal At", ref _settings.HealAt, 0, 100)) OnSettingsChanged?.Invoke();
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.SliderInt("Re-stam At", ref _settings.RestamAt, 0, 100)) OnSettingsChanged?.Invoke();
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.SliderInt("Get Mana At", ref _settings.GetManaAt, 0, 100)) OnSettingsChanged?.Invoke();
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Text("Top-Off Vitals (%)");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.SliderInt("Top HP", ref _settings.TopOffHP, 0, 100)) OnSettingsChanged?.Invoke();
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.SliderInt("Top Stam", ref _settings.TopOffStam, 0, 100)) OnSettingsChanged?.Invoke();
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.SliderInt("Top Mana", ref _settings.TopOffMana, 0, 100)) OnSettingsChanged?.Invoke();
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Text("Helper Settings (%)");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.SliderInt("Heal Others", ref _settings.HealOthersAt, 0, 100)) OnSettingsChanged?.Invoke();
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.SliderInt("Re-stam Others", ref _settings.RestamOthersAt, 0, 100)) OnSettingsChanged?.Invoke();
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.SliderInt("Infuse Others", ref _settings.InfuseOthersAt, 0, 100)) OnSettingsChanged?.Invoke();
|
||||
break;
|
||||
|
||||
case "Melee Combat":
|
||||
ImGui.Text("Attack Power & Height");
|
||||
ImGui.Separator();
|
||||
|
||||
// --- USE RECKLESSNESS ---
|
||||
if (ImGui.Checkbox("Use Recklessness", ref _settings.UseRecklessness)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("When enabled and Recklessness is trained,\nauto power is set to 80% instead of 100%.\nThis activates the Recklessness damage bonus.");
|
||||
|
||||
ImGui.Spacing();
|
||||
|
||||
// --- MELEE ATTACK POWER ---
|
||||
bool meleeAuto = _settings.MeleeAttackPower < 0;
|
||||
if (ImGui.Checkbox("Melee Auto Power", ref meleeAuto))
|
||||
{
|
||||
_settings.MeleeAttackPower = meleeAuto ? -1 : 100;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("Auto = 100%, or 80% if Use Recklessness is on.");
|
||||
if (!meleeAuto)
|
||||
{
|
||||
ImGui.Indent();
|
||||
int mPwr = _settings.MeleeAttackPower;
|
||||
ImGui.SetNextItemWidth(150);
|
||||
if (ImGui.SliderInt("Melee Power %", ref mPwr, 0, 100))
|
||||
{
|
||||
_settings.MeleeAttackPower = mPwr;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
ImGui.Unindent();
|
||||
}
|
||||
|
||||
// --- MELEE ATTACK HEIGHT ---
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.Combo("Melee Attack Height", ref _settings.MeleeAttackHeight, _attackHeights, _attackHeights.Length))
|
||||
OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("Low = Delete, Medium = End, High = Page Down");
|
||||
|
||||
ImGui.Spacing();
|
||||
|
||||
// --- MISSILE ATTACK POWER ---
|
||||
bool missileAuto = _settings.MissileAttackPower < 0;
|
||||
if (ImGui.Checkbox("Missile Auto Power", ref missileAuto))
|
||||
{
|
||||
_settings.MissileAttackPower = missileAuto ? -1 : 100;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("Auto = 100%, or 80% if Use Recklessness is on.");
|
||||
if (!missileAuto)
|
||||
{
|
||||
ImGui.Indent();
|
||||
int rPwr = _settings.MissileAttackPower;
|
||||
ImGui.SetNextItemWidth(150);
|
||||
if (ImGui.SliderInt("Missile Power %", ref rPwr, 0, 100))
|
||||
{
|
||||
_settings.MissileAttackPower = rPwr;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
ImGui.Unindent();
|
||||
}
|
||||
|
||||
// --- MISSILE ATTACK HEIGHT ---
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.Combo("Missile Attack Height", ref _settings.MissileAttackHeight, _attackHeights, _attackHeights.Length))
|
||||
OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("Low = Delete, Medium = End, High = Page Down");
|
||||
|
||||
ImGui.Separator();
|
||||
ImGui.Spacing();
|
||||
|
||||
// You can add weapon-specific toggles here later
|
||||
if (ImGui.Checkbox("Summon Pets", ref _settings.SummonPets)) OnSettingsChanged?.Invoke();
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputInt("Pet Min Monsters", ref _settings.PetMinMonsters)) OnSettingsChanged?.Invoke();
|
||||
break;
|
||||
|
||||
case "Spell Combat":
|
||||
ImGui.Text("War/Void Casting Settings");
|
||||
ImGui.Separator();
|
||||
if (ImGui.Checkbox("Cast Dispel Self", ref _settings.CastDispelSelf)) OnSettingsChanged?.Invoke();
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Text("Ring Spell Override");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputInt("Min Ring Targets", ref _settings.MinRingTargets)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.SetTooltip("If this many monsters are within Ring Range,\nring spells are used instead of arc/bolt/streak.\nSet to 0 to disable the override.\nDefault: 4");
|
||||
}
|
||||
break;
|
||||
|
||||
case "Ranges":
|
||||
ImGui.Text("Standard Ranges (Yards)");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputInt("Monster Range", ref _settings.MonsterRange)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.SetTooltip("Detection range in yards. Same units as VTank.\n" +
|
||||
"Max bow range ≈ 70 yards. Magic ≈ 68 yards.\n" +
|
||||
"AC internal = yards / 240");
|
||||
}
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputInt("Ring Range", ref _settings.RingRange)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.SetTooltip("Distance at which Ring spells are used instead of other shapes.");
|
||||
}
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputInt("Approach Range", ref _settings.ApproachRange)) OnSettingsChanged?.Invoke();
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Text("Corpse Acquisition (AC Units)");
|
||||
ImGui.Separator();
|
||||
// MOVED FROM MAIN TAB
|
||||
ImGui.SetNextItemWidth(180);
|
||||
if (ImGui.InputDouble("Corpse Max", ref _settings.CorpseApproachRangeMax, 0.005, 0.01, "%.6f")) OnSettingsChanged?.Invoke();
|
||||
ImGui.SetNextItemWidth(180);
|
||||
if (ImGui.InputDouble("Corpse Min", ref _settings.CorpseApproachRangeMin, 0.005, 0.01, "%.6f")) OnSettingsChanged?.Invoke();
|
||||
break;
|
||||
|
||||
case "Navigation":
|
||||
if (ImGui.Checkbox("Boost Nav Priority", ref _settings.BoostNavPriority)) OnSettingsChanged?.Invoke();
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputFloat("Follow/Nav Min", ref _settings.FollowNavMin, 0.1f, 1.0f, "%.1f")) OnSettingsChanged?.Invoke();
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Text("Movement Engine");
|
||||
ImGui.SetNextItemWidth(200);
|
||||
if (ImGui.Combo("Mode", ref _settings.MovementMode, _movementModes, _movementModes.Length))
|
||||
OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(
|
||||
"Legacy: SetAutorun + TurnLeft/TurnRight (VTank-style)\n" +
|
||||
"Tier 1: Direct CM_Movement server events\n" +
|
||||
"Tier 2: Client physics MoveToPosition (smooth arcs, experimental)");
|
||||
if (_settings.MovementMode == 2 && !Tier2MovementHelper.IsInitialized)
|
||||
{
|
||||
ImGui.SameLine();
|
||||
ImGui.TextColored(new Vector4(1, 0.4f, 0.4f, 1), "(not initialized)");
|
||||
}
|
||||
|
||||
// ── Steering (all modes) ─────────────────────────────────
|
||||
ImGui.Spacing();
|
||||
ImGui.Separator();
|
||||
ImGui.Text("Steering");
|
||||
|
||||
ImGui.SetNextItemWidth(80);
|
||||
if (ImGui.InputFloat("Stop & Turn Angle", ref _settings.NavStopTurnAngle, 1f, 5f, "%.0f")) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Stop forward motion and turn in place when heading error exceeds this many degrees.\nLower = more precise but stop-start. Higher = wider arcs.");
|
||||
|
||||
ImGui.SetNextItemWidth(80);
|
||||
if (ImGui.InputFloat("Resume Run Angle", ref _settings.NavResumeTurnAngle, 1f, 5f, "%.0f")) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Resume running once the turn-in-place error drops below this.\nMust be less than Stop & Turn Angle.");
|
||||
|
||||
ImGui.SetNextItemWidth(80);
|
||||
if (ImGui.InputFloat("Dead Zone", ref _settings.NavDeadZone, 0.5f, 1f, "%.1f")) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Ignore heading corrections smaller than this.\nSmaller = tighter line but more twitchy. Larger = smoother but wider path.");
|
||||
|
||||
ImGui.SetNextItemWidth(80);
|
||||
if (ImGui.InputFloat("Sweep Detect Mult", ref _settings.NavSweepMult, 0.5f, 1f, "%.1f")) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Closest-approach detection radius = Arrival Radius * this.\nIf distance was decreasing and starts increasing within this radius, advance to next waypoint.\nHigher = more forgiving on tight turns. Lower = must pass closer.");
|
||||
|
||||
// ── Tier 2 tuning (only visible when mode 2 selected) ────
|
||||
if (_settings.MovementMode == 2)
|
||||
{
|
||||
ImGui.Spacing();
|
||||
ImGui.Separator();
|
||||
ImGui.Text("Tier 2 Tuning");
|
||||
|
||||
ImGui.SetNextItemWidth(100);
|
||||
if (ImGui.InputFloat("Speed##t2", ref _settings.T2Speed, 0.1f, 0.5f, "%.1f")) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Movement speed multiplier (1.0 = normal run speed)");
|
||||
|
||||
ImGui.SetNextItemWidth(100);
|
||||
if (ImGui.InputFloat("Walk Within (yd)", ref _settings.T2WalkWithinYd, 1f, 5f, "%.0f")) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Switch from run to walk when within this many yards of the waypoint.\n0 = always run.");
|
||||
|
||||
ImGui.SetNextItemWidth(100);
|
||||
if (ImGui.InputFloat("Stop Distance (yd)", ref _settings.T2DistanceTo, 0.1f, 0.5f, "%.1f")) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Stop this far from the target position (yards)");
|
||||
|
||||
ImGui.SetNextItemWidth(100);
|
||||
if (ImGui.InputFloat("Reissue Timeout (ms)", ref _settings.T2ReissueMs, 100f, 500f, "%.0f")) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Re-send MoveToPosition if no progress after this many ms");
|
||||
|
||||
ImGui.SetNextItemWidth(100);
|
||||
if (ImGui.InputFloat("Max Range (yd)", ref _settings.T2MaxRangeYd, 50f, 100f, "%.0f")) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Clamp waypoint distance to this. Will re-issue as you get closer.");
|
||||
|
||||
ImGui.SetNextItemWidth(100);
|
||||
if (ImGui.InputInt("Max Landblock Dist", ref _settings.T2MaxLandblocks, 1)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Skip MoveToPosition if target is more than N landblocks away");
|
||||
}
|
||||
break;
|
||||
|
||||
case "Buffing":
|
||||
if (ImGui.Checkbox("Enable Buffing", ref _settings.EnableBuffing)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.Checkbox("Rebuff When Idle", ref _settings.RebuffWhenIdle)) OnSettingsChanged?.Invoke();
|
||||
break;
|
||||
|
||||
case "Looting":
|
||||
if (ImGui.Checkbox("Enable Looting", ref _settings.EnableLooting)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.Checkbox("Boost Loot Priority", ref _settings.BoostLootPriority)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.Checkbox("Loot Only Rare Corpses", ref _settings.LootOnlyRareCorpses)) OnSettingsChanged?.Invoke();
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Text("Corpse Ownership");
|
||||
ImGui.SetNextItemWidth(180);
|
||||
if (ImGui.Combo("Loot From", ref _settings.LootOwnership, _lootOwnershipModes, _lootOwnershipModes.Length))
|
||||
OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("My Kills Only: Only loot corpses you killed.\nFellowship Kills: Loot kills by any fellowship member.\nAll Corpses: Loot everything within range.");
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Text("Inventory Management");
|
||||
if (ImGui.Checkbox("Enable Autostack", ref _settings.EnableAutostack)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.Checkbox("Enable Autocram", ref _settings.EnableAutocram)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.Checkbox("Combine Salvage Bags", ref _settings.EnableCombineSalvage)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered())
|
||||
{
|
||||
ImGui.SetTooltip("When enabled, salvage bags of the same material type\nare automatically combined after salvaging.");
|
||||
}
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Separator();
|
||||
ImGui.Text("Loot Timers (ms)");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputInt("Inter-Item Delay", ref _settings.LootInterItemDelayMs)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Delay between picking up each item from a corpse.");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputInt("Content Settle", ref _settings.LootContentSettleMs)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Wait for corpse contents to populate after opening.");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputInt("Empty Corpse Wait", ref _settings.LootEmptyCorpseMs)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("How long to wait before declaring a corpse empty.");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputInt("Closing Delay", ref _settings.LootClosingDelayMs)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Delay before closing corpse after all items looted.");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputInt("Assess Window", ref _settings.LootAssessWindowMs)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Max time to wait for item ID data from server.");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputInt("Loot Retry Timeout", ref _settings.LootRetryTimeoutMs)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("Retry picking up an item after this many ms.");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputInt("Corpse Open Retry", ref _settings.LootOpenRetryMs)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip("If corpse doesn't open, retry UseItem after this many ms.\nLower = faster but may toggle-close an already-opening corpse.");
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Separator();
|
||||
ImGui.Text("Salvage Timers (ms) — First / Fast");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputInt("Open (First)", ref _settings.SalvageOpenDelayFirstMs)) OnSettingsChanged?.Invoke();
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputInt("Open (Fast)", ref _settings.SalvageOpenDelayFastMs)) OnSettingsChanged?.Invoke();
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputInt("Add Item (First)", ref _settings.SalvageAddDelayFirstMs)) OnSettingsChanged?.Invoke();
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputInt("Add Item (Fast)", ref _settings.SalvageAddDelayFastMs)) OnSettingsChanged?.Invoke();
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputInt("Salvage Click", ref _settings.SalvageSalvageDelayMs)) OnSettingsChanged?.Invoke();
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputInt("Result (First)", ref _settings.SalvageResultDelayFirstMs)) OnSettingsChanged?.Invoke();
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputInt("Result (Fast)", ref _settings.SalvageResultDelayFastMs)) OnSettingsChanged?.Invoke();
|
||||
break;
|
||||
|
||||
case "Crafting":
|
||||
ImGui.Text("Missile Ammo Crafting");
|
||||
ImGui.Separator();
|
||||
ImGui.Spacing();
|
||||
|
||||
if (ImGui.Checkbox("Enable Missile Crafting", ref _settings.EnableMissileCrafting)) OnSettingsChanged?.Invoke();
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("Auto-manage missile ammo when the ammo slot is empty:\n\n1. If better ammo can be crafted from bundles → craft it\n2. Otherwise equip the best loose ammo in inventory\n3. If no ammo exists → craft from bundles, then equip\n\nRequires Fletching skill (Trained or Specialized).\nEach combine: 1 head bundle + 1 shaft bundle = 1000 ammo.");
|
||||
|
||||
if (!_settings.EnableMissileCrafting) { ImGui.TextDisabled("(Disabled)"); break; }
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Separator();
|
||||
ImGui.Spacing();
|
||||
|
||||
if (_missileCraftingManager != null)
|
||||
{
|
||||
string stateLabel = _missileCraftingManager.State.ToString();
|
||||
Vector4 stateColor = _missileCraftingManager.IsCrafting
|
||||
? new Vector4(0.2f, 1.0f, 0.4f, 1.0f)
|
||||
: new Vector4(0.6f, 0.6f, 0.6f, 1.0f);
|
||||
|
||||
ImGui.TextColored(stateColor, "State: " + stateLabel);
|
||||
|
||||
if (!string.IsNullOrEmpty(_missileCraftingManager.StatusMessage))
|
||||
ImGui.TextWrapped(_missileCraftingManager.StatusMessage);
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextDisabled("Crafting manager not initialized.");
|
||||
}
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.Separator();
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGui.TextDisabled("Ammo Types (by priority, highest first):");
|
||||
ImGui.BulletText("Lethal Prismatic (Specialized)");
|
||||
ImGui.BulletText("Deadly Prismatic (Specialized)");
|
||||
ImGui.BulletText("Greater Prismatic (Trained)");
|
||||
ImGui.BulletText("Prismatic (Trained)");
|
||||
ImGui.BulletText("Armor Piercing, Broad, Blunt, etc. (Trained)");
|
||||
ImGui.Spacing();
|
||||
ImGui.TextDisabled("Weapon → Ammo:");
|
||||
ImGui.BulletText("Bow → Arrows (arrowheads + arrowshafts)");
|
||||
ImGui.BulletText("Crossbow → Quarrels (quarrelheads + quarrelshafts)");
|
||||
ImGui.BulletText("Atlatl → Darts (dart heads + dart shafts)");
|
||||
break;
|
||||
|
||||
default:
|
||||
ImGui.Text($"Settings for {tabName} are currently under development.");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
157
Plugins/RynthAi/UI/LuaUI.cs
Normal file
157
Plugins/RynthAi/UI/LuaUI.cs
Normal file
|
|
@ -0,0 +1,157 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using Decal.Adapter.Wrappers;
|
||||
|
||||
namespace NexSuite.Plugins.RynthAi
|
||||
{
|
||||
public class LuaUI
|
||||
{
|
||||
private readonly UISettings _settings;
|
||||
private readonly Decal.Adapter.CoreManager _core;
|
||||
|
||||
// Delegates for PluginCore to hook into
|
||||
public Action OnSettingsChanged;
|
||||
public Action<string> OnExecuteRequested;
|
||||
public Action OnStopRequested;
|
||||
|
||||
// Internal State
|
||||
private string _luaFolder = @"C:\Games\DecalPlugins\NexSuite\RynthAi\LuaScripts";
|
||||
private string _newLuaFileName = "MyScript";
|
||||
private int _selectedLuaIdx = 0;
|
||||
public List<string> LuaFiles = new List<string>();
|
||||
|
||||
private string _selectedSnippetKey = "--- Select Snippet ---";
|
||||
private Dictionary<string, string> _luaSnippets = new Dictionary<string, string>
|
||||
{
|
||||
{ "--- Select Snippet ---", "" },
|
||||
{ "📍 Move to Coord", "RynthAi:GoTo(\"0.0N\", \"0.0E\")" },
|
||||
{ "🌀 Use Portal/NPC", "RynthAi:UsePortal(\"Portal Name\")" },
|
||||
{ "📏 Get Distance", "local dist = RynthAi:GetDistance(\"Object Name\")\nprint(\"Distance: \" .. dist)" },
|
||||
{ "🛑 Emergency Stop", "RynthAi:Stop()" }
|
||||
};
|
||||
|
||||
public LuaUI(UISettings settings, Decal.Adapter.CoreManager core)
|
||||
{
|
||||
_settings = settings;
|
||||
_core = core;
|
||||
RefreshLuaFiles();
|
||||
}
|
||||
|
||||
public void RefreshLuaFiles()
|
||||
{
|
||||
LuaFiles.Clear();
|
||||
LuaFiles.Add("None");
|
||||
if (Directory.Exists(_luaFolder))
|
||||
{
|
||||
foreach (var file in Directory.GetFiles(_luaFolder, "*.lua"))
|
||||
LuaFiles.Add(Path.GetFileNameWithoutExtension(file));
|
||||
}
|
||||
}
|
||||
|
||||
public void Render()
|
||||
{
|
||||
// Safety Checks
|
||||
if (_settings.LuaScript == null) _settings.LuaScript = "";
|
||||
if (_settings.LuaConsoleOutput == null) _settings.LuaConsoleOutput = "";
|
||||
|
||||
// 1. File & Snippet Bar
|
||||
RenderTopBar();
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
// 2. Toolbar (Run, Stop, Clear)
|
||||
RenderToolbar();
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
// 3. Editor & Console
|
||||
RenderEditorAndConsole();
|
||||
}
|
||||
|
||||
private void RenderTopBar()
|
||||
{
|
||||
ImGui.SetNextItemWidth(120);
|
||||
string preview = (_selectedLuaIdx < LuaFiles.Count) ? LuaFiles[_selectedLuaIdx] : "None";
|
||||
if (ImGui.BeginCombo("##LoadLua", preview))
|
||||
{
|
||||
for (int i = 0; i < LuaFiles.Count; i++)
|
||||
{
|
||||
if (ImGui.Selectable(LuaFiles[i], _selectedLuaIdx == i))
|
||||
{
|
||||
_selectedLuaIdx = i;
|
||||
if (LuaFiles[i] != "None")
|
||||
{
|
||||
string path = Path.Combine(_luaFolder, LuaFiles[i] + ".lua");
|
||||
if (File.Exists(path)) { _settings.LuaScript = File.ReadAllText(path); OnSettingsChanged?.Invoke(); }
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("🔄")) RefreshLuaFiles();
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.SetNextItemWidth(120);
|
||||
ImGui.InputText("##SaveAs", ref _newLuaFileName, 64);
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("💾"))
|
||||
{
|
||||
if (!Directory.Exists(_luaFolder)) Directory.CreateDirectory(_luaFolder);
|
||||
File.WriteAllText(Path.Combine(_luaFolder, _newLuaFileName + ".lua"), _settings.LuaScript);
|
||||
RefreshLuaFiles();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
RenderSnippets();
|
||||
}
|
||||
|
||||
private void RenderSnippets()
|
||||
{
|
||||
ImGui.SetNextItemWidth(150);
|
||||
if (ImGui.BeginCombo("##Snippets", _selectedSnippetKey))
|
||||
{
|
||||
foreach (var s in _luaSnippets)
|
||||
{
|
||||
if (ImGui.Selectable(s.Key))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_settings.LuaScript) && !_settings.LuaScript.EndsWith("\n")) _settings.LuaScript += "\n";
|
||||
_settings.LuaScript += s.Value;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
}
|
||||
|
||||
private void RenderToolbar()
|
||||
{
|
||||
if (ImGui.Button("▶ Run Script")) OnExecuteRequested?.Invoke(_settings.LuaScript);
|
||||
ImGui.SameLine();
|
||||
ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0.7f, 0.1f, 0.1f, 1.0f));
|
||||
if (ImGui.Button("🛑 Stop")) OnStopRequested?.Invoke();
|
||||
ImGui.PopStyleColor();
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("🧹 Clear Console")) { _settings.LuaConsoleOutput = "--- Console Cleared ---"; OnSettingsChanged?.Invoke(); }
|
||||
}
|
||||
|
||||
private void RenderEditorAndConsole()
|
||||
{
|
||||
float editorH = ImGui.GetContentRegionAvail().Y - 150;
|
||||
ImGui.InputTextMultiline("##LuaEditor", ref _settings.LuaScript, 50000, new Vector2(-1, editorH), ImGuiInputTextFlags.AllowTabInput);
|
||||
|
||||
ImGui.TextDisabled("Console Output:");
|
||||
if (ImGui.BeginChild("LuaConsole", new Vector2(-1, 0), true, ImGuiWindowFlags.HorizontalScrollbar))
|
||||
{
|
||||
ImGui.TextUnformatted(_settings.LuaConsoleOutput);
|
||||
if (ImGui.GetScrollY() >= ImGui.GetScrollMaxY()) ImGui.SetScrollHereY(1.0f);
|
||||
}
|
||||
ImGui.EndChild();
|
||||
}
|
||||
}
|
||||
}
|
||||
650
Plugins/RynthAi/UI/MetaUI.cs
Normal file
650
Plugins/RynthAi/UI/MetaUI.cs
Normal file
|
|
@ -0,0 +1,650 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Linq;
|
||||
using ImGuiNET;
|
||||
using RynthAi.Meta;
|
||||
|
||||
namespace NexSuite.Plugins.RynthAi
|
||||
{
|
||||
public class MetaUI
|
||||
{
|
||||
private readonly UISettings _settings;
|
||||
private readonly List<string> _navFiles; // Passed in so we can embed routes
|
||||
|
||||
public Action OnSettingsChanged;
|
||||
public Action OnMetaRulesUpdated;
|
||||
|
||||
// --- META STATE ---
|
||||
private bool _showMetaEditor = false;
|
||||
private MetaRule _editingRule = new MetaRule();
|
||||
private int _editingRuleIndex = -1;
|
||||
private string _newStateName = "";
|
||||
|
||||
// --- META DICTIONARIES ---
|
||||
private readonly string[] _metaConditionNames = {
|
||||
"Never", "Always", "All", "Any", "Chat Message", "Pack Slots <=",
|
||||
"Seconds in State >=", "Character Death", "Any Vendor Open",
|
||||
"Vendor Closed", "Inventory Item Count <=", "Inventory Item Count >=",
|
||||
"Monster Name Count Within Distance", "Monster Priority Count Within Distance",
|
||||
"Need To Buff", "No Monsters Within Distance", "Landblock ==",
|
||||
"Landcell ==", "Portalspace Entered", "Portalspace Exited", "Not",
|
||||
"Seconds in State (P) >=", "Time Left On Spell >=", "Time Left On Spell <=",
|
||||
"Burden Percentage >=", "Dist Any Route PT >=", "Expression",
|
||||
"Chat Message Capture", "Navroute Empty"
|
||||
};
|
||||
|
||||
private readonly string[] _metaActionNames = {
|
||||
"None", "Chat Command", "Set Meta State", "Embedded Nav Route", "All",
|
||||
"Call Meta State", "Return From Call", "Expression Action", "Chat Expression",
|
||||
"Set Watchdog", "Clear Watchdog", "Get NT Option", "Set NT Option",
|
||||
"Create View", "Destroy View", "Destroy All Views"
|
||||
};
|
||||
|
||||
public MetaUI(UISettings settings, List<string> navFiles)
|
||||
{
|
||||
_settings = settings;
|
||||
_navFiles = navFiles;
|
||||
}
|
||||
|
||||
public void Render()
|
||||
{
|
||||
if (ImGui.BeginTable("MetaRulesTable", 6, ImGuiTableFlags.BordersInnerH | ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY, new Vector2(0, -35)))
|
||||
{
|
||||
ImGui.TableSetupColumn("Up", ImGuiTableColumnFlags.WidthFixed, 20);
|
||||
ImGui.TableSetupColumn("Dn", ImGuiTableColumnFlags.WidthFixed, 20);
|
||||
ImGui.TableSetupColumn("Del", ImGuiTableColumnFlags.WidthFixed, 25);
|
||||
ImGui.TableSetupColumn("State", ImGuiTableColumnFlags.WidthFixed, 100);
|
||||
ImGui.TableSetupColumn("Condition", ImGuiTableColumnFlags.WidthStretch);
|
||||
ImGui.TableSetupColumn("Action", ImGuiTableColumnFlags.WidthStretch);
|
||||
ImGui.TableHeadersRow();
|
||||
|
||||
var groupedRules = _settings.MetaRules
|
||||
.GroupBy(r => r.State)
|
||||
.OrderBy(g => g.Key)
|
||||
.ToList();
|
||||
|
||||
foreach (var group in groupedRules)
|
||||
{
|
||||
ImGui.TableNextRow();
|
||||
ImGui.TableSetColumnIndex(3);
|
||||
ImGui.TextColored(new Vector4(0, 1, 1, 1), $"--- State: {group.Key} ---");
|
||||
|
||||
var stateRules = group.ToList();
|
||||
for (int i = 0; i < stateRules.Count; i++)
|
||||
{
|
||||
var rule = stateRules[i];
|
||||
int globalIdx = _settings.MetaRules.IndexOf(rule);
|
||||
|
||||
ImGui.TableNextRow();
|
||||
|
||||
bool isFired = rule.HasFired;
|
||||
if (isFired) ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1f, 0.2f, 0.2f, 1f));
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
if (i > 0 && ImGui.Button($"^##up{globalIdx}"))
|
||||
{
|
||||
var prevRule = stateRules[i - 1];
|
||||
int prevGlobalIdx = _settings.MetaRules.IndexOf(prevRule);
|
||||
_settings.MetaRules[globalIdx] = prevRule;
|
||||
_settings.MetaRules[prevGlobalIdx] = rule;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
if (i < stateRules.Count - 1 && ImGui.Button($"v##dn{globalIdx}"))
|
||||
{
|
||||
var nextRule = stateRules[i + 1];
|
||||
int nextGlobalIdx = _settings.MetaRules.IndexOf(nextRule);
|
||||
_settings.MetaRules[globalIdx] = nextRule;
|
||||
_settings.MetaRules[nextGlobalIdx] = rule;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.PushStyleColor(ImGuiCol.Text, new Vector4(1, 0, 0, 1));
|
||||
if (ImGui.Button($"X##delm{globalIdx}")) { _settings.MetaRules.Remove(rule); OnSettingsChanged?.Invoke(); }
|
||||
ImGui.PopStyleColor();
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
if (ImGui.Selectable($"{rule.State}##edit{globalIdx}", false, ImGuiSelectableFlags.SpanAllColumns))
|
||||
{
|
||||
_editingRule = new MetaRule { State = rule.State, Condition = rule.Condition, ConditionData = rule.ConditionData, Action = rule.Action, ActionData = rule.ActionData };
|
||||
if (rule.Children != null)
|
||||
{
|
||||
string json = Newtonsoft.Json.JsonConvert.SerializeObject(rule.Children);
|
||||
_editingRule.Children = Newtonsoft.Json.JsonConvert.DeserializeObject<List<MetaRule>>(json);
|
||||
}
|
||||
_editingRuleIndex = globalIdx;
|
||||
_showMetaEditor = true;
|
||||
}
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.Text(rule.Condition.ToString() + (string.IsNullOrEmpty(rule.ConditionData) ? "" : $": {rule.ConditionData}"));
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
if (rule.Action == MetaActionType.All)
|
||||
{
|
||||
int childCount = rule.Children?.Count ?? 0;
|
||||
ImGui.TextColored(new Vector4(1, 1, 0, 1), $"All: [{childCount} actions]");
|
||||
}
|
||||
else if (rule.Action == MetaActionType.EmbeddedNavRoute && !string.IsNullOrEmpty(rule.ActionData) && rule.ActionData.Contains(";"))
|
||||
{
|
||||
var parts = rule.ActionData.Split(';');
|
||||
ImGui.Text($"EmbeddedNavRoute: {parts[0]} ({parts[1]} pts)");
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.Text(rule.Action.ToString() + (string.IsNullOrEmpty(rule.ActionData) ? "" : $": {rule.ActionData}"));
|
||||
}
|
||||
|
||||
if (isFired) ImGui.PopStyleColor();
|
||||
}
|
||||
}
|
||||
ImGui.EndTable();
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
bool isMetaEnabled = _settings.EnableMeta;
|
||||
if (ImGui.Checkbox("Enable Meta", ref isMetaEnabled))
|
||||
{
|
||||
_settings.EnableMeta = isMetaEnabled;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.Text("Current State:");
|
||||
ImGui.SameLine();
|
||||
|
||||
ImGui.SetNextItemWidth(150);
|
||||
if (ImGui.BeginCombo("##CurrentStateDropdown", _settings.CurrentState))
|
||||
{
|
||||
if (ImGui.Selectable("< Create New State >"))
|
||||
{
|
||||
ImGui.OpenPopup("CreateStatePopup");
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
var uniqueStates = _settings.MetaRules.Select(r => r.State).Distinct().ToList();
|
||||
if (!uniqueStates.Contains("Default")) uniqueStates.Insert(0, "Default");
|
||||
|
||||
foreach (var state in uniqueStates)
|
||||
{
|
||||
if (ImGui.Selectable(state, _settings.CurrentState == state))
|
||||
{
|
||||
if (_settings.CurrentState == state) _settings.ForceStateReset = true;
|
||||
_settings.CurrentState = state;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
if (ImGui.BeginPopupModal("CreateStatePopup", ref _showMetaEditor, ImGuiWindowFlags.AlwaysAutoResize))
|
||||
{
|
||||
ImGui.Text("Enter New State Name:");
|
||||
ImGui.InputText("##newStateIn", ref _newStateName, 64);
|
||||
ImGui.Spacing();
|
||||
if (ImGui.Button("Create", new Vector2(120, 0)))
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_newStateName))
|
||||
{
|
||||
_settings.CurrentState = _newStateName;
|
||||
_newStateName = "";
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("Cancel", new Vector2(120, 0))) { ImGui.CloseCurrentPopup(); }
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
ImGui.SameLine(ImGui.GetWindowWidth() - 100);
|
||||
if (ImGui.Button("Create", new Vector2(80, 25)))
|
||||
{
|
||||
_editingRule = new MetaRule { State = _settings.CurrentState };
|
||||
_editingRuleIndex = -1;
|
||||
_showMetaEditor = true;
|
||||
}
|
||||
|
||||
RenderMetaEditorPopup();
|
||||
}
|
||||
|
||||
private void RenderMetaEditorPopup()
|
||||
{
|
||||
if (_showMetaEditor) ImGui.OpenPopup("Edit Meta Rule");
|
||||
|
||||
ImGui.SetNextWindowSize(new Vector2(650, 450), ImGuiCond.Appearing);
|
||||
|
||||
if (ImGui.BeginPopupModal("Edit Meta Rule", ref _showMetaEditor, ImGuiWindowFlags.NoCollapse))
|
||||
{
|
||||
float halfWidth = ImGui.GetContentRegionAvail().X / 2f - 4f;
|
||||
|
||||
var uniqueStates = _settings.MetaRules.Select(r => r.State).Distinct().ToList();
|
||||
if (!uniqueStates.Contains("Default")) uniqueStates.Insert(0, "Default");
|
||||
|
||||
ImGui.BeginChild("ConditionPane", new Vector2(halfWidth, -35), true);
|
||||
|
||||
ImGui.TextColored(new Vector4(0, 1, 1, 1), "Condition Type:");
|
||||
int condIdx = (int)_editingRule.Condition;
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
if (ImGui.Combo("##CondCombo", ref condIdx, _metaConditionNames, _metaConditionNames.Length))
|
||||
{
|
||||
_editingRule.Condition = (MetaConditionType)condIdx;
|
||||
ClearConditionDataIfNeeded(_editingRule);
|
||||
}
|
||||
|
||||
ImGui.TextColored(new Vector4(0, 1, 1, 1), "State Name:");
|
||||
ImGui.SetNextItemWidth(-30f);
|
||||
string tempState = _editingRule.State ?? "";
|
||||
if (ImGui.InputTextWithHint("##StateName", "State (e.g. Default)", ref tempState, 64))
|
||||
_editingRule.State = tempState;
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
if (ImGui.BeginCombo("##StatePicker", "", ImGuiComboFlags.NoPreview))
|
||||
{
|
||||
foreach (var state in uniqueStates)
|
||||
{
|
||||
if (ImGui.Selectable(state)) _editingRule.State = state;
|
||||
}
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
RenderRuleConditionNode(_editingRule, "root_cond");
|
||||
ImGui.EndChild();
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
ImGui.BeginChild("ActionPane", new Vector2(0, -35), true);
|
||||
ImGui.TextColored(new Vector4(1, 1, 0, 1), "Action Type:");
|
||||
RenderRuleActionNode(_editingRule, "root_action");
|
||||
ImGui.EndChild();
|
||||
|
||||
ImGui.SetCursorPosY(ImGui.GetWindowHeight() - 30);
|
||||
if (ImGui.Button(_editingRuleIndex == -1 ? "Add Rule" : "Save Rule", new Vector2(100, 25)))
|
||||
{
|
||||
if (_editingRuleIndex == -1) _settings.MetaRules.Add(_editingRule);
|
||||
else _settings.MetaRules[_editingRuleIndex] = _editingRule;
|
||||
|
||||
OnSettingsChanged?.Invoke();
|
||||
OnMetaRulesUpdated?.Invoke();
|
||||
|
||||
_showMetaEditor = false;
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("Cancel", new Vector2(100, 25))) { _showMetaEditor = false; }
|
||||
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
}
|
||||
|
||||
private void RenderRuleConditionNode(MetaRule rule, string idContext)
|
||||
{
|
||||
ImGui.PushID(idContext);
|
||||
|
||||
if (rule.Condition == MetaConditionType.Any ||
|
||||
rule.Condition == MetaConditionType.All ||
|
||||
rule.Condition == MetaConditionType.Not)
|
||||
{
|
||||
if (rule.Condition != MetaConditionType.Not || rule.Children.Count == 0)
|
||||
{
|
||||
if (ImGui.Button("+##add"))
|
||||
{
|
||||
rule.Children.Add(new MetaRule() { Condition = MetaConditionType.Always });
|
||||
}
|
||||
ImGui.SameLine();
|
||||
}
|
||||
|
||||
ImGui.TextColored(new Vector4(1, 1, 0, 1), $"{rule.Condition} Sub-Conditions");
|
||||
ImGui.Indent(15f);
|
||||
|
||||
for (int i = 0; i < rule.Children.Count; i++)
|
||||
{
|
||||
var child = rule.Children[i];
|
||||
ImGui.PushID($"child_{i}");
|
||||
|
||||
int childCondIdx = (int)child.Condition;
|
||||
ImGui.SetNextItemWidth(150);
|
||||
if (ImGui.Combo("##Cond", ref childCondIdx, _metaConditionNames, _metaConditionNames.Length))
|
||||
{
|
||||
child.Condition = (MetaConditionType)childCondIdx;
|
||||
ClearConditionDataIfNeeded(child);
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
float startX = ImGui.GetCursorPosX();
|
||||
float startY = ImGui.GetCursorPosY();
|
||||
ImGui.SameLine(ImGui.GetWindowWidth() - 35f);
|
||||
|
||||
ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0.8f, 0.1f, 0.1f, 1f));
|
||||
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, new Vector4(1f, 0.2f, 0.2f, 1f));
|
||||
bool deleteClicked = ImGui.Button("X");
|
||||
ImGui.PopStyleColor(2);
|
||||
|
||||
ImGui.SetCursorPos(new Vector2(startX, startY));
|
||||
RenderRuleConditionNode(child, $"node_{i}");
|
||||
|
||||
if (deleteClicked)
|
||||
{
|
||||
rule.Children.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
|
||||
ImGui.Dummy(new Vector2(0, 2f));
|
||||
ImGui.PopID();
|
||||
}
|
||||
|
||||
ImGui.Unindent(15f);
|
||||
}
|
||||
else
|
||||
{
|
||||
bool needsData = true;
|
||||
string condHint = "Data...";
|
||||
|
||||
if (rule.Condition == MetaConditionType.InventoryItemCount_LE ||
|
||||
rule.Condition == MetaConditionType.InventoryItemCount_GE)
|
||||
{
|
||||
string[] parts = (rule.ConditionData ?? "").Split(',');
|
||||
string itemName = parts[0];
|
||||
string itemCount = parts.Length > 1 ? parts[1] : "0";
|
||||
|
||||
ImGui.Text("Item Name:");
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
if (ImGui.InputText("##InvName", ref itemName, 64))
|
||||
rule.ConditionData = $"{itemName},{itemCount}";
|
||||
|
||||
ImGui.Text("Item Count:");
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
if (ImGui.InputText("##InvCount", ref itemCount, 16, ImGuiInputTextFlags.CharsDecimal))
|
||||
rule.ConditionData = $"{itemName},{itemCount}";
|
||||
|
||||
needsData = false;
|
||||
}
|
||||
else if (rule.Condition == MetaConditionType.TimeLeftOnSpell_GE ||
|
||||
rule.Condition == MetaConditionType.TimeLeftOnSpell_LE)
|
||||
{
|
||||
string[] parts = (rule.ConditionData ?? "").Split(',');
|
||||
string spellId = parts[0];
|
||||
string seconds = parts.Length > 1 ? parts[1] : "0";
|
||||
|
||||
ImGui.Text("Spell ID:");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputText("##SpellId", ref spellId, 16, ImGuiInputTextFlags.CharsDecimal))
|
||||
rule.ConditionData = $"{spellId},{seconds}";
|
||||
|
||||
if (int.TryParse(spellId, out int id))
|
||||
{
|
||||
string sName = SpellDatabase.GetSpellName(id);
|
||||
if (!string.IsNullOrEmpty(sName))
|
||||
{
|
||||
ImGui.SameLine();
|
||||
ImGui.TextColored(new Vector4(0, 1, 1, 1), $"({sName})");
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.Text("Seconds Remaining:");
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
if (ImGui.InputText("##SpellTime", ref seconds, 16, ImGuiInputTextFlags.CharsDecimal))
|
||||
rule.ConditionData = $"{spellId},{seconds}";
|
||||
|
||||
needsData = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (rule.Condition)
|
||||
{
|
||||
case MetaConditionType.Never:
|
||||
case MetaConditionType.Always:
|
||||
case MetaConditionType.CharacterDeath:
|
||||
case MetaConditionType.AnyVendorOpen:
|
||||
case MetaConditionType.VendorClosed:
|
||||
case MetaConditionType.NeedToBuff:
|
||||
case MetaConditionType.NoMonstersWithinDistance:
|
||||
case MetaConditionType.PortalspaceEntered:
|
||||
case MetaConditionType.PortalspaceExited:
|
||||
case MetaConditionType.NavrouteEmpty:
|
||||
needsData = false;
|
||||
break;
|
||||
case MetaConditionType.ChatMessage:
|
||||
case MetaConditionType.ChatMessageCapture:
|
||||
condHint = "Regex pattern...";
|
||||
break;
|
||||
case MetaConditionType.PackSlots_LE:
|
||||
condHint = "Min slots (e.g. 5)";
|
||||
break;
|
||||
case MetaConditionType.BurdenPercentage_GE:
|
||||
condHint = "Percentage (e.g. 250)";
|
||||
break;
|
||||
case MetaConditionType.SecondsInState_GE:
|
||||
case MetaConditionType.SecondsInStateP_GE:
|
||||
condHint = "Seconds (e.g. 10)";
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (needsData)
|
||||
{
|
||||
float availableSpace = ImGui.GetWindowWidth() - ImGui.GetCursorPosX() - 40f;
|
||||
ImGui.SetNextItemWidth(Math.Max(50f, availableSpace));
|
||||
|
||||
string cData = rule.ConditionData ?? "";
|
||||
if (ImGui.InputTextWithHint("##Data", condHint, ref cData, 256))
|
||||
rule.ConditionData = cData;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (rule.Condition != MetaConditionType.InventoryItemCount_LE &&
|
||||
rule.Condition != MetaConditionType.InventoryItemCount_GE &&
|
||||
rule.Condition != MetaConditionType.TimeLeftOnSpell_GE &&
|
||||
rule.Condition != MetaConditionType.TimeLeftOnSpell_LE)
|
||||
{
|
||||
ImGui.TextDisabled("(No extra data)");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.PopID();
|
||||
}
|
||||
|
||||
private void RenderRuleActionNode(MetaRule rule, string idContext)
|
||||
{
|
||||
ImGui.PushID(idContext);
|
||||
|
||||
int actionIdx = (int)rule.Action;
|
||||
ImGui.SetNextItemWidth(180);
|
||||
if (ImGui.Combo("##ActionType", ref actionIdx, _metaActionNames, _metaActionNames.Length))
|
||||
{
|
||||
rule.Action = (MetaActionType)actionIdx;
|
||||
if (rule.Action == MetaActionType.All) rule.ActionData = "";
|
||||
else if (rule.Children != null) rule.Children.Clear();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
if (rule.Action == MetaActionType.All)
|
||||
{
|
||||
ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0.2f, 0.6f, 0.2f, 1f));
|
||||
if (ImGui.Button("+ Add Action"))
|
||||
{
|
||||
rule.Children.Add(new MetaRule { Action = MetaActionType.ChatCommand });
|
||||
}
|
||||
ImGui.PopStyleColor();
|
||||
|
||||
ImGui.Indent(20f);
|
||||
for (int i = 0; i < rule.Children.Count; i++)
|
||||
{
|
||||
var child = rule.Children[i];
|
||||
ImGui.PushID($"act_child_{i}");
|
||||
|
||||
if (ImGui.Button("X"))
|
||||
{
|
||||
rule.Children.RemoveAt(i);
|
||||
i--;
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.SameLine();
|
||||
RenderRuleActionNode(child, $"child_node_{i}");
|
||||
}
|
||||
|
||||
ImGui.PopID();
|
||||
if (i < rule.Children.Count - 1) ImGui.Separator();
|
||||
}
|
||||
ImGui.Unindent(20f);
|
||||
}
|
||||
else
|
||||
{
|
||||
switch (rule.Action)
|
||||
{
|
||||
case MetaActionType.ChatCommand:
|
||||
string cmd = rule.ActionData ?? "";
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
if (ImGui.InputTextWithHint("##Cmd", "e.g. /tell {1} hello!", ref cmd, 256))
|
||||
rule.ActionData = cmd;
|
||||
break;
|
||||
|
||||
case MetaActionType.SetMetaState:
|
||||
case MetaActionType.CallMetaState:
|
||||
string state = rule.ActionData ?? "";
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
if (ImGui.InputTextWithHint("##State", "Target State Name...", ref state, 64))
|
||||
rule.ActionData = state;
|
||||
break;
|
||||
|
||||
case MetaActionType.EmbeddedNavRoute:
|
||||
if (ImGui.BeginCombo("##NavSelect", string.IsNullOrEmpty(rule.ActionData) ? "Select Route..." : rule.ActionData))
|
||||
{
|
||||
foreach (var navFile in _navFiles)
|
||||
{
|
||||
if (navFile == "None") continue;
|
||||
if (ImGui.Selectable(navFile, rule.ActionData == navFile))
|
||||
rule.ActionData = navFile;
|
||||
}
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
break;
|
||||
|
||||
case MetaActionType.SetWatchdog:
|
||||
string[] wdParts = (rule.ActionData ?? "Default;10;60").Split(';');
|
||||
string wdState = wdParts[0];
|
||||
string wdMeters = wdParts.Length > 1 ? wdParts[1] : "10";
|
||||
string wdSeconds = wdParts.Length > 2 ? wdParts[2] : "60";
|
||||
|
||||
ImGui.Text("To State:");
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
|
||||
var wdStates = _settings.MetaRules.Select(r => r.State).Distinct().ToList();
|
||||
if (!wdStates.Contains("Default")) wdStates.Insert(0, "Default");
|
||||
if (!wdStates.Contains(wdState) && !string.IsNullOrEmpty(wdState)) wdStates.Add(wdState);
|
||||
|
||||
if (ImGui.BeginCombo("##WDStateCombo", wdState))
|
||||
{
|
||||
foreach (var s in wdStates)
|
||||
{
|
||||
if (ImGui.Selectable(s, wdState == s))
|
||||
{
|
||||
wdState = s;
|
||||
}
|
||||
}
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGui.Text("Meters in:");
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
ImGui.InputText("##WDMeters", ref wdMeters, 8, ImGuiInputTextFlags.CharsDecimal);
|
||||
ImGui.Spacing();
|
||||
|
||||
ImGui.Text("Seconds:");
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
ImGui.InputText("##WDSecs", ref wdSeconds, 8, ImGuiInputTextFlags.CharsDecimal);
|
||||
|
||||
rule.ActionData = $"{wdState};{wdMeters};{wdSeconds}";
|
||||
break;
|
||||
|
||||
case MetaActionType.SetNTOption:
|
||||
string[] ntParts = (rule.ActionData ?? "EnableBuffing;False").Split(';');
|
||||
string ntO = ntParts[0];
|
||||
string ntV = ntParts.Length > 1 ? ntParts[1] : "False";
|
||||
|
||||
ImGui.Text("Option:");
|
||||
ImGui.SetNextItemWidth(120);
|
||||
if (ImGui.InputText("##NTOpt", ref ntO, 64)) rule.ActionData = $"{ntO};{ntV}";
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.Text("Val:");
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
if (ImGui.InputText("##NTVal", ref ntV, 64)) rule.ActionData = $"{ntO};{ntV}";
|
||||
break;
|
||||
|
||||
case MetaActionType.ExpressionAction:
|
||||
case MetaActionType.ChatExpression:
|
||||
string expr = rule.ActionData ?? "";
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
if (ImGui.InputTextWithHint("##Expr", "Expression (e.g. [SlotCount] < 5)", ref expr, 256))
|
||||
rule.ActionData = expr;
|
||||
break;
|
||||
|
||||
case MetaActionType.GetNTOption:
|
||||
case MetaActionType.CreateView:
|
||||
case MetaActionType.DestroyView:
|
||||
string vData = rule.ActionData ?? "";
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
if (ImGui.InputText("##ViewData", ref vData, 128))
|
||||
rule.ActionData = vData;
|
||||
break;
|
||||
|
||||
case MetaActionType.ReturnFromCall:
|
||||
case MetaActionType.ClearWatchdog:
|
||||
case MetaActionType.DestroyAllViews:
|
||||
ImGui.TextDisabled("(No extra data required)");
|
||||
break;
|
||||
|
||||
case MetaActionType.None:
|
||||
ImGui.TextDisabled("(Select an action type)");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.PopID();
|
||||
}
|
||||
|
||||
// ── Floating window wrapper (called from dashboard) ──────────────────
|
||||
public void RenderAsWindow(ref bool open)
|
||||
{
|
||||
ImGui.SetNextWindowSize(new Vector2(600, 460), ImGuiCond.FirstUseEver);
|
||||
if (ImGui.Begin("Macro Rules##RynthAiMeta", ref open))
|
||||
Render();
|
||||
ImGui.End();
|
||||
}
|
||||
|
||||
private void ClearConditionDataIfNeeded(MetaRule rule)
|
||||
{
|
||||
switch (rule.Condition)
|
||||
{
|
||||
case MetaConditionType.Always:
|
||||
case MetaConditionType.Never:
|
||||
case MetaConditionType.CharacterDeath:
|
||||
case MetaConditionType.AnyVendorOpen:
|
||||
case MetaConditionType.VendorClosed:
|
||||
case MetaConditionType.PortalspaceEntered:
|
||||
case MetaConditionType.PortalspaceExited:
|
||||
case MetaConditionType.NavrouteEmpty:
|
||||
rule.ConditionData = "";
|
||||
break;
|
||||
|
||||
case MetaConditionType.All:
|
||||
case MetaConditionType.Any:
|
||||
case MetaConditionType.Not:
|
||||
rule.ConditionData = "";
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
282
Plugins/RynthAi/UI/MonstersUI.cs
Normal file
282
Plugins/RynthAi/UI/MonstersUI.cs
Normal file
|
|
@ -0,0 +1,282 @@
|
|||
using System;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using Decal.Adapter;
|
||||
using Decal.Adapter.Wrappers;
|
||||
|
||||
namespace NexSuite.Plugins.RynthAi
|
||||
{
|
||||
public class MonstersUI
|
||||
{
|
||||
private readonly UISettings _settings;
|
||||
private readonly CoreManager _core;
|
||||
|
||||
public Action OnSettingsChanged;
|
||||
|
||||
// Local state just for this tab
|
||||
private string _newMonsterName = "";
|
||||
private readonly string[] _elements = { "Slash", "Pierce", "Bludgeon", "Fire", "Cold", "Lightning", "Acid", "Nether" };
|
||||
|
||||
public MonstersUI(UISettings settings, CoreManager core)
|
||||
{
|
||||
_settings = settings;
|
||||
_core = core;
|
||||
}
|
||||
|
||||
public void Render()
|
||||
{
|
||||
if (ImGui.BeginTable("MonstersGrid", 18, ImGuiTableFlags.NoSavedSettings | ImGuiTableFlags.Borders | ImGuiTableFlags.RowBg | ImGuiTableFlags.ScrollY, new Vector2(0, 300)))
|
||||
{
|
||||
ImGui.TableSetupColumn("F", ImGuiTableColumnFlags.WidthFixed, 15);
|
||||
ImGui.TableSetupColumn("B", ImGuiTableColumnFlags.WidthFixed, 15);
|
||||
ImGui.TableSetupColumn("G", ImGuiTableColumnFlags.WidthFixed, 15);
|
||||
ImGui.TableSetupColumn("I", ImGuiTableColumnFlags.WidthFixed, 15);
|
||||
ImGui.TableSetupColumn("Y", ImGuiTableColumnFlags.WidthFixed, 15);
|
||||
ImGui.TableSetupColumn("V", ImGuiTableColumnFlags.WidthFixed, 15);
|
||||
ImGui.TableSetupColumn("A", ImGuiTableColumnFlags.WidthFixed, 15);
|
||||
ImGui.TableSetupColumn("Bl", ImGuiTableColumnFlags.WidthFixed, 15);
|
||||
ImGui.TableSetupColumn("R", ImGuiTableColumnFlags.WidthFixed, 15);
|
||||
ImGui.TableSetupColumn("S", ImGuiTableColumnFlags.WidthFixed, 15);
|
||||
ImGui.TableSetupColumn("Name", ImGuiTableColumnFlags.WidthStretch);
|
||||
ImGui.TableSetupColumn("P", ImGuiTableColumnFlags.WidthFixed, 25);
|
||||
ImGui.TableSetupColumn("Dmg type", ImGuiTableColumnFlags.WidthFixed, 80);
|
||||
ImGui.TableSetupColumn("Ex Vuln", ImGuiTableColumnFlags.WidthFixed, 80);
|
||||
ImGui.TableSetupColumn("Weapon", ImGuiTableColumnFlags.WidthStretch);
|
||||
ImGui.TableSetupColumn("Offhand", ImGuiTableColumnFlags.WidthStretch);
|
||||
ImGui.TableSetupColumn("PetDmg", ImGuiTableColumnFlags.WidthFixed, 70);
|
||||
ImGui.TableSetupColumn("Del", ImGuiTableColumnFlags.WidthFixed, 30);
|
||||
|
||||
ImGui.TableHeadersRow();
|
||||
|
||||
uint checkColor = ImGui.ColorConvertFloat4ToU32(new Vector4(0.2f, 1.0f, 0.2f, 1.0f));
|
||||
uint offColor = ImGui.ColorConvertFloat4ToU32(new Vector4(0.3f, 0.3f, 0.3f, 1.0f));
|
||||
|
||||
for (int i = 0; i < _settings.MonsterRules.Count; i++)
|
||||
{
|
||||
var rule = _settings.MonsterRules[i];
|
||||
bool isDefault = rule.Name.Equals("Default", StringComparison.OrdinalIgnoreCase);
|
||||
|
||||
ImGui.TableNextRow();
|
||||
|
||||
// --- 9 Toggle Lights ---
|
||||
ImGui.TableNextColumn();
|
||||
if (DrawToggleLight($"##F{i}", rule.Fester, checkColor, offColor, "F: Fester (Decrepitude's Grasp / Fester Other I-VIII)"))
|
||||
{ rule.Fester = !rule.Fester; OnSettingsChanged?.Invoke(); }
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
if (DrawToggleLight($"##B{i}", rule.Broadside, checkColor, offColor, "B: Broadside (Broadside of a Barn / Missile Weapons Ineptitude I-VIII)"))
|
||||
{ rule.Broadside = !rule.Broadside; OnSettingsChanged?.Invoke(); }
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
if (DrawToggleLight($"##G{i}", rule.GravityWell, checkColor, offColor, "G: Gravity Well (Vulnerability Other I-VIII)"))
|
||||
{ rule.GravityWell = !rule.GravityWell; OnSettingsChanged?.Invoke(); }
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
if (DrawToggleLight($"##I{i}", rule.Imperil, checkColor, offColor, "I: Imperil (Gossamer Flesh / Imperil Other I-VIII)"))
|
||||
{ rule.Imperil = !rule.Imperil; OnSettingsChanged?.Invoke(); }
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
if (DrawToggleLight($"##Y{i}", rule.Yield, checkColor, offColor, "Y: Yield (Magic Yield Other I-VIII)"))
|
||||
{ rule.Yield = !rule.Yield; OnSettingsChanged?.Invoke(); }
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
if (DrawToggleLight($"##V{i}", rule.Vuln, checkColor, offColor, "V: Vulnerability (element-matched)"))
|
||||
{ rule.Vuln = !rule.Vuln; OnSettingsChanged?.Invoke(); }
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
if (DrawToggleLight($"##A{i}", rule.UseArc, checkColor, offColor, "A: Arc spells (War/Void magic)\nFor Melee/Missile: Attack toggle"))
|
||||
{ rule.UseArc = !rule.UseArc; OnSettingsChanged?.Invoke(); }
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
if (DrawToggleLight($"##Bl{i}", rule.UseBolt, checkColor, offColor, "Bl: Bolt spells (War/Void magic, default)\nIf none of A/Bl/R/S set in magic = no attack (buff bot)"))
|
||||
{ rule.UseBolt = !rule.UseBolt; OnSettingsChanged?.Invoke(); }
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
if (DrawToggleLight($"##R{i}", rule.UseRing, checkColor, offColor, "R: Ring spells (uses Ring Range)"))
|
||||
{ rule.UseRing = !rule.UseRing; OnSettingsChanged?.Invoke(); }
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
if (DrawToggleLight($"##S{i}", rule.UseStreak, checkColor, offColor, "S: Streak spells (War/Void magic)"))
|
||||
{ rule.UseStreak = !rule.UseStreak; OnSettingsChanged?.Invoke(); }
|
||||
|
||||
// --- Name ---
|
||||
ImGui.TableNextColumn();
|
||||
if (isDefault) ImGui.TextColored(new Vector4(1, 1, 0, 1), rule.Name);
|
||||
else ImGui.Text(rule.Name);
|
||||
|
||||
// --- Priority ---
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.SetNextItemWidth(25);
|
||||
int p = rule.Priority;
|
||||
if (ImGui.InputInt($"##P{i}", ref p, 0)) { rule.Priority = p; OnSettingsChanged?.Invoke(); }
|
||||
|
||||
// --- Dmg type ---
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.SetNextItemWidth(80);
|
||||
if (ImGui.BeginCombo($"##Dmg{i}", rule.DamageType, ImGuiComboFlags.NoArrowButton))
|
||||
{
|
||||
if (ImGui.Selectable("Auto", rule.DamageType == "Auto")) { rule.DamageType = "Auto"; OnSettingsChanged?.Invoke(); }
|
||||
foreach (var el in _elements)
|
||||
{
|
||||
if (ImGui.Selectable(el, rule.DamageType == el))
|
||||
{ rule.DamageType = el; OnSettingsChanged?.Invoke(); }
|
||||
}
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
// --- Ex Vuln (extra vulnerability element) ---
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.SetNextItemWidth(80);
|
||||
if (ImGui.BeginCombo($"##Vuln{i}", rule.ExVuln, ImGuiComboFlags.NoArrowButton))
|
||||
{
|
||||
if (ImGui.Selectable("None", rule.ExVuln == "None")) { rule.ExVuln = "None"; OnSettingsChanged?.Invoke(); }
|
||||
foreach (var el in _elements)
|
||||
{
|
||||
if (ImGui.Selectable(el, rule.ExVuln == el))
|
||||
{ rule.ExVuln = el; OnSettingsChanged?.Invoke(); }
|
||||
}
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
// --- Weapon Dropdown ---
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
string currentWeaponName = "<AUTO>";
|
||||
if (rule.WeaponId != 0)
|
||||
{
|
||||
var matchedWep = _settings.ItemRules.FirstOrDefault(x => x.Id == rule.WeaponId);
|
||||
if (matchedWep != null) currentWeaponName = matchedWep.Name;
|
||||
}
|
||||
if (ImGui.BeginCombo($"##Wep{i}", currentWeaponName, ImGuiComboFlags.NoArrowButton))
|
||||
{
|
||||
if (ImGui.Selectable("<AUTO>", rule.WeaponId == 0))
|
||||
{ rule.WeaponId = 0; OnSettingsChanged?.Invoke(); }
|
||||
foreach (var itemRule in _settings.ItemRules)
|
||||
{
|
||||
if (ImGui.Selectable(itemRule.Name, rule.WeaponId == itemRule.Id))
|
||||
{ rule.WeaponId = itemRule.Id; OnSettingsChanged?.Invoke(); }
|
||||
}
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
// --- Offhand Dropdown (shield or dual-wield weapon from ItemRules) ---
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
string currentOffhandName = "<AUTO>";
|
||||
if (rule.OffhandId != 0)
|
||||
{
|
||||
var matchedOff = _settings.ItemRules.FirstOrDefault(x => x.Id == rule.OffhandId);
|
||||
if (matchedOff != null) currentOffhandName = matchedOff.Name;
|
||||
}
|
||||
if (ImGui.BeginCombo($"##Off{i}", currentOffhandName, ImGuiComboFlags.NoArrowButton))
|
||||
{
|
||||
if (ImGui.Selectable("<AUTO>", rule.OffhandId == 0))
|
||||
{ rule.OffhandId = 0; OnSettingsChanged?.Invoke(); }
|
||||
foreach (var itemRule in _settings.ItemRules)
|
||||
{
|
||||
if (ImGui.Selectable(itemRule.Name + "##off", rule.OffhandId == itemRule.Id))
|
||||
{ rule.OffhandId = itemRule.Id; OnSettingsChanged?.Invoke(); }
|
||||
}
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
// --- PetDmg (pet damage element) ---
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.SetNextItemWidth(70);
|
||||
if (ImGui.BeginCombo($"##PetDmg{i}", rule.PetDamage, ImGuiComboFlags.NoArrowButton))
|
||||
{
|
||||
if (ImGui.Selectable("PAuto", rule.PetDamage == "PAuto")) { rule.PetDamage = "PAuto"; OnSettingsChanged?.Invoke(); }
|
||||
foreach (var el in _elements)
|
||||
{
|
||||
if (ImGui.Selectable(el, rule.PetDamage == el))
|
||||
{ rule.PetDamage = el; OnSettingsChanged?.Invoke(); }
|
||||
}
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
// --- Delete ---
|
||||
ImGui.TableNextColumn();
|
||||
if (isDefault)
|
||||
{
|
||||
ImGui.TextDisabled("-");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ImGui.Button($"X##del{i}"))
|
||||
{
|
||||
_settings.MonsterRules.RemoveAt(i);
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui.EndTable();
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
if (ImGui.BeginTable("AddTable", 3))
|
||||
{
|
||||
ImGui.TableSetupColumn("NameIn", ImGuiTableColumnFlags.WidthStretch);
|
||||
ImGui.TableSetupColumn("AddBtn", ImGuiTableColumnFlags.WidthFixed, 60);
|
||||
ImGui.TableSetupColumn("AddSelBtn", ImGuiTableColumnFlags.WidthFixed, 80);
|
||||
|
||||
ImGui.TableNextRow();
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
ImGui.InputTextWithHint("##NewMonName", "Enter monster name to add...", ref _newMonsterName, 64);
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
if (ImGui.Button("Add", new Vector2(60, 22)))
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(_newMonsterName) && !_settings.MonsterRules.Any(m => m.Name.Equals(_newMonsterName, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
_settings.MonsterRules.Add(new MonsterRule { Name = _newMonsterName, DamageType = "Auto", WeaponId = 0 });
|
||||
_newMonsterName = "";
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
if (ImGui.Button("Add Sel", new Vector2(80, 22)))
|
||||
{
|
||||
int selectedId = _core.Actions.CurrentSelection;
|
||||
if (selectedId != 0)
|
||||
{
|
||||
var obj = _core.WorldFilter[selectedId];
|
||||
if (obj != null && !_settings.MonsterRules.Any(m => m.Name.Equals(obj.Name, StringComparison.OrdinalIgnoreCase)))
|
||||
{
|
||||
_settings.MonsterRules.Add(new MonsterRule { Name = obj.Name, DamageType = "Auto", WeaponId = 0 });
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
// ── Floating window wrapper (called from dashboard) ──────────────────
|
||||
public void RenderAsWindow(ref bool open)
|
||||
{
|
||||
ImGui.SetNextWindowSize(new Vector2(700, 400), ImGuiCond.FirstUseEver);
|
||||
if (ImGui.Begin("Monster Config##RynthAiMonsters", ref open))
|
||||
Render();
|
||||
ImGui.End();
|
||||
}
|
||||
|
||||
private bool DrawToggleLight(string id, bool isOn, uint onColor, uint offColor, string tooltip = null)
|
||||
{
|
||||
var pos = ImGui.GetCursorScreenPos();
|
||||
ImGui.GetWindowDrawList().AddRectFilled(
|
||||
pos + new Vector2(2, 2),
|
||||
pos + new Vector2(12, 12),
|
||||
isOn ? onColor : offColor, 10.0f
|
||||
);
|
||||
ImGui.InvisibleButton(id, new Vector2(14, 14));
|
||||
if (tooltip != null && ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip(tooltip);
|
||||
return ImGui.IsItemClicked();
|
||||
}
|
||||
}
|
||||
}
|
||||
337
Plugins/RynthAi/UI/RouteUI.cs
Normal file
337
Plugins/RynthAi/UI/RouteUI.cs
Normal file
|
|
@ -0,0 +1,337 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using ImGuiNET;
|
||||
using Decal.Adapter;
|
||||
using Decal.Adapter.Wrappers;
|
||||
|
||||
namespace NexSuite.Plugins.RynthAi
|
||||
{
|
||||
public class RouteUI
|
||||
{
|
||||
private readonly UISettings _settings;
|
||||
private readonly CoreManager _core;
|
||||
|
||||
public Action OnSettingsChanged;
|
||||
|
||||
// --- ROUTE STATE ---
|
||||
private readonly string[] _routeTypes = { "Once", "Circular", "Linear", "Follow" };
|
||||
private readonly string[] _addModes = { "End", "Above", "Below" };
|
||||
private int _addModeIdx = 0;
|
||||
private int _selectedRouteIndex = -1;
|
||||
|
||||
// --- GRAPHICS STATE ---
|
||||
public bool NeedsRouteGraphicsRefresh = false;
|
||||
private List<D3DObj> _routeGraphics = new List<D3DObj>();
|
||||
public List<D3DObj> TestD3DObjects = new List<D3DObj>();
|
||||
|
||||
public RouteUI(UISettings settings, CoreManager core)
|
||||
{
|
||||
_settings = settings;
|
||||
_core = core;
|
||||
}
|
||||
|
||||
public void Render()
|
||||
{
|
||||
string activeNavName = string.IsNullOrEmpty(_settings.CurrentNavPath) ? "None (Unsaved)" : Path.GetFileName(_settings.CurrentNavPath);
|
||||
ImGui.TextColored(new Vector4(1, 1, 0, 1), $"Active Nav: {activeNavName}");
|
||||
ImGui.Separator();
|
||||
|
||||
int rTypeIdx = 0;
|
||||
if (_settings.CurrentRoute.RouteType == NavRouteType.Circular) rTypeIdx = 1;
|
||||
else if (_settings.CurrentRoute.RouteType == NavRouteType.Linear) rTypeIdx = 2;
|
||||
else if (_settings.CurrentRoute.RouteType == NavRouteType.Follow) rTypeIdx = 3;
|
||||
|
||||
ImGui.SetNextItemWidth(100);
|
||||
if (ImGui.Combo("Route Type", ref rTypeIdx, _routeTypes, _routeTypes.Length))
|
||||
{
|
||||
if (rTypeIdx == 0) _settings.CurrentRoute.RouteType = NavRouteType.Once;
|
||||
else if (rTypeIdx == 1) _settings.CurrentRoute.RouteType = NavRouteType.Circular;
|
||||
else if (rTypeIdx == 2) _settings.CurrentRoute.RouteType = NavRouteType.Linear;
|
||||
else if (rTypeIdx == 3) _settings.CurrentRoute.RouteType = NavRouteType.Follow;
|
||||
|
||||
TryAutoSaveNav();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.SetNextItemWidth(100);
|
||||
ImGui.Combo("Insert", ref _addModeIdx, _addModes, _addModes.Length);
|
||||
|
||||
ImGui.Spacing();
|
||||
|
||||
if (ImGui.Button("Add Waypoint", new Vector2(100, 25)))
|
||||
{
|
||||
var me = _core.WorldFilter[_core.CharacterFilter.Id];
|
||||
if (me != null)
|
||||
{
|
||||
var newPt = new NavPoint
|
||||
{
|
||||
NS = me.Coordinates().NorthSouth,
|
||||
EW = me.Coordinates().EastWest,
|
||||
Z = me.Offset().Z
|
||||
};
|
||||
InsertPoint(newPt);
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("Add Portal", new Vector2(100, 25)))
|
||||
{
|
||||
try
|
||||
{
|
||||
var me = _core.WorldFilter[_core.CharacterFilter.Id];
|
||||
if (me != null)
|
||||
{
|
||||
var myPos = me.Coordinates();
|
||||
WorldObject best = null;
|
||||
double bestDist = double.MaxValue;
|
||||
foreach (WorldObject wo in _core.WorldFilter.GetLandscape())
|
||||
{
|
||||
if (wo == null) continue;
|
||||
if (wo.ObjectClass == ObjectClass.Portal || wo.ObjectClass == ObjectClass.Npc || wo.ObjectClass == ObjectClass.Vendor)
|
||||
{
|
||||
try
|
||||
{
|
||||
double dNS = wo.Coordinates().NorthSouth - myPos.NorthSouth;
|
||||
double dEW = wo.Coordinates().EastWest - myPos.EastWest;
|
||||
double d = Math.Sqrt(dNS * dNS + dEW * dEW) * 240.0;
|
||||
if (d < bestDist) { bestDist = d; best = wo; }
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
if (best != null && bestDist < 20.0)
|
||||
{
|
||||
var newPt = new NavPoint
|
||||
{
|
||||
Type = NavPointType.PortalNPC,
|
||||
NS = myPos.NorthSouth,
|
||||
EW = myPos.EastWest,
|
||||
Z = me.Offset().Z,
|
||||
TargetName = best.Name,
|
||||
ObjectClass = (int)best.ObjectClass,
|
||||
IsTie = false
|
||||
};
|
||||
InsertPoint(newPt);
|
||||
_core.Actions.AddChatText($"[RynthAi] Added Portal/NPC: {best.Name} ({bestDist:F1}yd)", 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
_core.Actions.AddChatText("[RynthAi] No portal/NPC found within 20 yards.", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex) { _core.Actions.AddChatText($"[RynthAi] Error: {ex.Message}", 1); }
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("Add Recall", new Vector2(100, 25)))
|
||||
{
|
||||
ImGui.OpenPopup("RecallPopup");
|
||||
}
|
||||
if (ImGui.BeginPopup("RecallPopup"))
|
||||
{
|
||||
int[] ids = {
|
||||
48, 2645, 2647,
|
||||
1635, 1636,
|
||||
157, 158, 1637,
|
||||
2648, 2649, 2650,
|
||||
2931, 2023, 2041, 2358, 2813, 2941, 2943,
|
||||
3865, 3929, 3930, 4084, 4198, 4213,
|
||||
4907, 4908, 4909,
|
||||
5175, 5330, 5541, 6150, 6321, 6322
|
||||
};
|
||||
|
||||
for (int ri = 0; ri < ids.Length; ri++)
|
||||
{
|
||||
string name = SpellDatabase.GetSpellName(ids[ri]);
|
||||
if (ImGui.Selectable($"{name} ({ids[ri]})"))
|
||||
{
|
||||
var me = _core.WorldFilter[_core.CharacterFilter.Id];
|
||||
if (me != null)
|
||||
{
|
||||
var newPt = new NavPoint
|
||||
{
|
||||
Type = NavPointType.Recall,
|
||||
NS = me.Coordinates().NorthSouth,
|
||||
EW = me.Coordinates().EastWest,
|
||||
Z = me.Offset().Z,
|
||||
SpellId = ids[ri]
|
||||
};
|
||||
InsertPoint(newPt);
|
||||
_core.Actions.AddChatText($"[RynthAi] Added Recall: {name} ({ids[ri]})", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui.EndPopup();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("Clear Route", new Vector2(100, 25)))
|
||||
{
|
||||
_settings.CurrentRoute.Points.Clear();
|
||||
_settings.ActiveNavIndex = 0;
|
||||
TryAutoSaveNav();
|
||||
DisposeRouteGraphics();
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.Button("Save Route", new Vector2(100, 25)))
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_settings.CurrentNavPath))
|
||||
{
|
||||
try { _settings.CurrentRoute.Save(_settings.CurrentNavPath); _core.Actions.AddChatText("[RynthAi] Route saved.", 1); } catch { }
|
||||
}
|
||||
}
|
||||
|
||||
if (ImGui.BeginListBox("##RoutePoints", new Vector2(-1, 200)))
|
||||
{
|
||||
for (int i = 0; i < _settings.CurrentRoute.Points.Count; i++)
|
||||
{
|
||||
// Push a unique ID so ImGui doesn't confuse the 50 different "X" buttons
|
||||
ImGui.PushID($"route_pt_{i}");
|
||||
|
||||
// Draw the red "X" button
|
||||
ImGui.PushStyleColor(ImGuiCol.Button, new Vector4(0.8f, 0.2f, 0.2f, 1f));
|
||||
if (ImGui.Button("X", new Vector2(20, 20)))
|
||||
{
|
||||
// 1. Remove the point
|
||||
_settings.CurrentRoute.Points.RemoveAt(i);
|
||||
|
||||
// 2. Safely shift our selected/active indexes so we don't crash
|
||||
if (_selectedRouteIndex == i) _selectedRouteIndex = -1;
|
||||
else if (_selectedRouteIndex > i) _selectedRouteIndex--;
|
||||
|
||||
if (_settings.ActiveNavIndex == i) _settings.ActiveNavIndex = 0;
|
||||
else if (_settings.ActiveNavIndex > i) _settings.ActiveNavIndex--;
|
||||
|
||||
// 3. Save, update 3D graphics, and notify the plugin
|
||||
TryAutoSaveNav();
|
||||
UpdateRouteGraphics();
|
||||
OnSettingsChanged?.Invoke();
|
||||
|
||||
// 4. Pop the styles and break the loop for this single frame to prevent index out-of-range errors
|
||||
ImGui.PopStyleColor();
|
||||
ImGui.PopID();
|
||||
break;
|
||||
}
|
||||
ImGui.PopStyleColor();
|
||||
|
||||
ImGui.SameLine();
|
||||
|
||||
// Draw the selectable row text
|
||||
string prefix = " ";
|
||||
if (i == _settings.ActiveNavIndex) prefix = "==>";
|
||||
|
||||
bool isSelected = (_selectedRouteIndex == i);
|
||||
if (ImGui.Selectable($"{prefix} [{i}] {_settings.CurrentRoute.Points[i]}", isSelected))
|
||||
{
|
||||
_selectedRouteIndex = i;
|
||||
}
|
||||
|
||||
ImGui.PopID();
|
||||
}
|
||||
ImGui.EndListBox();
|
||||
}
|
||||
}
|
||||
|
||||
public void InsertPoint(NavPoint newPt)
|
||||
{
|
||||
if (_addModeIdx == 0 || _settings.CurrentRoute.Points.Count == 0)
|
||||
_settings.CurrentRoute.Points.Add(newPt);
|
||||
else if (_addModeIdx == 1 && _selectedRouteIndex >= 0)
|
||||
_settings.CurrentRoute.Points.Insert(_selectedRouteIndex, newPt);
|
||||
else if (_addModeIdx == 2 && _selectedRouteIndex >= 0)
|
||||
_settings.CurrentRoute.Points.Insert(_selectedRouteIndex + 1, newPt);
|
||||
else
|
||||
_settings.CurrentRoute.Points.Add(newPt);
|
||||
|
||||
TryAutoSaveNav();
|
||||
UpdateRouteGraphics();
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
|
||||
public void TryAutoSaveNav()
|
||||
{
|
||||
if (!string.IsNullOrEmpty(_settings.CurrentNavPath))
|
||||
{
|
||||
try { _settings.CurrentRoute.Save(_settings.CurrentNavPath); } catch { }
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateRouteGraphics()
|
||||
{
|
||||
DisposeRouteGraphics();
|
||||
|
||||
if (_settings.CurrentRoute?.Points == null || _settings.CurrentRoute.Points.Count == 0)
|
||||
return;
|
||||
|
||||
if (_core?.D3DService == null)
|
||||
return;
|
||||
|
||||
int colorAqua = unchecked((int)0xFF00FFFF);
|
||||
int colorBlue = unchecked((int)0xFF0088FF);
|
||||
int colorRed = unchecked((int)0xFFFF2222);
|
||||
|
||||
float ringScale = Math.Max(0.5f, (float)_settings.FollowNavMin);
|
||||
|
||||
try
|
||||
{
|
||||
for (int i = 0; i < _settings.CurrentRoute.Points.Count; i++)
|
||||
{
|
||||
var pt = _settings.CurrentRoute.Points[i];
|
||||
int wpColor = (i == _settings.ActiveNavIndex) ? colorRed : colorAqua;
|
||||
|
||||
var ring = _core.D3DService.MarkCoordsWithShape(
|
||||
(float)pt.NS, (float)pt.EW, (float)pt.Z + 0.5f,
|
||||
Decal.Adapter.Wrappers.D3DShape.Ring, wpColor);
|
||||
ring.Visible = true;
|
||||
ring.ScaleX = ringScale;
|
||||
ring.ScaleY = ringScale;
|
||||
ring.ScaleZ = 0.1f;
|
||||
try { ring.Anchor((float)pt.NS, (float)pt.EW, (float)pt.Z + 0.5f); } catch { }
|
||||
_routeGraphics.Add(ring);
|
||||
|
||||
int nextIdx = i + 1;
|
||||
if (nextIdx >= _settings.CurrentRoute.Points.Count)
|
||||
{
|
||||
if (_settings.CurrentRoute.RouteType == NavRouteType.Circular) nextIdx = 0;
|
||||
else continue;
|
||||
}
|
||||
|
||||
var nextPt = _settings.CurrentRoute.Points[nextIdx];
|
||||
double dNS = nextPt.NS - pt.NS;
|
||||
double dEW = nextPt.EW - pt.EW;
|
||||
double dZ = nextPt.Z - pt.Z;
|
||||
double dist2D = Math.Sqrt(dNS * dNS + dEW * dEW) * 240.0;
|
||||
|
||||
int dots = Math.Min(150, Math.Max(2, (int)dist2D));
|
||||
|
||||
for (int d = 1; d < dots; d++)
|
||||
{
|
||||
double f = (double)d / dots;
|
||||
var dot = _core.D3DService.MarkCoordsWithShape(
|
||||
(float)(pt.NS + dNS * f),
|
||||
(float)(pt.EW + dEW * f),
|
||||
(float)(pt.Z + dZ * f) + 0.5f,
|
||||
Decal.Adapter.Wrappers.D3DShape.Sphere, colorBlue);
|
||||
dot.Visible = true;
|
||||
dot.Scale(0.15f);
|
||||
_routeGraphics.Add(dot);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public void DisposeRouteGraphics()
|
||||
{
|
||||
foreach (var o in _routeGraphics) { try { o.Visible = false; ((IDisposable)o).Dispose(); } catch { } }
|
||||
_routeGraphics.Clear();
|
||||
foreach (var o in TestD3DObjects) { try { o.Visible = false; ((IDisposable)o).Dispose(); } catch { } }
|
||||
TestD3DObjects.Clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
9
Plugins/RynthAi/UI/RynthAiUI.Rendering.cs
Normal file
9
Plugins/RynthAi/UI/RynthAiUI.Rendering.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
namespace NexSuite.Plugins.RynthAi
|
||||
{
|
||||
// This file intentionally left blank.
|
||||
// The old "Unified Tabs" UI has been retired in favor of the clean Advanced Settings menu.
|
||||
public partial class RynthAiUI
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
997
Plugins/RynthAi/UI/RynthAiUI.cs
Normal file
997
Plugins/RynthAi/UI/RynthAiUI.cs
Normal file
|
|
@ -0,0 +1,997 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using System.Linq;
|
||||
using ImGuiNET;
|
||||
using Decal.Adapter;
|
||||
using Decal.Adapter.Wrappers;
|
||||
using RynthAi.Meta;
|
||||
|
||||
namespace NexSuite.Plugins.RynthAi
|
||||
{
|
||||
public static class DashWindows
|
||||
{
|
||||
public static bool ShowMacroRules = false;
|
||||
public static bool ShowMonsters = false;
|
||||
public static bool ShowNavigation = false;
|
||||
public static bool ShowWeapons = false;
|
||||
public static bool ShowLua = false;
|
||||
}
|
||||
|
||||
public partial class RynthAiUI : IDisposable
|
||||
{
|
||||
public UISettings Settings { get; set; }
|
||||
public CombatManager CombatManager { get; set; }
|
||||
public CoreManager Core { get; set; }
|
||||
public MetaManager MetaManager { get; set; }
|
||||
|
||||
public Action OnSettingsChanged;
|
||||
public Action OnForceRebuffClicked;
|
||||
public Action OnLootProfileSelected;
|
||||
public Action OnMetaProfileSelected;
|
||||
public Action OnMetaRulesUpdated;
|
||||
|
||||
public LuaUI LuaTab;
|
||||
public MetaUI MetaTab;
|
||||
public MonstersUI MonstersTab;
|
||||
public RouteUI RouteTab;
|
||||
|
||||
private readonly AdvancedSettingsUI _advancedUI;
|
||||
|
||||
public List<string> Profiles = new List<string>();
|
||||
public List<string> NavFiles = new List<string>();
|
||||
public List<string> LootFiles = new List<string>();
|
||||
public List<string> MetaFiles = new List<string>();
|
||||
|
||||
private int _selectedNavIdx = 0;
|
||||
private string _navFolder = @"C:\Games\DecalPlugins\NexSuite\RynthAi\NavProfiles";
|
||||
private string _lootFolder = @"C:\Games\DecalPlugins\NexSuite\RynthAi\LootProfiles";
|
||||
private string _metaFolder = @"C:\Games\DecalPlugins\NexSuite\RynthAi\MetaProfiles";
|
||||
|
||||
private readonly string[] _elements = { "Slash", "Pierce", "Bludgeon", "Fire", "Cold", "Lightning", "Acid", "Nether" };
|
||||
|
||||
// ── Colour palette ───────────────────────────────────────────────────
|
||||
private static readonly Vector4 ColTeal = new Vector4(0.15f, 0.85f, 0.90f, 1.00f);
|
||||
private static readonly Vector4 ColAmber = new Vector4(0.91f, 0.70f, 0.20f, 1.00f);
|
||||
private static readonly Vector4 ColRed = new Vector4(0.85f, 0.25f, 0.25f, 1.00f);
|
||||
private static readonly Vector4 ColGreen = new Vector4(0.25f, 0.85f, 0.45f, 1.00f);
|
||||
private static readonly Vector4 ColTextDim = new Vector4(0.85f, 0.90f, 0.95f, 1.00f);
|
||||
private static readonly Vector4 ColTextMute = new Vector4(0.55f, 0.65f, 0.75f, 1.00f);
|
||||
private static readonly Vector4 ColHp = new Vector4(0.85f, 0.20f, 0.20f, 1.00f);
|
||||
private static readonly Vector4 ColStam = new Vector4(0.20f, 0.80f, 0.35f, 1.00f);
|
||||
private static readonly Vector4 ColMana = new Vector4(0.15f, 0.55f, 0.95f, 1.00f);
|
||||
private static readonly Vector4 ColBarBg = new Vector4(0.08f, 0.12f, 0.16f, 1.00f);
|
||||
private static readonly Vector4 ColPanelBg = new Vector4(0.04f, 0.07f, 0.10f, 0.95f);
|
||||
|
||||
private static readonly Vector4 ColBtnOn = new Vector4(0.15f, 0.30f, 0.35f, 1.00f);
|
||||
private static readonly Vector4 ColBtnFill = new Vector4(0.06f, 0.12f, 0.18f, 1.00f);
|
||||
private static readonly Vector4 ColBtnHov = new Vector4(0.10f, 0.18f, 0.25f, 1.00f);
|
||||
private static readonly Vector4 ColBtnAct = new Vector4(0.08f, 0.15f, 0.22f, 1.00f);
|
||||
private static readonly Vector4 ColBtnBord = new Vector4(0.15f, 0.25f, 0.35f, 1.00f);
|
||||
|
||||
// ── DRAKHUD HEALTH ENGINE ────────────────────────────────────────────
|
||||
private Dictionary<int, float> _healthRatioTracker = new Dictionary<int, float>();
|
||||
private Dictionary<int, int> _maxHealthTracker = new Dictionary<int, int>();
|
||||
private int _lastTargetId = 0;
|
||||
private int _retryTargetId = 0;
|
||||
private int _retryCount = 0;
|
||||
private DateTime _lastRequestTime = DateTime.MinValue;
|
||||
|
||||
// ── UI STATE ─────────────────────────────────────────────────────────
|
||||
private bool _isMinimized = false;
|
||||
private bool _isLocked = false;
|
||||
private float _bgOpacity = 0.95f;
|
||||
private Vector2 _expandedSize = new Vector2(430, 420);
|
||||
private bool _wasMinimized = false;
|
||||
|
||||
public RynthAiUI(UISettings settings, CombatManager combatManager, CoreManager core)
|
||||
{
|
||||
Settings = settings;
|
||||
CombatManager = combatManager;
|
||||
Core = core;
|
||||
|
||||
LuaTab = new LuaUI(settings, core);
|
||||
_advancedUI = new AdvancedSettingsUI(settings) { OnSettingsChanged = () => OnSettingsChanged?.Invoke() };
|
||||
MetaTab = new MetaUI(settings, NavFiles) { OnSettingsChanged = () => OnSettingsChanged?.Invoke(), OnMetaRulesUpdated = () => OnMetaRulesUpdated?.Invoke() };
|
||||
MonstersTab = new MonstersUI(settings, core) { OnSettingsChanged = () => OnSettingsChanged?.Invoke() };
|
||||
RouteTab = new RouteUI(settings, core) { OnSettingsChanged = () => OnSettingsChanged?.Invoke() };
|
||||
|
||||
RefreshProfilesList(); RefreshNavFiles(); RefreshLootFiles(); RefreshMetaFiles();
|
||||
|
||||
try { Core.EchoFilter.ServerDispatch += OnServerDispatch; } catch { }
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
try { Core.EchoFilter.ServerDispatch -= OnServerDispatch; } catch { }
|
||||
}
|
||||
|
||||
public void SetMissileCraftingManager(MissileCraftingManager mgr) => _advancedUI.SetMissileCraftingManager(mgr);
|
||||
|
||||
public void Render()
|
||||
{
|
||||
UpdateTargetAppraisal();
|
||||
|
||||
if (RouteTab != null && RouteTab.NeedsRouteGraphicsRefresh)
|
||||
{ RouteTab.NeedsRouteGraphicsRefresh = false; RouteTab.UpdateRouteGraphics(); }
|
||||
|
||||
RenderDashboard();
|
||||
|
||||
// Render all active popup windows based on the button toggles
|
||||
try { if (Settings.ShowAdvancedWindow) _advancedUI?.Render(); } catch { Settings.ShowAdvancedWindow = false; }
|
||||
try { if (DashWindows.ShowMacroRules) MetaTab?.RenderAsWindow(ref DashWindows.ShowMacroRules); } catch { DashWindows.ShowMacroRules = false; }
|
||||
try { if (DashWindows.ShowMonsters) MonstersTab?.RenderAsWindow(ref DashWindows.ShowMonsters); } catch { DashWindows.ShowMonsters = false; }
|
||||
try { if (DashWindows.ShowWeapons) RenderWeaponsWindow(); } catch { DashWindows.ShowWeapons = false; }
|
||||
try { if (DashWindows.ShowNavigation) RenderNavigationWindow(); } catch { DashWindows.ShowNavigation = false; }
|
||||
try { if (DashWindows.ShowLua) RenderLuaWindow(); } catch { DashWindows.ShowLua = false; }
|
||||
}
|
||||
|
||||
private void RenderDashboard()
|
||||
{
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.WindowPadding, new Vector2(10, 10));
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.WindowRounding, 8.0f);
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.ChildRounding, 6.0f);
|
||||
|
||||
ImGui.PushStyleColor(ImGuiCol.WindowBg, new Vector4(0.04f, 0.06f, 0.08f, _bgOpacity));
|
||||
|
||||
ImGuiWindowFlags flags = ImGuiWindowFlags.NoTitleBar | ImGuiWindowFlags.NoCollapse;
|
||||
|
||||
if (_isMinimized)
|
||||
{
|
||||
flags |= ImGuiWindowFlags.AlwaysAutoResize | ImGuiWindowFlags.NoResize;
|
||||
_wasMinimized = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_isLocked) flags |= ImGuiWindowFlags.NoResize | ImGuiWindowFlags.NoMove;
|
||||
|
||||
if (_wasMinimized)
|
||||
{
|
||||
ImGui.SetNextWindowSize(_expandedSize, ImGuiCond.Always);
|
||||
_wasMinimized = false;
|
||||
}
|
||||
}
|
||||
|
||||
ImGui.SetNextWindowSizeConstraints(new Vector2(400, 0), new Vector2(1200, 2000));
|
||||
|
||||
if (!_wasMinimized && !_isMinimized && !_isLocked)
|
||||
{
|
||||
ImGui.SetNextWindowSize(_expandedSize, ImGuiCond.FirstUseEver);
|
||||
}
|
||||
|
||||
if (ImGui.Begin("RynthAi Dashboard##Main", flags))
|
||||
{
|
||||
if (!_isMinimized && !_isLocked && !_wasMinimized)
|
||||
{
|
||||
_expandedSize = ImGui.GetWindowSize();
|
||||
}
|
||||
|
||||
RenderDashHeader();
|
||||
|
||||
ImGui.PushStyleColor(ImGuiCol.ChildBg, ColPanelBg);
|
||||
ImGui.PushStyleColor(ImGuiCol.Border, ColBtnBord);
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.ChildBorderSize, 1.0f);
|
||||
|
||||
if (ImGui.BeginChild("CombatPanel", new Vector2(-1, 154), true, ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse))
|
||||
{
|
||||
RenderCombatPanel();
|
||||
ImGui.Dummy(new Vector2(0, 4));
|
||||
}
|
||||
ImGui.EndChild();
|
||||
ImGui.PopStyleVar();
|
||||
ImGui.PopStyleColor(2);
|
||||
|
||||
if (!_isMinimized)
|
||||
{
|
||||
ImGui.Spacing(); ImGui.Spacing();
|
||||
RenderLauncherGrid();
|
||||
}
|
||||
}
|
||||
ImGui.End();
|
||||
ImGui.PopStyleColor();
|
||||
ImGui.PopStyleVar(3);
|
||||
}
|
||||
|
||||
private void RenderDashHeader()
|
||||
{
|
||||
float W = ImGui.GetContentRegionAvail().X;
|
||||
float startY = ImGui.GetCursorPosY();
|
||||
|
||||
ImGui.SetWindowFontScale(1.4f);
|
||||
ImGui.TextColored(ColTeal, "N"); ImGui.SameLine(0, 2);
|
||||
ImGui.TextColored(new Vector4(1, 1, 1, 1), "NEXAI DASHBOARD");
|
||||
ImGui.SetWindowFontScale(1.0f);
|
||||
|
||||
ImGui.SameLine();
|
||||
ImGui.SetCursorPosY(startY + 5);
|
||||
ImGui.TextColored(ColTextMute, "v4.0");
|
||||
|
||||
ImGui.SameLine(W - 130);
|
||||
ImGui.SetCursorPosY(startY + 2);
|
||||
|
||||
if (ImGui.SmallButton(_isLocked ? "Unlk" : "Lock")) { _isLocked = !_isLocked; }
|
||||
if (ImGui.IsItemHovered()) ImGui.SetTooltip(_isLocked ? "Unlock Window" : "Lock Window");
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.SmallButton("-")) _bgOpacity = Math.Max(0.1f, _bgOpacity - 0.1f);
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.SmallButton("+")) _bgOpacity = Math.Min(1.0f, _bgOpacity + 0.1f);
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.SmallButton(_isMinimized ? "^" : "_")) { _isMinimized = !_isMinimized; }
|
||||
|
||||
ImGui.SameLine();
|
||||
if (ImGui.SmallButton("X")) { Settings.IsMacroRunning = false; }
|
||||
|
||||
ImGui.Dummy(new Vector2(0, 2));
|
||||
|
||||
if (!_isMinimized)
|
||||
{
|
||||
if (ImGui.BeginTable("HeaderGrid", 2))
|
||||
{
|
||||
ImGui.TableSetupColumn("Left", ImGuiTableColumnFlags.WidthFixed, W * 0.40f);
|
||||
ImGui.TableSetupColumn("Right", ImGuiTableColumnFlags.WidthStretch);
|
||||
|
||||
ImGui.TableNextRow();
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.SetWindowFontScale(1.3f);
|
||||
ImGui.TextColored(ColTextMute, "Macro Status:");
|
||||
ImGui.SetWindowFontScale(1.0f);
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 2);
|
||||
ImGui.TextColored(ColTextMute, "Profile:");
|
||||
ImGui.SameLine(60);
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
if (ImGui.BeginCombo("##ProfCombo", TruncateName(Settings.SelectedProfile, 16)))
|
||||
{
|
||||
foreach (var p in Profiles)
|
||||
{
|
||||
if (ImGui.Selectable(p, p == Settings.SelectedProfile))
|
||||
{
|
||||
Settings.SelectedProfile = p; OnSettingsChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
ImGui.TableNextRow();
|
||||
ImGui.TableNextColumn();
|
||||
var pos = ImGui.GetCursorScreenPos();
|
||||
var dl = ImGui.GetWindowDrawList();
|
||||
uint color = Settings.IsMacroRunning ? ImGui.ColorConvertFloat4ToU32(ColGreen) : ImGui.ColorConvertFloat4ToU32(ColTextMute);
|
||||
|
||||
dl.AddCircleFilled(pos + new Vector2(8, 12), 6, color);
|
||||
if (Settings.IsMacroRunning) dl.AddCircle(pos + new Vector2(8, 12), 9, color, 12, 1.5f);
|
||||
|
||||
ImGui.SetCursorScreenPos(pos + new Vector2(24, 0));
|
||||
if (ImGui.InvisibleButton("ToggleMacro", new Vector2(100, 24)))
|
||||
{
|
||||
Settings.IsMacroRunning = !Settings.IsMacroRunning;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
|
||||
ImGui.SetCursorScreenPos(pos + new Vector2(26, 2));
|
||||
ImGui.SetWindowFontScale(1.3f);
|
||||
ImGui.TextColored(Settings.IsMacroRunning ? ColGreen : ColTextMute, Settings.IsMacroRunning ? "RUNNING" : "STOPPED");
|
||||
ImGui.SetWindowFontScale(1.0f);
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 4);
|
||||
ImGui.TextColored(ColTextMute, "Nav:");
|
||||
ImGui.SameLine(60);
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
string navName = string.IsNullOrEmpty(Settings.CurrentNavPath) ? "None" : Path.GetFileNameWithoutExtension(Settings.CurrentNavPath);
|
||||
if (ImGui.BeginCombo("##NavCombo", TruncateName(navName, 16)))
|
||||
{
|
||||
for (int i = 0; i < NavFiles.Count; i++)
|
||||
{
|
||||
if (ImGui.Selectable(NavFiles[i], _selectedNavIdx == i))
|
||||
{
|
||||
_selectedNavIdx = i; LoadSelectedNav();
|
||||
}
|
||||
}
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
ImGui.TableNextRow();
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 4);
|
||||
ImGui.TextColored(ColTextMute, "State:"); ImGui.SameLine(0, 8);
|
||||
ImGui.TextColored(ColAmber, Settings.CurrentState ?? "Idle");
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 6);
|
||||
ImGui.TextColored(ColTextMute, "Loot:");
|
||||
ImGui.SameLine(60);
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
string lootName = string.IsNullOrEmpty(Settings.CurrentLootPath) ? "None" : Path.GetFileNameWithoutExtension(Settings.CurrentLootPath);
|
||||
if (ImGui.BeginCombo("##LootCombo", TruncateName(lootName, 16)))
|
||||
{
|
||||
for (int i = 0; i < LootFiles.Count; i++)
|
||||
{
|
||||
if (ImGui.Selectable(LootFiles[i], Settings.LootProfileIdx == i))
|
||||
{
|
||||
Settings.LootProfileIdx = i;
|
||||
Settings.CurrentLootPath = (i == 0) ? "" : Path.Combine(_lootFolder, LootFiles[i] + ".utl");
|
||||
OnSettingsChanged?.Invoke(); OnLootProfileSelected?.Invoke();
|
||||
}
|
||||
}
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
ImGui.EndTable();
|
||||
}
|
||||
ImGui.Spacing();
|
||||
}
|
||||
}
|
||||
|
||||
private void RenderCombatPanel()
|
||||
{
|
||||
if (ImGui.BeginTable("CombatInnerTable", 2, ImGuiTableFlags.None))
|
||||
{
|
||||
ImGui.TableSetupColumn("Toggles", ImGuiTableColumnFlags.WidthFixed, 68);
|
||||
ImGui.TableSetupColumn("Vitals", ImGuiTableColumnFlags.WidthStretch);
|
||||
ImGui.TableNextRow();
|
||||
|
||||
// --- COLUMN 1: TOGGLES ---
|
||||
ImGui.TableNextColumn();
|
||||
var tPos = ImGui.GetCursorScreenPos() + new Vector2(2, 28);
|
||||
|
||||
// 2x2 Grid
|
||||
DrawSquareToggle("sword", ref Settings.EnableCombat, tPos, "CombatTgl");
|
||||
DrawSquareToggle("buff", ref Settings.EnableBuffing, tPos + new Vector2(34, 0), "BuffTgl");
|
||||
DrawSquareToggle("shoe", ref Settings.EnableNavigation, tPos + new Vector2(0, 34), "NavTgl");
|
||||
DrawSquareToggle("bag", ref Settings.EnableLooting, tPos + new Vector2(34, 34), "LootTgl");
|
||||
|
||||
// Wide MACRO Button
|
||||
DrawWideToggle("MACRO", "gear", ref Settings.EnableMeta, tPos + new Vector2(0, 68), "MetaTgl", 64f, 20f);
|
||||
|
||||
// --- COLUMN 2: MOB + PLAYER VITALS ---
|
||||
ImGui.TableNextColumn();
|
||||
|
||||
string targetName = "NO TARGET";
|
||||
float targetHpPct = 0f;
|
||||
string mobHpDisplay = "0%";
|
||||
int currentTarget = Core.Actions.CurrentSelection;
|
||||
|
||||
if (currentTarget != 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
var wo = Core.WorldFilter[currentTarget];
|
||||
if (wo != null)
|
||||
{
|
||||
targetName = wo.Name;
|
||||
|
||||
if (_healthRatioTracker.ContainsKey(currentTarget))
|
||||
{
|
||||
targetHpPct = _healthRatioTracker[currentTarget];
|
||||
}
|
||||
else
|
||||
{
|
||||
targetHpPct = (float)wo.Values((DoubleValueKey)0x92, 0.0);
|
||||
}
|
||||
|
||||
if (_maxHealthTracker.ContainsKey(currentTarget) && _maxHealthTracker[currentTarget] > 0)
|
||||
{
|
||||
int maxHp = _maxHealthTracker[currentTarget];
|
||||
int curHp = (int)Math.Round(targetHpPct * maxHp);
|
||||
mobHpDisplay = $"{(int)(targetHpPct * 100)}% ({curHp}/{maxHp})";
|
||||
}
|
||||
else
|
||||
{
|
||||
mobHpDisplay = $"{(int)(targetHpPct * 100)}%";
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
ImGui.SetCursorPosY(ImGui.GetCursorPosY() + 4);
|
||||
ImGui.TextColored(ColTextDim, TruncateName(targetName, 32).ToUpper());
|
||||
|
||||
float textWidth = ImGui.CalcTextSize(mobHpDisplay).X;
|
||||
ImGui.SameLine(ImGui.GetContentRegionAvail().X - textWidth);
|
||||
ImGui.TextColored(new Vector4(1, 1, 1, 1), mobHpDisplay);
|
||||
|
||||
DrawSegmentedBar(targetHpPct, ImGui.GetContentRegionAvail().X - 4);
|
||||
|
||||
ImGui.Spacing();
|
||||
ImGui.TextColored(ColTextMute, "PLAYER VITALS");
|
||||
|
||||
int hp = 0, hpMax = 1, st = 0, stMax = 1, mn = 0, mnMax = 1;
|
||||
try
|
||||
{
|
||||
if (Core?.CharacterFilter != null)
|
||||
{
|
||||
hp = Core.CharacterFilter.Health; hpMax = Math.Max(1, (int)Core.CharacterFilter.EffectiveVital[CharFilterVitalType.Health]);
|
||||
st = Core.CharacterFilter.Stamina; stMax = Math.Max(1, (int)Core.CharacterFilter.EffectiveVital[CharFilterVitalType.Stamina]);
|
||||
mn = Core.CharacterFilter.Mana; mnMax = Math.Max(1, (int)Core.CharacterFilter.EffectiveVital[CharFilterVitalType.Mana]);
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
float hpPct = (float)hp / hpMax; float stPct = (float)st / stMax; float mnPct = (float)mn / mnMax;
|
||||
|
||||
DrawVitalRow("heart", "HP", hpPct, ColHp, $"{hp}/{hpMax}");
|
||||
DrawVitalRow("run", "ST", stPct, ColGreen, $"{st}/{stMax}");
|
||||
DrawVitalRow("drop", "MN", mnPct, ColMana, $"{mn}/{mnMax}");
|
||||
|
||||
ImGui.EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
private void RenderLauncherGrid()
|
||||
{
|
||||
if (ImGui.BeginTable("LauncherGridTable", 3, ImGuiTableFlags.SizingStretchSame))
|
||||
{
|
||||
ImGui.TableNextRow();
|
||||
ImGui.TableNextColumn(); GridBtn("Macro Rules", "gear", ref DashWindows.ShowMacroRules);
|
||||
ImGui.TableNextColumn(); GridBtn("Monsters", "target", ref DashWindows.ShowMonsters);
|
||||
ImGui.TableNextColumn(); GridBtn("Settings", "wrench", ref Settings.ShowAdvancedWindow);
|
||||
|
||||
ImGui.TableNextRow();
|
||||
ImGui.TableNextColumn(); GridBtn("Navigation", "map", ref DashWindows.ShowNavigation);
|
||||
ImGui.TableNextColumn(); GridBtn("Weapons", "shield", ref DashWindows.ShowWeapons);
|
||||
ImGui.TableNextColumn(); GridBtn("Lua Scripts", "code", ref DashWindows.ShowLua);
|
||||
|
||||
ImGui.EndTable();
|
||||
}
|
||||
}
|
||||
|
||||
private void GridBtn(string label, string icon, ref bool flag)
|
||||
{
|
||||
bool wasOn = flag;
|
||||
float bH = 30f;
|
||||
float bW = -1f;
|
||||
|
||||
ImGui.PushStyleColor(ImGuiCol.Button, ColBtnFill);
|
||||
ImGui.PushStyleColor(ImGuiCol.ButtonHovered, ColBtnHov);
|
||||
ImGui.PushStyleColor(ImGuiCol.ButtonActive, ColBtnAct);
|
||||
ImGui.PushStyleColor(ImGuiCol.Border, wasOn ? ColTeal : ColBtnBord);
|
||||
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.FrameBorderSize, 1.0f);
|
||||
ImGui.PushStyleVar(ImGuiStyleVar.FrameRounding, 4f);
|
||||
|
||||
var startPos = ImGui.GetCursorScreenPos();
|
||||
if (ImGui.Button($"##{label}", new Vector2(bW, bH))) flag = !flag;
|
||||
|
||||
ImGui.PopStyleVar(2);
|
||||
ImGui.PopStyleColor(4);
|
||||
|
||||
float actualWidth = ImGui.GetItemRectSize().X;
|
||||
var textSize = ImGui.CalcTextSize(label);
|
||||
|
||||
DrawIcon(icon, startPos + new Vector2(8, 6), wasOn ? ColTeal : ColTextMute, 16f);
|
||||
|
||||
ImGui.SetCursorScreenPos(startPos + new Vector2(30, (bH - textSize.Y) / 2));
|
||||
ImGui.TextColored(wasOn ? ColTeal : ColTextDim, label);
|
||||
|
||||
ImGui.SetCursorScreenPos(startPos + new Vector2(0, bH + 2));
|
||||
ImGui.Dummy(new Vector2(actualWidth, 0));
|
||||
}
|
||||
|
||||
// ═════════════════════════════════════════════════════════════════════
|
||||
// WEAPONS & ITEMS WINDOW
|
||||
// ═════════════════════════════════════════════════════════════════════
|
||||
private void RenderWeaponsWindow()
|
||||
{
|
||||
ImGui.SetNextWindowSize(new Vector2(480, 300), ImGuiCond.FirstUseEver);
|
||||
if (ImGui.Begin("Weapons & Items##RynthAiWeapons", ref DashWindows.ShowWeapons))
|
||||
{
|
||||
ImGui.TextColored(ColAmber, "Weapons / Wands / Shields / Pets");
|
||||
|
||||
if (ImGui.BeginTable("ItemsTable", 3,
|
||||
ImGuiTableFlags.Borders | ImGuiTableFlags.RowBg | ImGuiTableFlags.Resizable))
|
||||
{
|
||||
ImGui.TableSetupColumn("Item Name", ImGuiTableColumnFlags.WidthStretch);
|
||||
ImGui.TableSetupColumn("Element", ImGuiTableColumnFlags.WidthFixed, 100);
|
||||
ImGui.TableSetupColumn("Actions", ImGuiTableColumnFlags.WidthFixed, 60);
|
||||
ImGui.TableHeadersRow();
|
||||
|
||||
for (int i = 0; i < Settings.ItemRules.Count; i++)
|
||||
{
|
||||
var rule = Settings.ItemRules[i];
|
||||
ImGui.TableNextRow();
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
var wo = Core?.WorldFilter[rule.Id];
|
||||
if (wo != null)
|
||||
ImGui.Text(rule.Name);
|
||||
else
|
||||
{
|
||||
ImGui.TextColored(ColRed, rule.Name);
|
||||
ImGui.SameLine();
|
||||
ImGui.TextColored(new Vector4(1f, 0.3f, 0.3f, 0.8f), "(Gone)");
|
||||
if (ImGui.IsItemHovered())
|
||||
ImGui.SetTooltip("Weapon not in inventory!\nBot cannot equip this item.\nRemove and re-add the correct weapon.");
|
||||
}
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
ImGui.SetNextItemWidth(-1);
|
||||
if (ImGui.BeginCombo($"##Elem{i}", rule.Element, ImGuiComboFlags.NoArrowButton))
|
||||
{
|
||||
foreach (var el in _elements)
|
||||
if (ImGui.Selectable(el, rule.Element == el))
|
||||
{ rule.Element = el; OnSettingsChanged?.Invoke(); }
|
||||
ImGui.EndCombo();
|
||||
}
|
||||
|
||||
ImGui.TableNextColumn();
|
||||
if (ImGui.Button($"Del##{i}", new Vector2(-1, 0)))
|
||||
{
|
||||
foreach (var mr in Settings.MonsterRules)
|
||||
{
|
||||
if (mr.WeaponId == rule.Id) mr.WeaponId = 0;
|
||||
if (mr.OffhandId == rule.Id) mr.OffhandId = 0;
|
||||
}
|
||||
Settings.ItemRules.RemoveAt(i);
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
ImGui.EndTable();
|
||||
}
|
||||
|
||||
ImGui.Separator();
|
||||
if (ImGui.Button("Add Selected Item", new Vector2(150, 24)))
|
||||
{
|
||||
int sel = Core.Actions.CurrentSelection;
|
||||
if (sel != 0)
|
||||
{
|
||||
var item = Core.WorldFilter[sel];
|
||||
if (item != null)
|
||||
{
|
||||
if (IsValidEquipment(item))
|
||||
{
|
||||
if (!Settings.ItemRules.Any(x => x.Id == item.Id))
|
||||
{
|
||||
Settings.ItemRules.Add(new ItemRule
|
||||
{
|
||||
Id = item.Id,
|
||||
Name = item.Name,
|
||||
Element = GetElement(item),
|
||||
KeepBuffed = true
|
||||
});
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
else Core.Actions.AddChatText($"[RynthAi] Item ID {item.Id} already in list.", 1);
|
||||
}
|
||||
else Core.Actions.AddChatText("[RynthAi] Selected item must be a weapon, wand, or shield.", 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
ImGui.SameLine();
|
||||
ImGui.TextDisabled("(Select item in-game first)");
|
||||
}
|
||||
ImGui.End();
|
||||
}
|
||||
|
||||
// ═════════════════════════════════════════════════════════════════════
|
||||
// NAVIGATION WINDOW
|
||||
// ═════════════════════════════════════════════════════════════════════
|
||||
private void RenderNavigationWindow()
|
||||
{
|
||||
ImGui.SetNextWindowSize(new Vector2(360, 400), ImGuiCond.FirstUseEver);
|
||||
if (ImGui.Begin("Navigation##RynthAiNav", ref DashWindows.ShowNavigation))
|
||||
RouteTab?.Render();
|
||||
ImGui.End();
|
||||
}
|
||||
|
||||
// ═════════════════════════════════════════════════════════════════════
|
||||
// LUA SCRIPTS WINDOW
|
||||
// ═════════════════════════════════════════════════════════════════════
|
||||
private void RenderLuaWindow()
|
||||
{
|
||||
ImGui.SetNextWindowSize(new Vector2(400, 300), ImGuiCond.FirstUseEver);
|
||||
if (ImGui.Begin("Lua Scripts##RynthAiLua", ref DashWindows.ShowLua))
|
||||
{
|
||||
if (LuaTab != null)
|
||||
{
|
||||
LuaTab.Render();
|
||||
}
|
||||
else
|
||||
{
|
||||
ImGui.TextColored(ColTextDim, "Lua Engine is currently unavailable.");
|
||||
}
|
||||
}
|
||||
ImGui.End();
|
||||
}
|
||||
|
||||
// ── DRAKHUD LOGIC (Embedded) ──────────────────────────────────────────
|
||||
private void UpdateTargetAppraisal()
|
||||
{
|
||||
int currentTarget = Core.Actions.CurrentSelection;
|
||||
bool isMonster = false;
|
||||
|
||||
if (currentTarget != 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
WorldObject wo = Core.WorldFilter[currentTarget];
|
||||
if (wo != null && wo.ObjectClass == ObjectClass.Monster)
|
||||
isMonster = true;
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
if (currentTarget != _lastTargetId)
|
||||
{
|
||||
_lastTargetId = currentTarget;
|
||||
_retryTargetId = currentTarget;
|
||||
_retryCount = 0;
|
||||
if (currentTarget != 0 && isMonster)
|
||||
{
|
||||
try { Core.Actions.RequestId(currentTarget); _lastRequestTime = DateTime.Now; } catch { }
|
||||
}
|
||||
}
|
||||
|
||||
if (currentTarget != 0 && isMonster && currentTarget == _retryTargetId && _retryCount < 3 &&
|
||||
!_maxHealthTracker.ContainsKey(currentTarget) && (DateTime.Now - _lastRequestTime).TotalSeconds >= 0.75)
|
||||
{
|
||||
try { Core.Actions.RequestId(currentTarget); _lastRequestTime = DateTime.Now; _retryCount++; } catch { }
|
||||
}
|
||||
}
|
||||
|
||||
private void OnServerDispatch(object sender, NetworkMessageEventArgs e)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (e.Message.Type == 0xF7B0)
|
||||
{
|
||||
int eventType = (int)e.Message[2];
|
||||
if (eventType == 0x1C0)
|
||||
{
|
||||
int targetId = (int)e.Message[3];
|
||||
object rawHealth = e.Message[4];
|
||||
float ratio = 1.0f;
|
||||
if (rawHealth is float) ratio = (float)rawHealth;
|
||||
else if (rawHealth is double) ratio = (float)(double)rawHealth;
|
||||
else if (rawHealth is Single) ratio = (Single)rawHealth;
|
||||
_healthRatioTracker[targetId] = ratio;
|
||||
}
|
||||
else if (eventType == 0xC9)
|
||||
{
|
||||
TryExtractVitals(e.Message);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private void TryExtractVitals(Decal.Adapter.Message msg)
|
||||
{
|
||||
try
|
||||
{
|
||||
Decal.Adapter.MessageStruct eventStruct = msg.Struct("event");
|
||||
if (eventStruct != null)
|
||||
{
|
||||
int health = 0, healthMax = 0;
|
||||
try { health = eventStruct.Value<int>("health"); } catch { }
|
||||
try { healthMax = eventStruct.Value<int>("healthMax"); } catch { }
|
||||
|
||||
if (healthMax > 0)
|
||||
{
|
||||
int objectId = 0;
|
||||
try { objectId = eventStruct.Value<int>("object"); } catch { }
|
||||
if (objectId == 0) objectId = Core.Actions.CurrentSelection;
|
||||
|
||||
if (objectId != 0)
|
||||
{
|
||||
_maxHealthTracker[objectId] = healthMax;
|
||||
if (healthMax > 0) _healthRatioTracker[objectId] = (float)health / (float)healthMax;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
|
||||
try
|
||||
{
|
||||
int health = 0, healthMax = 0;
|
||||
try { health = msg.Value<int>("health"); } catch { }
|
||||
try { healthMax = msg.Value<int>("healthMax"); } catch { }
|
||||
|
||||
if (healthMax > 0)
|
||||
{
|
||||
int objectId = Core.Actions.CurrentSelection;
|
||||
if (objectId != 0)
|
||||
{
|
||||
_maxHealthTracker[objectId] = healthMax;
|
||||
_healthRatioTracker[objectId] = (float)health / (float)healthMax;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
// ── Drawing Math & Custom Shapes ──────────────────────────────────────
|
||||
private void DrawIcon(string type, Vector2 pos, Vector4 color, float s)
|
||||
{
|
||||
var dl = ImGui.GetWindowDrawList();
|
||||
uint col = ImGui.ColorConvertFloat4ToU32(color);
|
||||
|
||||
switch (type)
|
||||
{
|
||||
case "gear":
|
||||
dl.AddCircle(pos + new Vector2(s / 2, s / 2), s / 3.5f, col, 12, 1.5f);
|
||||
for (int i = 0; i < 8; i++)
|
||||
{
|
||||
float a = i * ((float)Math.PI * 2f / 8f);
|
||||
dl.AddLine(pos + new Vector2(s / 2 + (float)Math.Cos(a) * s / 3, s / 2 + (float)Math.Sin(a) * s / 3),
|
||||
pos + new Vector2(s / 2 + (float)Math.Cos(a) * s / 2, s / 2 + (float)Math.Sin(a) * s / 2), col, 2f);
|
||||
}
|
||||
break;
|
||||
case "target":
|
||||
dl.AddCircle(pos + new Vector2(s / 2, s / 2), s / 2.5f, col, 12, 1.5f);
|
||||
dl.AddLine(pos + new Vector2(s / 2, 0), pos + new Vector2(s / 2, s), col, 1.5f);
|
||||
dl.AddLine(pos + new Vector2(0, s / 2), pos + new Vector2(s, s / 2), col, 1.5f);
|
||||
break;
|
||||
case "wrench":
|
||||
dl.AddCircle(pos + new Vector2(s * 0.3f, s * 0.3f), s * 0.25f, col, 8, 1.5f);
|
||||
dl.AddLine(pos + new Vector2(s * 0.4f, s * 0.4f), pos + new Vector2(s * 0.9f, s * 0.9f), col, 2f);
|
||||
break;
|
||||
case "map":
|
||||
dl.AddRect(pos, pos + new Vector2(s, s), col, 1.5f);
|
||||
dl.AddLine(pos + new Vector2(s / 2, 2), pos + new Vector2(s / 2, s - 2), col, 1.5f);
|
||||
dl.AddLine(pos + new Vector2(2, s / 2), pos + new Vector2(s - 2, s / 2), col, 1.5f);
|
||||
break;
|
||||
case "bag":
|
||||
dl.AddRectFilled(pos + new Vector2(2, s / 3), pos + new Vector2(s - 2, s), col, 2f);
|
||||
dl.AddCircle(pos + new Vector2(s / 2, s / 4), s / 5, col, 8, 1.5f);
|
||||
break;
|
||||
case "shield":
|
||||
dl.AddLine(pos + new Vector2(s * 0.2f, 0), pos + new Vector2(s * 0.8f, 0), col, 1.5f);
|
||||
dl.AddLine(pos + new Vector2(s * 0.8f, 0), pos + new Vector2(s * 0.8f, s * 0.6f), col, 1.5f);
|
||||
dl.AddLine(pos + new Vector2(s * 0.8f, s * 0.6f), pos + new Vector2(s * 0.5f, s), col, 1.5f);
|
||||
dl.AddLine(pos + new Vector2(s * 0.5f, s), pos + new Vector2(s * 0.2f, s * 0.6f), col, 1.5f);
|
||||
dl.AddLine(pos + new Vector2(s * 0.2f, s * 0.6f), pos + new Vector2(s * 0.2f, 0), col, 1.5f);
|
||||
break;
|
||||
case "code":
|
||||
dl.AddLine(pos + new Vector2(s * 0.3f, 2), pos + new Vector2(0, s / 2), col, 1.5f);
|
||||
dl.AddLine(pos + new Vector2(0, s / 2), pos + new Vector2(s * 0.3f, s - 2), col, 1.5f);
|
||||
dl.AddLine(pos + new Vector2(s * 0.7f, 2), pos + new Vector2(s, s / 2), col, 1.5f);
|
||||
dl.AddLine(pos + new Vector2(s, s / 2), pos + new Vector2(s * 0.7f, s - 2), col, 1.5f);
|
||||
break;
|
||||
case "heart":
|
||||
dl.AddCircleFilled(pos + new Vector2(s * 0.3f, s * 0.3f), s * 0.25f, col);
|
||||
dl.AddCircleFilled(pos + new Vector2(s * 0.7f, s * 0.3f), s * 0.25f, col);
|
||||
dl.AddTriangleFilled(pos + new Vector2(s * 0.05f, s * 0.4f), pos + new Vector2(s * 0.95f, s * 0.4f), pos + new Vector2(s * 0.5f, s * 0.9f), col);
|
||||
break;
|
||||
case "run":
|
||||
dl.AddCircle(pos + new Vector2(s * 0.5f, s * 0.2f), s * 0.15f, col, 8, 1.5f);
|
||||
dl.AddLine(pos + new Vector2(s * 0.5f, s * 0.35f), pos + new Vector2(s * 0.5f, s * 0.65f), col, 1.5f);
|
||||
dl.AddLine(pos + new Vector2(s * 0.5f, s * 0.65f), pos + new Vector2(s * 0.2f, s * 0.9f), col, 1.5f);
|
||||
dl.AddLine(pos + new Vector2(s * 0.5f, s * 0.65f), pos + new Vector2(s * 0.8f, s * 0.9f), col, 1.5f);
|
||||
dl.AddLine(pos + new Vector2(s * 0.2f, s * 0.4f), pos + new Vector2(s * 0.8f, s * 0.4f), col, 1.5f);
|
||||
break;
|
||||
case "drop":
|
||||
dl.AddCircleFilled(pos + new Vector2(s * 0.5f, s * 0.7f), s * 0.25f, col);
|
||||
dl.AddTriangleFilled(pos + new Vector2(s * 0.25f, s * 0.65f), pos + new Vector2(s * 0.75f, s * 0.65f), pos + new Vector2(s * 0.5f, s * 0.1f), col);
|
||||
break;
|
||||
case "sword":
|
||||
dl.AddLine(pos + new Vector2(s * 0.3f, s * 0.7f), pos + new Vector2(s * 0.9f, s * 0.1f), col, 2f);
|
||||
dl.AddLine(pos + new Vector2(s * 0.2f, s * 0.6f), pos + new Vector2(s * 0.4f, s * 0.8f), col, 2f);
|
||||
dl.AddLine(pos + new Vector2(s * 0.1f, s * 0.9f), pos + new Vector2(s * 0.3f, s * 0.7f), col, 2f);
|
||||
break;
|
||||
case "shoe":
|
||||
dl.AddLine(pos + new Vector2(s * 0.3f, s * 0.2f), pos + new Vector2(s * 0.3f, s * 0.8f), col, 2f);
|
||||
dl.AddLine(pos + new Vector2(s * 0.3f, s * 0.8f), pos + new Vector2(s * 0.8f, s * 0.8f), col, 2f);
|
||||
dl.AddLine(pos + new Vector2(s * 0.8f, s * 0.8f), pos + new Vector2(s * 0.8f, s * 0.6f), col, 2f);
|
||||
dl.AddLine(pos + new Vector2(s * 0.8f, s * 0.6f), pos + new Vector2(s * 0.5f, s * 0.5f), col, 2f);
|
||||
dl.AddLine(pos + new Vector2(s * 0.5f, s * 0.5f), pos + new Vector2(s * 0.5f, s * 0.2f), col, 2f);
|
||||
dl.AddLine(pos + new Vector2(s * 0.5f, s * 0.2f), pos + new Vector2(s * 0.3f, s * 0.2f), col, 2f);
|
||||
break;
|
||||
case "buff":
|
||||
dl.AddLine(pos + new Vector2(s * 0.5f, s * 0.2f), pos + new Vector2(s * 0.5f, s * 0.8f), col, 2f);
|
||||
dl.AddLine(pos + new Vector2(s * 0.2f, s * 0.5f), pos + new Vector2(s * 0.8f, s * 0.5f), col, 2f);
|
||||
dl.AddLine(pos + new Vector2(s * 0.3f, s * 0.3f), pos + new Vector2(s * 0.5f, s * 0.1f), col, 1.5f);
|
||||
dl.AddLine(pos + new Vector2(s * 0.5f, s * 0.1f), pos + new Vector2(s * 0.7f, s * 0.3f), col, 1.5f);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawSquareToggle(string icon, ref bool state, Vector2 pos, string id)
|
||||
{
|
||||
var dl = ImGui.GetWindowDrawList();
|
||||
float s = 30f;
|
||||
|
||||
Vector4 bgColor = state ? ColBtnOn : ColBarBg;
|
||||
Vector4 iconColor = state ? ColTeal : ColTextMute;
|
||||
|
||||
dl.AddRectFilled(pos, pos + new Vector2(s, s), ImGui.ColorConvertFloat4ToU32(bgColor), 4f);
|
||||
if (state) dl.AddRect(pos, pos + new Vector2(s, s), ImGui.ColorConvertFloat4ToU32(ColTeal), 4f, ImDrawFlags.None, 1f);
|
||||
|
||||
DrawIcon(icon, pos + new Vector2(6, 6), iconColor, 18f);
|
||||
|
||||
ImGui.SetCursorScreenPos(pos);
|
||||
if (ImGui.InvisibleButton($"##{id}", new Vector2(s, s)))
|
||||
{
|
||||
state = !state;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private void DrawWideToggle(string label, string icon, ref bool state, Vector2 pos, string id, float width, float height)
|
||||
{
|
||||
var dl = ImGui.GetWindowDrawList();
|
||||
|
||||
Vector4 bgColor = state ? ColBtnOn : ColBarBg;
|
||||
Vector4 iconColor = state ? ColTeal : ColTextMute;
|
||||
|
||||
dl.AddRectFilled(pos, pos + new Vector2(width, height), ImGui.ColorConvertFloat4ToU32(bgColor), 4f);
|
||||
if (state) dl.AddRect(pos, pos + new Vector2(width, height), ImGui.ColorConvertFloat4ToU32(ColTeal), 4f, ImDrawFlags.None, 1f);
|
||||
|
||||
DrawIcon(icon, pos + new Vector2(4, (height - 12) / 2), iconColor, 12f);
|
||||
|
||||
var textSize = ImGui.CalcTextSize(label);
|
||||
dl.AddText(pos + new Vector2(18, (height - textSize.Y) / 2), ImGui.ColorConvertFloat4ToU32(state ? ColTeal : ColTextDim), label);
|
||||
|
||||
ImGui.SetCursorScreenPos(pos);
|
||||
if (ImGui.InvisibleButton($"##{id}", new Vector2(width, height)))
|
||||
{
|
||||
state = !state;
|
||||
OnSettingsChanged?.Invoke();
|
||||
}
|
||||
}
|
||||
|
||||
private Vector4 GetGradientCol(float t)
|
||||
{
|
||||
if (t < 0.33f) { float f = t / 0.33f; return new Vector4(1f, f, 0f, 1f); }
|
||||
else if (t < 0.66f) { float f = (t - 0.33f) / 0.33f; return new Vector4(1f - f, 1f, 0f, 1f); }
|
||||
else { float f = (t - 0.66f) / 0.34f; return new Vector4(0f, 1f, f, 1f); }
|
||||
}
|
||||
|
||||
private void DrawSegmentedBar(float pct, float width)
|
||||
{
|
||||
var pos = ImGui.GetCursorScreenPos();
|
||||
var dl = ImGui.GetWindowDrawList();
|
||||
float h = 10f; int segments = 15; float gap = 2f;
|
||||
float segW = (width - (segments - 1) * gap) / segments;
|
||||
|
||||
for (int i = 0; i < segments; i++)
|
||||
{
|
||||
float t = (float)i / (segments - 1);
|
||||
Vector4 drawCol = (i / (float)segments <= pct) ? GetGradientCol(t) : ColBarBg;
|
||||
dl.AddRectFilled(pos + new Vector2(i * (segW + gap), 0), pos + new Vector2(i * (segW + gap) + segW, h), ImGui.ColorConvertFloat4ToU32(drawCol), 1f);
|
||||
}
|
||||
ImGui.Dummy(new Vector2(width, h + 2));
|
||||
}
|
||||
|
||||
private void DrawVitalRow(string icon, string label, float pct, Vector4 color, string valText)
|
||||
{
|
||||
float width = ImGui.GetContentRegionAvail().X - 4f;
|
||||
var pos = ImGui.GetCursorScreenPos();
|
||||
var dl = ImGui.GetWindowDrawList();
|
||||
float h = 16f;
|
||||
|
||||
dl.AddRectFilled(pos, pos + new Vector2(width, h), ImGui.ColorConvertFloat4ToU32(ColBarBg), 4f);
|
||||
float safePct = Math.Max(0, Math.Min(1, pct));
|
||||
dl.AddRectFilled(pos, pos + new Vector2(width * safePct, h), ImGui.ColorConvertFloat4ToU32(color), 4f);
|
||||
|
||||
DrawIcon(icon, pos + new Vector2(4, 1), ColTextDim, 14f);
|
||||
string display = $"{label}: {(int)(safePct * 100)}% ({valText})";
|
||||
dl.AddText(pos + new Vector2(24, 0), ImGui.ColorConvertFloat4ToU32(new Vector4(1, 1, 1, 1)), display);
|
||||
|
||||
ImGui.Dummy(new Vector2(width, h));
|
||||
ImGui.Spacing();
|
||||
}
|
||||
|
||||
private static string TruncateName(string s, int max) => s != null && s.Length > max ? s.Substring(0, max - 1) + "..." : (s ?? "");
|
||||
|
||||
// ── Backend Helpers ───────────────────────────────────────
|
||||
public void LoadSelectedNav()
|
||||
{
|
||||
if (_selectedNavIdx < 0 || _selectedNavIdx >= NavFiles.Count) return;
|
||||
string sel = NavFiles[_selectedNavIdx];
|
||||
if (sel == "None") { Settings.CurrentNavPath = ""; Settings.CurrentRoute.Points.Clear(); Settings.ActiveNavIndex = 0; }
|
||||
else
|
||||
{
|
||||
string fp = Path.Combine(_navFolder, sel + ".nav");
|
||||
Settings.CurrentNavPath = fp; Settings.CurrentRoute = VTankNavParser.Load(fp);
|
||||
Settings.ActiveNavIndex = (Settings.CurrentRoute.RouteType == NavRouteType.Once || Settings.CurrentRoute.RouteType == NavRouteType.Follow) ? 0 : FindNearestWaypoint(Settings.CurrentRoute);
|
||||
}
|
||||
if (RouteTab != null) RouteTab.NeedsRouteGraphicsRefresh = true; OnSettingsChanged?.Invoke();
|
||||
}
|
||||
|
||||
private int FindNearestWaypoint(VTankNavParser route)
|
||||
{
|
||||
if (route?.Points == null || route.Points.Count == 0) return 0;
|
||||
try
|
||||
{
|
||||
var me = Core.WorldFilter[Core.CharacterFilter.Id]; if (me == null) return 0;
|
||||
var pos = me.Coordinates(); int best = 0; double bestD = double.MaxValue;
|
||||
for (int i = 0; i < route.Points.Count; i++)
|
||||
{
|
||||
var pt = route.Points[i]; if (pt.Type != NavPointType.Point) continue;
|
||||
double d = Math.Sqrt(Math.Pow(pt.NS - pos.NorthSouth, 2) + Math.Pow(pt.EW - pos.EastWest, 2));
|
||||
if (d < bestD) { bestD = d; best = i; }
|
||||
}
|
||||
return best;
|
||||
}
|
||||
catch { return 0; }
|
||||
}
|
||||
|
||||
private bool IsValidEquipment(WorldObject item)
|
||||
{
|
||||
if (item.ObjectClass == ObjectClass.MeleeWeapon ||
|
||||
item.ObjectClass == ObjectClass.MissileWeapon ||
|
||||
item.ObjectClass == ObjectClass.WandStaffOrb) return true;
|
||||
if (item.ObjectClass == ObjectClass.Armor &&
|
||||
(item.Name.IndexOf("Shield", StringComparison.OrdinalIgnoreCase) >= 0 ||
|
||||
item.Name.IndexOf("Defender", StringComparison.OrdinalIgnoreCase) >= 0)) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private string GetElement(WorldObject item)
|
||||
{
|
||||
switch (item.Values(LongValueKey.DamageType, 0))
|
||||
{
|
||||
case 1: return "Slash";
|
||||
case 2: return "Pierce";
|
||||
case 4: return "Bludgeon";
|
||||
case 8: return "Cold";
|
||||
case 16: return "Fire";
|
||||
case 32: return "Acid";
|
||||
case 64: return "Lightning";
|
||||
default: return "Slash";
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshNavFiles()
|
||||
{
|
||||
NavFiles.Clear(); NavFiles.Add("None"); _selectedNavIdx = 0;
|
||||
if (!Directory.Exists(_navFolder)) return;
|
||||
foreach (var f in Directory.GetFiles(_navFolder, "*.nav"))
|
||||
{
|
||||
NavFiles.Add(Path.GetFileNameWithoutExtension(f));
|
||||
if (f.Equals(Settings.CurrentNavPath, StringComparison.OrdinalIgnoreCase)) _selectedNavIdx = NavFiles.Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshLootFiles()
|
||||
{
|
||||
LootFiles.Clear(); LootFiles.Add("None");
|
||||
if (!Directory.Exists(_lootFolder)) return;
|
||||
foreach (var f in Directory.GetFiles(_lootFolder, "*.utl"))
|
||||
{
|
||||
LootFiles.Add(Path.GetFileNameWithoutExtension(f));
|
||||
if (f.Equals(Settings.CurrentLootPath, StringComparison.OrdinalIgnoreCase)) Settings.LootProfileIdx = LootFiles.Count - 1;
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshMetaFiles()
|
||||
{
|
||||
try
|
||||
{
|
||||
MetaFiles.Clear(); MetaFiles.Add("None");
|
||||
if (!Directory.Exists(_metaFolder)) Directory.CreateDirectory(_metaFolder);
|
||||
foreach (var f in Directory.GetFiles(_metaFolder, "*.met")) MetaFiles.Add(Path.GetFileNameWithoutExtension(f));
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
private void RefreshProfilesList()
|
||||
{
|
||||
try
|
||||
{
|
||||
Profiles.Clear();
|
||||
string srv = Core.CharacterFilter.Server ?? "UnknownServer";
|
||||
string chr = Core.CharacterFilter.Name ?? "UnknownCharacter";
|
||||
string path = Path.Combine(@"C:\Games\DecalPlugins\NexSuite\RynthAi\SettingsProfiles", srv, chr);
|
||||
Directory.CreateDirectory(path);
|
||||
foreach (string f in Directory.GetFiles(path, "*.json"))
|
||||
{
|
||||
string n = Path.GetFileNameWithoutExtension(f);
|
||||
if (n.ToLower() != "settings") Profiles.Add(n);
|
||||
}
|
||||
if (Profiles.Count == 0) Profiles.Add("Default");
|
||||
}
|
||||
catch { Profiles.Add("Default"); }
|
||||
}
|
||||
}
|
||||
}
|
||||
314
Plugins/RynthAi/UI/UISettings.cs
Normal file
314
Plugins/RynthAi/UI/UISettings.cs
Normal file
|
|
@ -0,0 +1,314 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Numerics;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace NexSuite.Plugins.RynthAi
|
||||
{
|
||||
public class UISettings
|
||||
{
|
||||
// Core macro state
|
||||
public bool IsMacroRunning = false;
|
||||
public string CurrentState = "Default";
|
||||
public bool IsRecordingNav = false;
|
||||
|
||||
// Subsystem Toggles
|
||||
public bool EnableBuffing = true;
|
||||
public bool EnableCombat = false;
|
||||
public bool EnableNavigation = false;
|
||||
public bool EnableLooting = false;
|
||||
public bool EnableMeta = false;
|
||||
public bool EnableRaycasting = true;
|
||||
|
||||
// Movement Mode: 0 = Legacy (SetAutorun/SetClientMotion),
|
||||
// 1 = Tier1 (CM_Movement direct calls),
|
||||
// 2 = Tier2 (CPhysicsObj::MoveToPosition — planned),
|
||||
// 3 = Tier3 (MoveToManager queue — planned)
|
||||
public int MovementMode = 0;
|
||||
|
||||
// ── Navigation Steering (all modes) ───────────────────────────────
|
||||
public float NavStopTurnAngle = 20f; // Stop and turn in place when error > X°
|
||||
public float NavResumeTurnAngle = 10f; // Resume running when error < X° (must be < StopTurn)
|
||||
public float NavDeadZone = 4f; // Ignore corrections smaller than X°
|
||||
public float NavSweepMult = 2.5f; // Closest-approach detect radius = ArrivalYards * this
|
||||
|
||||
// ── Tier 2 Tuning ─────────────────────────────────────────────────
|
||||
public float T2Speed = 1.0f; // Movement speed multiplier
|
||||
public float T2DistanceTo = 0.5f; // Stop this far from target (yards)
|
||||
public float T2ReissueMs = 2000f; // Re-issue MoveToPosition if no progress (ms)
|
||||
public float T2MaxRangeYd = 500f; // Clamp waypoint distance to this (yards)
|
||||
public int T2MaxLandblocks = 3; // Skip if target is more than N landblocks away
|
||||
public float T2WalkWithinYd = 5f; // Walk (not run) when within X yards of waypoint
|
||||
|
||||
// Persistence
|
||||
public string CurrentNavPath = "";
|
||||
public string CurrentLootPath = "";
|
||||
public string CurrentMetaPath = "";
|
||||
|
||||
|
||||
// Profile Selection Indices
|
||||
public int MacroSettingsIdx = 1;
|
||||
public int NavProfileIdx = 1;
|
||||
public int LootProfileIdx = 0;
|
||||
public int MetaProfileIdx = 1;
|
||||
|
||||
// Automation Toggles
|
||||
public bool EnableAutostack = true;
|
||||
public bool EnableAutocram = true;
|
||||
public bool EnableCombineSalvage = true; // If true, combine salvage bags of same material
|
||||
|
||||
// --- Missile Crafting ---
|
||||
public bool EnableMissileCrafting = false; // Master toggle for auto-crafting ammo from bundles
|
||||
public int MissileCraftAmmoThreshold = 1000; // Craft when ammo count drops below this
|
||||
|
||||
// --- Loot Timing (ms) — tunable in Advanced Settings → Looting ---
|
||||
public int LootInterItemDelayMs = 100; // Delay between picking up items
|
||||
public int LootContentSettleMs = 100; // Wait for corpse contents to populate
|
||||
public int LootEmptyCorpseMs = 400; // Wait before declaring corpse empty
|
||||
public int LootClosingDelayMs = 200; // Delay before closing corpse
|
||||
public int LootAssessWindowMs = 800; // Max time to wait for item ID data
|
||||
public int LootRetryTimeoutMs = 800; // Retry pickup after this long
|
||||
public int LootOpenRetryMs = 3000; // Retry opening corpse if no response
|
||||
|
||||
// --- Salvage Timing (ms) — first item / subsequent item ---
|
||||
public int SalvageOpenDelayFirstMs = 400; // Panel open delay (first item)
|
||||
public int SalvageOpenDelayFastMs = 50; // Panel open delay (subsequent)
|
||||
public int SalvageAddDelayFirstMs = 600; // Add item delay (first)
|
||||
public int SalvageAddDelayFastMs = 50; // Add item delay (subsequent)
|
||||
public int SalvageSalvageDelayMs = 50; // Click salvage button delay
|
||||
public int SalvageResultDelayFirstMs = 1000; // Wait for result (first)
|
||||
public int SalvageResultDelayFastMs = 250; // Wait for result (subsequent)
|
||||
public bool UseDispelItems = false;
|
||||
public bool CastDispelSelf = false;
|
||||
public bool AutoFellowMgmt = false;
|
||||
public bool MChargesWhenOff = false;
|
||||
|
||||
// Vitals (0-100)
|
||||
public int HealAt = 60;
|
||||
public int RestamAt = 30;
|
||||
public int GetManaAt = 40;
|
||||
public int TopOffHP = 95;
|
||||
public int TopOffStam = 95;
|
||||
public int TopOffMana = 95;
|
||||
public int HealOthersAt = 50;
|
||||
public int RestamOthersAt = 10;
|
||||
public int InfuseOthersAt = 10;
|
||||
|
||||
// Ranges & Misc
|
||||
public int MonsterRange = 50;
|
||||
public int RingRange = 5;
|
||||
public int ApproachRange = 4;
|
||||
public int MinRingTargets = 4; // Minimum monsters in ring range to use ring spells
|
||||
public float FollowNavMin = 1.5f;
|
||||
public double MaxMonRange = 12.0;
|
||||
public bool SummonPets = false;
|
||||
public int CustomPetRange = 5;
|
||||
public int PetMinMonsters = 1;
|
||||
public bool AdvancedOptions = false;
|
||||
public bool MineOnly = true;
|
||||
public bool ShowEditor = false;
|
||||
public double CorpseApproachRangeMax = 0.04166667; // ~10 yards (10 / 240)
|
||||
public double CorpseApproachRangeMin = 0.00833333; // ~2 yards (2 / 240)
|
||||
|
||||
// Advanced Toggles
|
||||
public bool BoostNavPriority = false;
|
||||
public bool BoostLootPriority = false;
|
||||
// Loot Ownership: 0=MyKillsOnly (default), 1=FellowshipKills, 2=AllCorpses
|
||||
public int LootOwnership = 0;
|
||||
public bool LootOnlyRareCorpses = false;
|
||||
public bool PeaceModeWhenIdle = true;
|
||||
public bool RebuffWhenIdle = false;
|
||||
|
||||
// Blacklist Settings (Combat)
|
||||
public int BlacklistAttempts = 3; // How many failed attacks before blacklisting
|
||||
public int BlacklistTimeoutSec = 30; // How long a mob stays blacklisted (seconds)
|
||||
|
||||
// Attack Power (0-100 percent, or -1 for auto)
|
||||
// Auto: 100% power, or 80% if UseRecklessness is enabled and Recklessness is trained
|
||||
public int MeleeAttackPower = -1; // -1 = auto, 0-100 = manual percent
|
||||
public int MissileAttackPower = -1; // -1 = auto, 0-100 = manual percent
|
||||
public bool UseRecklessness = false; // When true + Recklessness trained, auto power = 80%
|
||||
|
||||
// Attack Height: 0=Low (Delete), 1=Medium (End), 2=High (Page Down)
|
||||
public int MeleeAttackHeight = 1; // Default: Medium
|
||||
public int MissileAttackHeight = 1; // Default: Medium
|
||||
|
||||
//FPS Limits
|
||||
public bool EnableFPSLimit = true;
|
||||
public int TargetFPSFocused = 60;
|
||||
public int TargetFPSBackground = 30;
|
||||
|
||||
// Data Lists
|
||||
public List<MonsterRule> MonsterRules = new List<MonsterRule>();
|
||||
public List<ItemRule> ItemRules = new List<ItemRule>();
|
||||
public List<BuffRule> BuffRules = new List<BuffRule>();
|
||||
public List<MetaRule> MetaRules = new List<MetaRule>(); // <--- NEW META LIST
|
||||
public string LuaScript = "-- Enter your Lua script here\nprint('RynthAi Lua Loaded')";
|
||||
public string LuaConsoleOutput = "--- RynthAi Lua Console ---";
|
||||
|
||||
public string SelectedProfile = "Default";
|
||||
public VTankNavParser CurrentRoute = new VTankNavParser(); // Uncomment if you still use this
|
||||
public int ActiveNavIndex = 0;
|
||||
|
||||
// Advanced Settings Popup
|
||||
// Inside UISettings.cs
|
||||
public bool ShowAdvancedWindow = false; // Toggle this with your button
|
||||
public int SelectedAdvancedTab = 0; // Tracks the left-hand selection
|
||||
|
||||
// Define your tabs in an array for easy rendering
|
||||
[JsonIgnore]
|
||||
public readonly string[] AdvancedTabs = {
|
||||
"Misc", "Recharge", "Melee Combat", "Spell Combat",
|
||||
"Ranges", "Navigation", "Buffing", "Crafting", "Looting"
|
||||
};
|
||||
|
||||
//Refresh state when selected
|
||||
[JsonIgnore]
|
||||
public bool ForceStateReset { get; set; } = false;
|
||||
|
||||
public UISettings()
|
||||
{
|
||||
// REMOVED EnsureDefaultRule() from here to stop JSON deserialization from duplicating it.
|
||||
}
|
||||
|
||||
public void EnsureDefaultRule()
|
||||
{
|
||||
// Find any existing Default rules
|
||||
var existingDefaults = MonsterRules.Where(m => m.Name.Equals("Default", StringComparison.OrdinalIgnoreCase)).ToList();
|
||||
MonsterRule trueDefault;
|
||||
|
||||
if (existingDefaults.Count > 0)
|
||||
{
|
||||
// Keep the first one (it contains your saved weapon settings)
|
||||
trueDefault = existingDefaults.First();
|
||||
// Erase all of them from the list to clean up any duplicates
|
||||
MonsterRules.RemoveAll(m => m.Name.Equals("Default", StringComparison.OrdinalIgnoreCase));
|
||||
}
|
||||
else
|
||||
{
|
||||
// If it truly doesn't exist, make a brand new one
|
||||
trueDefault = new MonsterRule { Name = "Default", Priority = 1, DamageType = "Auto", WeaponId = 0 };
|
||||
}
|
||||
|
||||
// Insert the one true Default safely at the very top
|
||||
MonsterRules.Insert(0, trueDefault);
|
||||
}
|
||||
}
|
||||
|
||||
public class MonsterRule
|
||||
{
|
||||
public string Name { get; set; } = "New Monster";
|
||||
public int Priority { get; set; } = 1;
|
||||
public string DamageType { get; set; } = "Auto";
|
||||
public int WeaponId { get; set; } = 0;
|
||||
|
||||
// Debuff Lights (cast on target before attacking)
|
||||
public bool Fester { get; set; } = false; // F - Festering Curse
|
||||
public bool Broadside { get; set; } = false; // B - Broadside of a Barn
|
||||
public bool GravityWell { get; set; } = false; // G - Gravity Well
|
||||
public bool Imperil { get; set; } = false; // I - Imperil
|
||||
public bool Yield { get; set; } = false; // Y - Yield
|
||||
public bool Vuln { get; set; } = false; // V - Vulnerability (element-matched)
|
||||
|
||||
// Spell Type Lights (how to attack)
|
||||
public bool UseArc { get; set; } = false; // A - Arc spells (war/void)
|
||||
public bool UseRing { get; set; } = false; // R - Ring spells (uses RingRange)
|
||||
public bool UseStreak { get; set; } = false; // S - Streak spells (war/void)
|
||||
public bool UseBolt { get; set; } = true; // B - Bolt spells (default on)
|
||||
// If none of A/R/S/B are set in magic mode = don't attack (buff bot)
|
||||
|
||||
// Extra Vulnerability element (cast in addition to the V light)
|
||||
public string ExVuln { get; set; } = "None";
|
||||
// Offhand weapon/shield ID (from ItemRules, for dual wield or shield)
|
||||
public int OffhandId { get; set; } = 0;
|
||||
// Pet damage element
|
||||
public string PetDamage { get; set; } = "PAuto";
|
||||
}
|
||||
|
||||
public class BuffRule { public string SpellName { get; set; } public int SpellId { get; set; } public bool Enabled { get; set; } = true; }
|
||||
|
||||
public class ItemRule
|
||||
{
|
||||
public int Id { get; set; }
|
||||
public string Name { get; set; }
|
||||
public string Action { get; set; } = "Loot";
|
||||
public string Element { get; set; } = "Slash";
|
||||
public bool KeepBuffed { get; set; } = true;
|
||||
}
|
||||
|
||||
// ====================================================================
|
||||
// NEW META SYSTEM MODELS
|
||||
// ====================================================================
|
||||
public enum MetaConditionType
|
||||
{
|
||||
Never,
|
||||
Always,
|
||||
All,
|
||||
Any,
|
||||
ChatMessage,
|
||||
PackSlots_LE,
|
||||
SecondsInState_GE,
|
||||
CharacterDeath,
|
||||
AnyVendorOpen,
|
||||
VendorClosed,
|
||||
InventoryItemCount_LE,
|
||||
InventoryItemCount_GE,
|
||||
MonsterNameCountWithinDistance,
|
||||
MonsterPriorityCountWithinDistance,
|
||||
NeedToBuff,
|
||||
NoMonstersWithinDistance,
|
||||
Landblock_EQ,
|
||||
Landcell_EQ,
|
||||
PortalspaceEntered,
|
||||
PortalspaceExited,
|
||||
Not,
|
||||
SecondsInStateP_GE,
|
||||
TimeLeftOnSpell_GE,
|
||||
TimeLeftOnSpell_LE,
|
||||
BurdenPercentage_GE,
|
||||
DistAnyRoutePT_GE,
|
||||
Expression,
|
||||
ChatMessageCapture,
|
||||
NavrouteEmpty,
|
||||
MainHealthLE,
|
||||
MainHealthPHE,
|
||||
MainManaLE,
|
||||
MainManaPHE,
|
||||
MainStamLE
|
||||
}
|
||||
|
||||
public enum MetaActionType
|
||||
{
|
||||
None,
|
||||
ChatCommand,
|
||||
SetMetaState,
|
||||
EmbeddedNavRoute,
|
||||
All,
|
||||
CallMetaState, // New
|
||||
ReturnFromCall, // New
|
||||
ExpressionAction, // New
|
||||
ChatExpression, // New
|
||||
SetWatchdog, // New
|
||||
ClearWatchdog, // New
|
||||
GetNTOption, // New
|
||||
SetNTOption, // New
|
||||
CreateView, // New
|
||||
DestroyView, // New
|
||||
DestroyAllViews // New
|
||||
}
|
||||
|
||||
public class MetaRule
|
||||
{
|
||||
public string State { get; set; } = "Default";
|
||||
public MetaConditionType Condition { get; set; }
|
||||
public string ConditionData { get; set; } = "";
|
||||
public MetaActionType Action { get; set; }
|
||||
public string ActionData { get; set; } = "";
|
||||
public List<MetaRule> Children { get; set; } = new List<MetaRule>();
|
||||
|
||||
// NEW: Temporary flag for the UI. JsonIgnore prevents it from saving to the file.
|
||||
[JsonIgnore]
|
||||
public bool HasFired { get; set; } = false;
|
||||
}
|
||||
}
|
||||
Loading…
Reference in a new issue