// Will return any kind of combatant, even if not a mob. // This function always returns a combatant object, even if empty. public unsafe Combatant GetCombatantFromByteArray(byte[] source, bool exceptEffects = false) { fixed(byte *p = source) { CombatantMemory mem = *(CombatantMemory *)&p[0]; Combatant combatant = new Combatant() { Name = FFXIVMemory.GetStringFromBytes(mem.Name, CombatantMemory.nameBytes), Job = mem.Job, ID = mem.ID, OwnerID = mem.OwnerID == emptyID ? 0 : mem.OwnerID, Type = (ObjectType)mem.Type, PosX = mem.PosX, PosY = mem.PosY, PosZ = mem.PosZ, TargetID = mem.TargetID, CurrentHP = mem.CurrentHP, MaxHP = mem.MaxHP, Effects = exceptEffects ? new List <EffectEntry>() : GetEffectEntries(mem.Effects, (ObjectType)mem.Type), }; if (combatant.Type != ObjectType.PC && combatant.Type != ObjectType.Monster) { // Other types have garbage memory for hp. combatant.CurrentHP = 0; combatant.MaxHP = 0; } return(combatant); } }
public EnmityMemory(ILogger logger) { this.memory = new FFXIVMemory(logger); this.memory.OnProcessChange += ResetPointers; this.logger = logger; GetPointerAddress(); }