public EnmityMemory54(TinyIoCContainer container)
 {
     this.memory = new FFXIVMemory(container);
     this.memory.OnProcessChange += ResetPointers;
     this.logger = container.Resolve <ILogger>();
     GetPointerAddress();
 }
Example #2
0
        // 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, uint mycharID, bool isPlayer, bool exceptEffects = false)
        {
            fixed(byte *p = source)
            {
                CombatantMemory mem = *(CombatantMemory *)&p[0];

                if (isPlayer)
                {
                    mycharID = mem.ID;
                }

                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,
                    MonsterType = (MonsterType)mem.MonsterType,
                    Status      = (ObjectStatus)mem.Status,
                    ModelStatus = (ModelStatus)mem.ModelStatus,
                    // Normalize all possible aggression statuses into the basic 4 ones.
                    AggressionStatus     = (AggressionStatus)(mem.AggressionStatus - (mem.AggressionStatus / 4) * 4),
                    RawEffectiveDistance = mem.EffectiveDistance,
                    PosX      = mem.PosX,
                    PosY      = mem.PosY,
                    PosZ      = mem.PosZ,
                    Rotation  = mem.Rotation,
                    Radius    = mem.Radius,
                    TargetID  = mem.TargetID,
                    CurrentHP = mem.CurrentHP,
                    MaxHP     = mem.MaxHP,
                    Effects   = exceptEffects ? new List <EffectEntry>() : GetEffectEntries(mem.Effects, (ObjectType)mem.Type, mycharID),
                };

                combatant.IsTargetable =
                    (combatant.ModelStatus == ModelStatus.Visible) &&
                    ((combatant.Status == ObjectStatus.NormalActorStatus) || (combatant.Status == ObjectStatus.NormalSubActorStatus));
                if (combatant.Type != ObjectType.PC && combatant.Type != ObjectType.Monster)
                {
                    // Other types have garbage memory for hp.
                    combatant.CurrentHP = 0;
                    combatant.MaxHP     = 0;
                }
                return(combatant);
            }
        }
        // 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, uint mycharID, bool isPlayer, bool exceptEffects = false)
        {
            fixed(byte *p = source)
            {
                CombatantMemory mem = *(CombatantMemory *)&p[0];

                if (isPlayer)
                {
                    mycharID = mem.ID;
                }

                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,
                    RawEffectiveDistance = mem.EffectiveDistance,
                    PosX      = mem.PosX,
                    PosY      = mem.PosY,
                    PosZ      = mem.PosZ,
                    Rotation  = mem.Rotation,
                    TargetID  = mem.TargetID,
                    CurrentHP = mem.CurrentHP,
                    MaxHP     = mem.MaxHP,
                    Effects   = exceptEffects ? new List <EffectEntry>() : GetEffectEntries(mem.Effects, (ObjectType)mem.Type, mycharID),
                };

                if (combatant.Type != ObjectType.PC && combatant.Type != ObjectType.Monster)
                {
                    // Other types have garbage memory for hp.
                    combatant.CurrentHP = 0;
                    combatant.MaxHP     = 0;
                }
                return(combatant);
            }
        }