// Converts an EnmityList into a List<EnmityEntry>. public override List <EnmityEntry> GetEnmityEntryList(List <Combatant> combatantList) { uint topEnmity = 0; Combatant mychar = GetSelfCombatant(); var result = new List <EnmityEntry>(); EnmityList list = ReadEnmityList(enmityAddress); for (int i = 0; i < list.numEntries; i++) { EnmityListEntry e = list.GetEntry(i); topEnmity = Math.Max(topEnmity, e.Enmity); Combatant c = null; if (e.ID > 0) { c = combatantList.Find(x => x.ID == e.ID); } var entry = new EnmityEntry() { ID = e.ID, Enmity = e.Enmity, isMe = e.ID == mychar.ID, Name = c == null ? "Unknown" : c.Name, OwnerID = c == null ? 0 : c.OwnerID, HateRate = (int)(((double)e.Enmity / (double)topEnmity) * 100), Job = c == null ? (byte)0 : c.Job, }; result.Add(entry); } return(result); }
// Converts an EnmityList into a List<AggroEntry>. public unsafe List <AggroEntry> GetAggroList(List <Combatant> combatantList) { Combatant mychar = GetSelfCombatant(); uint currentTargetID = 0; var targetCombatant = GetTargetCombatant(); if (targetCombatant != null) { currentTargetID = targetCombatant.ID; } var result = new List <AggroEntry>(); EnmityList list = ReadEnmityList(aggroAddress); for (int i = 0; i < list.numEntries; i++) { EnmityListEntry e = list.GetEntry(i); if (e.ID <= 0) { continue; } Combatant c = combatantList.Find(x => x.ID == e.ID); if (c == null) { continue; } var entry = new AggroEntry() { ID = e.ID, // Rather than storing enmity, this is hate rate for the aggro list. // This is likely because we're reading the memory for the aggro sidebar. HateRate = (int)e.Enmity, isCurrentTarget = (e.ID == currentTargetID), Name = c.Name, MaxHP = c.MaxHP, CurrentHP = c.CurrentHP, Effects = c.Effects, }; // TODO: it seems like when your chocobo has aggro, this entry // is you, and not your chocobo. It's not clear if there's // anything that can be done about it. if (c.TargetID > 0) { Combatant t = combatantList.Find(x => x.ID == c.TargetID); if (t != null) { entry.Target = new EnmityEntry() { ID = t.ID, Name = t.Name, OwnerID = t.OwnerID, isMe = mychar.ID == t.ID ? true : false, Enmity = 0, HateRate = 0, Job = t.Job, }; } } result.Add(entry); } return(result); }