Exemplo n.º 1
0
        public unsafe void Init()
        {
            var scanner = _plugin.pluginInterface.TargetModuleScanner;

            // actually a pointer to the game's memory storage for all battlecharas. the player character is always the first.
            // this SHOULD persist on swapping characters but i didnt actually test
            var localPlayerAddress = scanner.GetStaticAddressFromSig("48 8B F8 48 8D 2D ? ? ? ? ");

            LocalPlayer = *(BattleChara **)localPlayerAddress.ToPointer();

            var characterEnableDrawAddress  = scanner.ScanText("E8 ?? ?? ?? ?? 48 8B 8B ?? ?? ?? ?? 48 85 C9 74 2C 33 D2");
            var characterDisableDrawAddress = scanner.ScanText("40 57 41 56 48 83 EC 28 48 8B F9 48 8B 0D ?? ?? ?? ??");
            var companionEnableDrawAddress  = scanner.ScanText("40 53 48 83 EC 20 80 B9 ?? ?? ?? ?? ?? 48 8B D9 72 0C F7 81 ?? ?? ?? ?? ?? ?? ?? ?? 74 3D");
            var characterDtorAddress        = scanner.ScanText("48 89 5C 24 ?? 57 48 83 EC 20 48 8D 05 ?? ?? ?? ?? 48 8B D9 48 89 01 48 8D 05 ?? ?? ?? ?? 48 89 81 ?? ?? ?? ?? 48 8B 89 ?? ?? ?? ??");

            this.hookCharacterEnableDraw  = new Hook <CharacterEnableDrawPrototype>(characterEnableDrawAddress, new CharacterEnableDrawPrototype(CharacterEnableDrawDetour), this);
            this.hookCharacterDisableDraw = new Hook <CharacterDisableDrawPrototype>(characterDisableDrawAddress, new CharacterDisableDrawPrototype(CharacterDisableDrawDetour), this);
            this.hookCompanionEnableDraw  = new Hook <CompanionEnableDrawPrototype>(companionEnableDrawAddress, new CompanionEnableDrawPrototype(CompanionEnableDrawDetour), this);
            this.hookCharacterDtor        = new Hook <CharacterDtorPrototype>(characterDtorAddress, new CharacterDtorPrototype(CharacterDtorDetour), this);

            this.hookCharacterEnableDraw.Enable();
            this.hookCharacterDisableDraw.Enable();
            this.hookCompanionEnableDraw.Enable();
            this.hookCharacterDtor.Enable();
        }
        public unsafe void Init(DalamudPluginInterface pluginInterface, VisibilityConfiguration pluginConfig)
        {
            _pluginInterface = pluginInterface;
            _address.Setup(pluginInterface.TargetModuleScanner);
            _config = pluginConfig;

            LocalPlayer = *(BattleChara **)_address.LocalPlayerAddress.ToPointer();

            hookCharacterEnableDraw  = new Hook <CharacterEnableDrawPrototype>(_address.CharacterEnableDrawAddress, new CharacterEnableDrawPrototype(CharacterEnableDrawDetour), this);
            hookCharacterDisableDraw = new Hook <CharacterDisableDrawPrototype>(_address.CharacterDisableDrawAddress, new CharacterDisableDrawPrototype(CharacterDisableDrawDetour), this);
            hookCompanionEnableDraw  = new Hook <CompanionEnableDrawPrototype>(_address.CompanionEnableDrawAddress, new CompanionEnableDrawPrototype(CompanionEnableDrawDetour), this);
            hookCharacterDtor        = new Hook <CharacterDtorPrototype>(_address.CharacterDtorAddress, new CharacterDtorPrototype(CharacterDtorDetour), this);

            hookCharacterEnableDraw.Enable();
            hookCharacterDisableDraw.Enable();
            hookCompanionEnableDraw.Enable();
            hookCharacterDtor.Enable();
        }
        private unsafe void CharacterEnableDrawDetour(Character *thisPtr)
        {
            var localPlayerAddress = _pluginInterface?.ClientState?.LocalPlayer?.Address;

            if (localPlayerAddress.HasValue && LocalPlayer != (BattleChara *)localPlayerAddress.Value)
            {
                LocalPlayer = (BattleChara *)localPlayerAddress.Value;
            }

            if (_config.Enabled && localPlayerAddress.HasValue && thisPtr != (Character *)LocalPlayer)
            {
                switch (thisPtr->GameObject.ObjectKind)
                {
                case (byte)ObjectKind.Player:
                    if (thisPtr->GameObject.ObjectID == 0xE0000000)
                    {
                        break;
                    }

                    _players[ContainerType.All].Add(thisPtr->GameObject.ObjectID);

                    if ((thisPtr->StatusFlags & (byte)StatusFlags.Friend) > 0)
                    {
                        _players[ContainerType.Friend].Add(thisPtr->GameObject.ObjectID);
                    }
                    else
                    {
                        _players[ContainerType.Friend].Remove(thisPtr->GameObject.ObjectID);
                    }

                    if ((thisPtr->StatusFlags & (byte)StatusFlags.PartyMember) > 0)
                    {
                        _players[ContainerType.Party].Add(thisPtr->GameObject.ObjectID);
                    }
                    else
                    {
                        _players[ContainerType.Party].Remove(thisPtr->GameObject.ObjectID);
                    }

                    if ((_pluginInterface.ClientState.Condition[ConditionFlag.BoundByDuty] ||
                         _pluginInterface.ClientState.Condition[ConditionFlag.BetweenAreas] ||
                         _pluginInterface.ClientState.Condition[ConditionFlag.WatchingCutscene]) &&
                        !(_config.TerritoryTypeWhitelist.Contains(_pluginInterface.ClientState.TerritoryType) && _config.TerryWhiteList))
                    {
                        break;
                    }

                    if (*LocalPlayer->Character.CompanyTag != 0 &&
                        LocalPlayer->Character.CurrentWorld == LocalPlayer->Character.HomeWorld &&
                        UnsafeArrayEqual(thisPtr->CompanyTag, LocalPlayer->Character.CompanyTag, 7))
                    {
                        _players[ContainerType.Company].Add(thisPtr->GameObject.ObjectID);
                    }
                    else
                    {
                        _players[ContainerType.Company].Remove(thisPtr->GameObject.ObjectID);
                    }


                    if (_config.VoidList.Any(x => UnsafeArrayEqual(Encoding.UTF8.GetBytes(x.Name),
                                                                   thisPtr->GameObject.Name) &&
                                             x.HomeworldId == thisPtr->HomeWorld))
                    {
                        thisPtr->GameObject.RenderFlags |= (int)VisibilityFlags.Invisible;
                        HiddenObjectIds.Add(thisPtr->GameObject.ObjectID);
                        break;
                    }

                    if (!_config.HidePlayer ||
                        (_config.ShowDeadPlayer && thisPtr->CurrentHp == 0) ||
                        (_config.ShowFriendPlayer && _players[ContainerType.Friend].Contains(thisPtr->GameObject.ObjectID)) ||
                        (_config.ShowCompanyPlayer && _players[ContainerType.Company].Contains(thisPtr->GameObject.ObjectID)) ||
                        (_config.ShowPartyPlayer && _players[ContainerType.Party].Contains(thisPtr->GameObject.ObjectID)) ||
                        (_config.Whitelist.Any(x => UnsafeArrayEqual(Encoding.UTF8.GetBytes(x.Name),
                                                                     thisPtr->GameObject.Name) &&
                                               x.HomeworldId == thisPtr->HomeWorld)))
                    {
                        break;
                    }
                    else
                    {
                        thisPtr->GameObject.RenderFlags |= (int)VisibilityFlags.Invisible;
                        HiddenObjectIds.Add(thisPtr->GameObject.ObjectID);
                        break;
                    }

                case (byte)ObjectKind.BattleNpc when thisPtr->GameObject.SubKind == (byte)BattleNpcSubKind.Pet && thisPtr->NameID != 6565:
                    if (!_config.HidePet ||
                        thisPtr->GameObject.OwnerID == LocalPlayer->Character.GameObject.ObjectID)
                    {
                        break;
                    }

                    _pets[ContainerType.All].Add(thisPtr->GameObject.ObjectID);

                    if (_players[ContainerType.Friend].Contains(thisPtr->GameObject.OwnerID))
                    {
                        _pets[ContainerType.Friend].Add(thisPtr->GameObject.ObjectID);
                    }

                    if (_players[ContainerType.Party].Contains(thisPtr->GameObject.OwnerID))
                    {
                        _pets[ContainerType.Party].Add(thisPtr->GameObject.ObjectID);
                    }

                    if (_players[ContainerType.Company].Contains(thisPtr->GameObject.OwnerID))
                    {
                        _pets[ContainerType.Company].Add(thisPtr->GameObject.ObjectID);
                    }

                    if ((_config.ShowFriendPet && _players[ContainerType.Friend].Contains(thisPtr->GameObject.OwnerID)) ||
                        (_config.ShowCompanyPet && _players[ContainerType.Company].Contains(thisPtr->GameObject.OwnerID)) ||
                        (_config.ShowPartyPet && _players[ContainerType.Party].Contains(thisPtr->GameObject.OwnerID)))
                    {
                        break;
                    }
                    else
                    {
                        thisPtr->GameObject.RenderFlags |= (int)VisibilityFlags.Invisible;
                        HiddenObjectIds.Add(thisPtr->GameObject.ObjectID);
                        break;
                    }

                case (byte)ObjectKind.BattleNpc
                    when thisPtr->GameObject.SubKind == (byte)BattleNpcSubKind.Pet && thisPtr->NameID == 6565
                    :                             // Earthly Star
                    if (_config.HideStar &&
                        _pluginInterface.ClientState.Condition[ConditionFlag.InCombat] &&
                        thisPtr->GameObject.OwnerID != LocalPlayer->Character.GameObject.ObjectID &&
                        !_players[ContainerType.Party].Contains(thisPtr->GameObject.OwnerID))
                    {
                        thisPtr->GameObject.RenderFlags |= (int)VisibilityFlags.Invisible;
                        HiddenObjectIds.Add(thisPtr->GameObject.ObjectID);
                    }

                    break;

                case (byte)ObjectKind.BattleNpc when thisPtr->GameObject.SubKind == 3:
                    if (!_config.HideChocobo ||
                        thisPtr->GameObject.OwnerID == LocalPlayer->Character.GameObject.ObjectID)
                    {
                        break;
                    }

                    _chocobos[ContainerType.All].Add(thisPtr->GameObject.ObjectID);

                    if (_players[ContainerType.Friend].Contains(thisPtr->GameObject.OwnerID))
                    {
                        _chocobos[ContainerType.Friend].Add(thisPtr->GameObject.ObjectID);
                    }

                    if (_players[ContainerType.Party].Contains(thisPtr->GameObject.OwnerID))
                    {
                        _chocobos[ContainerType.Party].Add(thisPtr->GameObject.ObjectID);
                    }

                    if (_players[ContainerType.Company].Contains(thisPtr->GameObject.OwnerID))
                    {
                        _chocobos[ContainerType.Company].Add(thisPtr->GameObject.ObjectID);
                    }

                    if ((_config.ShowFriendChocobo && _players[ContainerType.Friend].Contains(thisPtr->GameObject.OwnerID)) ||
                        (_config.ShowCompanyChocobo && _players[ContainerType.Company].Contains(thisPtr->GameObject.OwnerID)) ||
                        (_config.ShowPartyChocobo && _players[ContainerType.Party].Contains(thisPtr->GameObject.OwnerID)))
                    {
                        break;
                    }
                    else
                    {
                        thisPtr->GameObject.RenderFlags |= (int)VisibilityFlags.Invisible;
                        HiddenObjectIds.Add(thisPtr->GameObject.ObjectID);
                        break;
                    }
                }
            }

            hookCharacterEnableDraw.Original(thisPtr);
        }
 public unsafe void UpdateLocalPlayer()
 {
     LocalPlayer = *(BattleChara **)_address.LocalPlayerAddress.ToPointer();
 }
Exemplo n.º 5
0
 public partial BattleChara *LookupPetByOwnerObject(BattleChara *owner);