Update select target to nearest everytimes

This commit is contained in:
HungDK
2026-04-09 10:53:36 +07:00
parent 503fc49681
commit fc38b2199d
+14
View File
@@ -63,6 +63,7 @@ namespace BrewMonster
private CECPetCorral m_pPetCorral;
private List<CECObject> m_aTabSels = new List<CECObject>();
private int m_lastAutoSelectNearestId = 0;
private List<CECSkill> m_aPtSkills = new List<CECSkill>();
private List<CECSkill> m_aPsSkills = new List<CECSkill>();
private List<CECSkill> m_aEquipSkills = new List<CECSkill>();
@@ -2812,10 +2813,22 @@ namespace BrewMonster
int idNewSel = 0;
if (sorted.Count == 0)
{
m_lastAutoSelectNearestId = 0;
idNewSel = idCurSel;
}
else
{
int nearestId = sorted[0].id;
if (nearestId != 0 && nearestId != m_lastAutoSelectNearestId)
{
// If the nearest target changed (movement/spawn/despawn), reset cycle back to nearest
m_lastAutoSelectNearestId = nearestId;
idNewSel = nearestId;
}
else
{
m_lastAutoSelectNearestId = nearestId;
int idx = -1;
for (int i = 0; i < sorted.Count; i++)
{
@@ -2827,6 +2840,7 @@ namespace BrewMonster
}
int nextIdx = idx < 0 ? 0 : (idx + 1) % sorted.Count;
idNewSel = sorted[nextIdx].id;
}
}
// Select the target if found / 如果找到目标则选择它