Esempio n. 1
0
 public RunAsmHookModule(Action <IntPtr> onUpdate, Action <IHookModule> tick, IMemoryApi memoryApi, uint allocSize)
 {
     MemoryApi    = memoryApi;
     AllocSize    = allocSize;
     OnDataUpdate = onUpdate;
     Tick         = tick;
 }
Esempio n. 2
0
 public virtual void Update(IMemoryApi memoryApi, IOffsetList offsetList)
 {
     if (DescriptorAddress != IntPtr.Zero && memoryApi.Read(DescriptorAddress, out WowObjectDescriptor obj))
     {
         RawObject = obj;
     }
 }
Esempio n. 3
0
        public override void Update(IMemoryApi memoryApi, IOffsetList offsetList)
        {
            base.Update(memoryApi, offsetList);

            if (!memoryApi.Read(DescriptorAddress + WowObjectDescriptor.EndOffset,
                                out WowItemDescriptor objPtr))
            {
                return;
            }

            Count = objPtr.StackCount;
            Owner = objPtr.Owner;

            ItemEnchantments = new List <ItemEnchantment>
            {
                objPtr.Enchantment1,
                objPtr.Enchantment2,
                objPtr.Enchantment3,
                objPtr.Enchantment4,
                objPtr.Enchantment5,
                objPtr.Enchantment6,
                objPtr.Enchantment7,
                objPtr.Enchantment8,
                objPtr.Enchantment9,
                objPtr.Enchantment10,
                objPtr.Enchantment11,
                objPtr.Enchantment12,
            };
        }
Esempio n. 4
0
        public LocalAmeisenBotDb(IWowInterface wowInterface, IMemoryApi memoryApi)
        {
            MemoryApi = memoryApi;
            Wow       = wowInterface;

            Clear();
        }
Esempio n. 5
0
        public override void Update(IMemoryApi memoryApi, IOffsetList offsetList)
        {
            base.Update(memoryApi, offsetList);

            if (memoryApi.Read(DescriptorAddress + WowObjectDescriptor.EndOffset, out WowCorpseDescriptor obj))
            {
                RawWowCorpse = obj;
            }
        }
Esempio n. 6
0
        public override void Update(IMemoryApi memoryApi, IOffsetList offsetList)
        {
            base.Update(memoryApi, offsetList);

            if (memoryApi.Read(DescriptorAddress + WowObjectDescriptor.EndOffset, out WowDynobjectDescriptor objPtr) &&
                memoryApi.Read(IntPtr.Add(BaseAddress, (int)offsetList.WowDynobjectPosition), out Vector3 position))
            {
                Caster   = objPtr.Caster;
                Radius   = objPtr.Radius;
                SpellId  = objPtr.SpellId;
                Position = position;
            }
        }
Esempio n. 7
0
        private IMemoryApi memoryApi = null; //add for the addition of interface of IMemoryApi

        void PrepareHardware(IAbstractFactory2 schema)
        {
            cpuApi       = (ICPUApi)schema.CreateApi(1);
            mainboardApi = (IMainboardApi)schema.CreateApi(2);
            memoryApi    = (IMemoryApi)schema.CreateApi(3);

            cpuApi.Calculate();
            mainboardApi.InstallCPU();

            if (memoryApi != null) // Add For addtional interface of IMemoryApi
            {
                memoryApi.RunMem();
            }
        }
        public DefaultCharacterManager(IWowInterface wowInterface, IMemoryApi memoryApi)
        {
            Wow       = wowInterface;
            MemoryApi = memoryApi;

            Inventory        = new CharacterInventory(Wow);
            Equipment        = new CharacterEquipment(Wow);
            SpellBook        = new SpellBook(Wow);
            TalentManager    = new TalentManager(Wow);
            LastLevelTrained = 0;
            ItemComparator   = new ItemLevelComparator();
            Skills           = new Dictionary <string, (int, int)>();

            ItemSlotsToSkip = new List <WowEquipmentSlot>();
        }
Esempio n. 9
0
        public List <float> GetPosition(IMemoryApi mem)
        {
            float harryX = QToFloat(mem.ReadS32(Rom.Addresses.MainRam.HarryPositionX));
            float harryY = QToFloat(mem.ReadS32(Rom.Addresses.MainRam.HarryPositionY));
            float harryZ = QToFloat(mem.ReadS32(Rom.Addresses.MainRam.HarryPositionZ));

            float cameraX = QToFloat(mem.ReadS32(Rom.Addresses.MainRam.CameraPositionActualX));
            float cameraY = QToFloat(mem.ReadS32(Rom.Addresses.MainRam.CameraPositionActualY));
            float cameraZ = QToFloat(mem.ReadS32(Rom.Addresses.MainRam.CameraPositionActualZ));

            return(new List <float>()
            {
                harryX, harryY, harryZ,
                cameraX, cameraY, cameraZ
            });
        }
Esempio n. 10
0
        public override void Update(IMemoryApi memoryApi, IOffsetList offsetList)
        {
            base.Update(memoryApi, offsetList);

            if (memoryApi.Read(DescriptorAddress + WowObjectDescriptor.EndOffset, out WowGameobjectDescriptor objPtr) &&
                memoryApi.Read(IntPtr.Add(BaseAddress, (int)offsetList.WowGameobjectPosition), out Vector3 position))
            {
                GameObjectType = (WowGameObjectType)objPtr.GameobjectBytes1;
                CreatedBy      = objPtr.CreatedBy;
                Bytes0         = objPtr.GameobjectBytes0;
                DisplayId      = objPtr.DisplayId;
                Faction        = objPtr.Faction;
                Flags          = new(objPtr.Flags);
                Level          = objPtr.Level;
                Position       = position;
            }
        }
Esempio n. 11
0
        public List <float> GetAngles(IMemoryApi mem)
        {
            uint harryPitch = mem.ReadU16(Rom.Addresses.MainRam.HarryPitch);
            uint harryYaw   = mem.ReadU16(Rom.Addresses.MainRam.HarryYaw);
            uint harryRoll  = mem.ReadU16(Rom.Addresses.MainRam.HarryRoll);

            uint cameraPitch = mem.ReadU16(Rom.Addresses.MainRam.CameraActualPitch);
            uint cameraYaw   = mem.ReadU16(Rom.Addresses.MainRam.CameraActualYaw);
            uint cameraRoll  = mem.ReadU16(Rom.Addresses.MainRam.CameraActualRoll);

            return(new List <float>()
            {
                GameUnitsToDegrees(harryPitch),
                GameUnitsToDegrees(harryYaw),
                GameUnitsToDegrees(harryRoll),

                GameUnitsToDegrees(cameraPitch),
                GameUnitsToDegrees(cameraYaw),
                GameUnitsToDegrees(cameraRoll)
            });
        }
Esempio n. 12
0
        public override string ReadName(IMemoryApi memoryApi, IOffsetList offsetList)
        {
            if (memoryApi.Read(IntPtr.Add(offsetList.NameStore, (int)offsetList.NameMask), out uint nameMask) &&
                memoryApi.Read(IntPtr.Add(offsetList.NameStore, (int)offsetList.NameBase), out uint nameBase))
            {
                uint shortGuid = (uint)Guid & 0xfffffff;
                uint offset    = 12 * (nameMask & shortGuid);

                if (memoryApi.Read(new(nameBase + offset + 8), out uint current) &&
                    memoryApi.Read(new(nameBase + offset), out offset))
                {
                    if ((current & 0x1) == 0x1)
                    {
                        return(string.Empty);
                    }

                    memoryApi.Read(new(current), out uint testGuid);

                    while (testGuid != shortGuid)
                    {
                        memoryApi.Read(new(current + offset + 4), out current);

                        if ((current & 0x1) == 0x1)
                        {
                            return(string.Empty);
                        }

                        memoryApi.Read(new(current), out testGuid);
                    }

                    if (memoryApi.ReadString(new(current + (int)offsetList.NameString), Encoding.UTF8, out string name, 16))
                    {
                        return(name);
                    }
                }
            }

            return(string.Empty);
        }
Esempio n. 13
0
 public void SetHarryPosition(IMemoryApi mem, float x, float y, float z)
 {
     SetHarryX(mem, x);
     SetHarryY(mem, y);
     SetHarryZ(mem, z);
 }
Esempio n. 14
0
 public void SetHarryZ(IMemoryApi mem, float z)
 {
     mem.WriteS32(Rom.Addresses.MainRam.HarryPositionZ, FloatToQ(z));
 }
Esempio n. 15
0
 public void SetHarryY(IMemoryApi mem, float y)
 {
     mem.WriteS32(Rom.Addresses.MainRam.HarryPositionY, FloatToQ(y));
 }
Esempio n. 16
0
        public override void Update(IMemoryApi memoryApi, IOffsetList offsetList)
        {
            base.Update(memoryApi, offsetList);

            if (memoryApi.Read(DescriptorAddress + WowObjectDescriptor.EndOffset + WowUnitDescriptor.EndOffset, out WowPlayerDescriptor obj))
            {
                RawWowPlayer = obj;

                questlogEntries = new QuestlogEntry[]
                {
                    obj.QuestlogEntry1,
                    obj.QuestlogEntry2,
                    obj.QuestlogEntry3,
                    obj.QuestlogEntry4,
                    obj.QuestlogEntry5,
                    obj.QuestlogEntry6,
                    obj.QuestlogEntry7,
                    obj.QuestlogEntry8,
                    obj.QuestlogEntry9,
                    obj.QuestlogEntry10,
                    obj.QuestlogEntry11,
                    obj.QuestlogEntry12,
                    obj.QuestlogEntry13,
                    obj.QuestlogEntry14,
                    obj.QuestlogEntry15,
                    obj.QuestlogEntry16,
                    obj.QuestlogEntry17,
                    obj.QuestlogEntry18,
                    obj.QuestlogEntry19,
                    obj.QuestlogEntry20,
                    obj.QuestlogEntry21,
                    obj.QuestlogEntry22,
                    obj.QuestlogEntry23,
                    obj.QuestlogEntry24,
                    obj.QuestlogEntry25,
                };

                itemEnchantments = new VisibleItemEnchantment[]
                {
                    obj.VisibleItemEnchantment1,
                    obj.VisibleItemEnchantment2,
                    obj.VisibleItemEnchantment3,
                    obj.VisibleItemEnchantment4,
                    obj.VisibleItemEnchantment5,
                    obj.VisibleItemEnchantment6,
                    obj.VisibleItemEnchantment7,
                    obj.VisibleItemEnchantment8,
                    obj.VisibleItemEnchantment9,
                    obj.VisibleItemEnchantment10,
                    obj.VisibleItemEnchantment11,
                    obj.VisibleItemEnchantment12,
                    obj.VisibleItemEnchantment13,
                    obj.VisibleItemEnchantment14,
                    obj.VisibleItemEnchantment15,
                    obj.VisibleItemEnchantment16,
                    obj.VisibleItemEnchantment17,
                    obj.VisibleItemEnchantment18,
                    obj.VisibleItemEnchantment19,
                };
            }

            if (memoryApi.Read(IntPtr.Add(BaseAddress, (int)offsetList.WowUnitSwimFlags), out uint swimFlags))
            {
                IsSwimming = (swimFlags & 0x200000) != 0;
            }

            if (memoryApi.Read(IntPtr.Add(BaseAddress, (int)offsetList.WowUnitFlyFlagsPointer), out IntPtr flyFlagsPointer) &&
                memoryApi.Read(IntPtr.Add(flyFlagsPointer, (int)offsetList.WowUnitFlyFlags), out uint flyFlags))
            {
                IsFlying = (flyFlags & 0x2000000) != 0;
            }

            if (memoryApi.Read(offsetList.BreathTimer, out int breathTimer))
            {
                IsUnderwater = breathTimer > 0;
            }

            if (memoryApi.Read(offsetList.ComboPoints, out byte comboPoints))
            {
                ComboPoints = comboPoints;
            }

            IsGhost = HasBuffById(8326);
        }
Esempio n. 17
0
 public void SetRoll(IMemoryApi mem, float roll)
 {
     mem.WriteU16(Rom.Addresses.MainRam.HarryRoll, DegreesToGameUnits(roll));
 }
Esempio n. 18
0
        public static LocalAmeisenBotDb FromJson(string dbFile, IWowInterface wowInterface, IMemoryApi memoryApi)
        {
            if (!Directory.Exists(Path.GetDirectoryName(dbFile)))
            {
                Directory.CreateDirectory(Path.GetDirectoryName(dbFile));
            }
            else if (File.Exists(dbFile))
            {
                AmeisenLogger.I.Log("Cache", "Loading Cache", LogLevel.Debug);

                try
                {
                    LocalAmeisenBotDb db = JsonSerializer.Deserialize <LocalAmeisenBotDb>(File.ReadAllText(dbFile), new() { AllowTrailingCommas = true, NumberHandling = JsonNumberHandling.AllowReadingFromString });
                    db.MemoryApi = memoryApi;
                    db.Wow       = wowInterface;
                    return(db);
                }
                catch (Exception ex)
                {
                    AmeisenLogger.I.Log("Cache", $"Error while loading db:\n{ex}", LogLevel.Debug);
                }
            }

            return(new(wowInterface, memoryApi));
        }
 public BizHawkBinarySerializer(IMemoryApi mem)
 {
     Mem = mem;
     CurrentAddressValue = 0x00;
 }
Esempio n. 20
0
 public TracelineJumpHookModule(Action <IntPtr> onUpdate, Action <IHookModule> tick, IMemoryApi memoryApi, IOffsetList offsetList) : base(onUpdate, tick, memoryApi, 256)
 {
     OffsetList = offsetList;
 }
Esempio n. 21
0
 public void SetPitch(IMemoryApi mem, float pitch)
 {
     mem.WriteU16(Rom.Addresses.MainRam.HarryPitch, DegreesToGameUnits(pitch));
 }
Esempio n. 22
0
 public void SetYaw(IMemoryApi mem, float yaw)
 {
     mem.WriteU16(Rom.Addresses.MainRam.HarryYaw, DegreesToGameUnits(yaw));
 }
Esempio n. 23
0
 public RunLuaHookModule(Action <IntPtr> onUpdate, Action <IHookModule> tick, IMemoryApi memoryApi, IOffsetList offsetList, string lua, string varName, uint allocSize = 128) : base(onUpdate, tick, memoryApi, allocSize)
 {
     OffsetList = offsetList;
     Lua        = lua;
     VarName    = varName;
 }
Esempio n. 24
0
 public void SetAngles(IMemoryApi mem, float pitch, float yaw, float roll)
 {
     SetPitch(mem, pitch);
     SetYaw(mem, yaw);
     SetRoll(mem, roll);
 }
Esempio n. 25
0
 public void SetHarryX(IMemoryApi mem, float x)
 {
     mem.WriteS32(Rom.Addresses.MainRam.HarryPositionX, FloatToQ(x));
 }
Esempio n. 26
0
        public WowInterface335a(IMemoryApi memoryApi)
        {
            Memory = memoryApi;

            OffsetList  = new();
            HookModules = new();

            // lua variable names for the event hook
            string handlerName     = BotUtils.FastRandomStringOnlyLetters();
            string tableName       = BotUtils.FastRandomStringOnlyLetters();
            string eventHookOutput = BotUtils.FastRandomStringOnlyLetters();

            // name of the frame used to capture wows events
            string eventHookFrameName = BotUtils.FastRandomStringOnlyLetters();

            EventManager = new(LuaDoString, eventHookFrameName);

            // module to process wows events.
            HookModules.Add(new RunLuaHookModule
                            (
                                (x) =>
            {
                if (x != IntPtr.Zero &&
                    memoryApi.ReadString(x, Encoding.UTF8, out string s) &&
                    !string.IsNullOrWhiteSpace(s))
                {
                    EventManager.OnEventPush(s);
                }
            },
                                null,
                                memoryApi,
                                Offsets,
                                $"{eventHookOutput}='['function {handlerName}(self,a,...)table.insert({tableName},{{time(),a,{{...}}}})end if {eventHookFrameName}==nil then {tableName}={{}}{eventHookFrameName}=CreateFrame(\"FRAME\"){eventHookFrameName}:SetScript(\"OnEvent\",{handlerName})else for b,c in pairs({tableName})do {eventHookOutput}={eventHookOutput}..'{{'for d,e in pairs(c)do if type(e)==\"table\"then {eventHookOutput}={eventHookOutput}..'\"args\": ['for f,g in pairs(e)do {eventHookOutput}={eventHookOutput}..'\"'..g..'\"'if f<=table.getn(e)then {eventHookOutput}={eventHookOutput}..','end end {eventHookOutput}={eventHookOutput}..']}}'if b<table.getn({tableName})then {eventHookOutput}={eventHookOutput}..','end else if type(e)==\"string\"then {eventHookOutput}={eventHookOutput}..'\"event\": \"'..e..'\",'else {eventHookOutput}={eventHookOutput}..'\"time\": \"'..e..'\",'end end end end end {eventHookOutput}={eventHookOutput}..']'{tableName}={{}}",
                                eventHookOutput
                            ));

            string staticPopupsVarName = BotUtils.FastRandomStringOnlyLetters();
            string oldPoupString       = string.Empty;

            // module that monitors the STATIC_POPUP windows.
            HookModules.Add(new RunLuaHookModule
                            (
                                (x) =>
            {
                if (x != IntPtr.Zero &&
                    memoryApi.ReadString(x, Encoding.UTF8, out string s) &&
                    !string.IsNullOrWhiteSpace(s))
                {
                    if (!oldPoupString.Equals(s, StringComparison.Ordinal))
                    {
                        OnStaticPopup?.Invoke(s);
                        oldPoupString = s;
                    }
                }
                else
                {
                    oldPoupString = string.Empty;
                }
            },
                                null,
                                memoryApi,
                                Offsets,
                                $"{staticPopupsVarName}=\"\"for b=1,STATICPOPUP_NUMDIALOGS do local c=_G[\"StaticPopup\"..b]if c:IsShown()then {staticPopupsVarName}={staticPopupsVarName}..b..\":\"..c.which..\"; \"end end",
                                staticPopupsVarName
                            ));

            string battlegroundStatusVarName = BotUtils.FastRandomStringOnlyLetters();
            string oldBattlegroundStatus     = string.Empty;

            // module to monitor the battleground (and queue) status.
            HookModules.Add(new RunLuaHookModule
                            (
                                (x) =>
            {
                if (x != IntPtr.Zero &&
                    memoryApi.ReadString(x, Encoding.UTF8, out string s) &&
                    !string.IsNullOrWhiteSpace(s))
                {
                    if (!oldBattlegroundStatus.Equals(s, StringComparison.Ordinal))
                    {
                        OnBattlegroundStatus?.Invoke(s);
                        oldBattlegroundStatus = s;
                    }
                }
                else
                {
                    oldBattlegroundStatus = string.Empty;
                }
            },
                                null,
                                memoryApi,
                                Offsets,
                                $"{battlegroundStatusVarName}=\"\"for b=1,MAX_BATTLEFIELD_QUEUES do local c,d,e,f,g,h=GetBattlefieldStatus(b)local i=GetBattlefieldTimeWaited(b)/1000;{battlegroundStatusVarName}={battlegroundStatusVarName}..b..\":\"..tostring(c or\"unknown\")..\":\"..tostring(d or\"unknown\")..\":\"..tostring(e or\"unknown\")..\":\"..tostring(f or\"unknown\")..\":\"..tostring(g or\"unknown\")..\":\"..tostring(h or\"unknown\")..\":\"..tostring(i or\"unknown\")..\";\"end",
                                battlegroundStatusVarName
                            ));

            // module to detect small obstacles that we can jump over
            HookModules.Add(new TracelineJumpHookModule
                            (
                                null,
                                (x) =>
            {
                IntPtr dataPtr = x.GetDataPointer();

                if (dataPtr != IntPtr.Zero && Player != null)
                {
                    Vector3 playerPosition = Player.Position;
                    playerPosition.Z      += 1.3f;

                    Vector3 pos = BotUtils.MoveAhead(playerPosition, Player.Rotation, 0.25f);
                    memoryApi.Write(dataPtr, (1.0f, playerPosition, pos));
                }
            },
                                memoryApi,
                                Offsets
                            ));

            ObjectManager = new(memoryApi, Offsets);

            Hook = new(memoryApi, Offsets, ObjectManager);
            Hook.OnGameInfoPush += ObjectManager.HookManagerOnGameInfoPush;
        }
 public Rayman1Serializer(IMemoryApi mem, Dictionary <Rayman1Pointer, long> pointerTable, Rayman1EngineVersion engineVersion) : base(mem)
 {
     PointerTable  = pointerTable;
     EngineVersion = engineVersion;
 }