Never mind
Last edited by zsuperman; 09-23-2018 at 12:17 PM.
anybody got any tips for finding lua_setfield? im thinking of trying to search for xrefs to something like lua_pushcclosure and looking at functions that r called after it
nevermind! i just read about it in the lua docs and ill just use something like this guy instead
Programming in Lua : 25.1Code:void setfield (const char *index, int value) { lua_pushstring(L, index); lua_pushnumber(L, (double)value/MAX_COLOR); lua_settable(L, -3); }
Last edited by xashh; 12-17-2018 at 12:32 PM.
Has anyone gotten BoxCollide to work? I think I have the correct offsets. Going to look into it more, just seeing if anyone else has it working.Code:LoadModel = 0x00706A50 ... BoxCollide = 0x006AC060 CurrentBoundingBox = 0x00C4E5A0 BoxCollide_CollisionInfo = 0x00BE0F54
Anyone able to shed some more light on world2screen? It seems the x position is correct but the y is doing weird stuff.
Please excuse the mess - still just trying to get it working. Also if anyone has an easy way to get the wow window that would be helpful - im currently using GetActiveWindow() so if i alt tab the drawing stops.
Code:static auto const WorldToScreen = reinterpret_cast<bool(__thiscall *)( DWORD framePtr, C3Vector* c3Struct, C3Vector* c2Struct)>(Offsets::FunctionOffsets::WorldToScreen); // 0x483EE0After looking at some snippets for later expacs (Jadds is floating around), I went looking and have found DDCToNDC at 0x41ADE0, but am still looking into it - the function in 1.12.1 seems different.Code:if (liteMgrr->Target != NULL) { C3Vector targetPos; auto targLoc = liteMgrr->Target->GetLocation(); targetPos.x = *targLoc.X; targetPos.y = *targLoc.Y; targetPos.z = *targLoc.Z; drawVector = WorldToScreen(framePtr, &targetPos, &drawPos); RECT windowRect; bool findScreen = GetWindowRect(GetActiveWindow(), &windowRect); if (findScreen && drawVector) { float width = windowRect.right - windowRect.left; // left is always zero float height = windowRect.bottom - windowRect.top; // top is always zero drawPos.x = (drawPos.x * width); // This seems right, it is really close drawPos.y = height -(drawPos.y * (height *2)); // This is the closest //drawPos.y = height -(drawPos.y * height); // This initially looked like the inverse // Draw code happens later but same frame } else { drawVector = false; } }
Untitled.jpg
don't use get window rect that will throw it off you should be using getclientrect something like this
notice with getclientrect it properly overlays the window without the tittlebars (the red lines are the fake overlay window bordersPHP Code:
private static bool SetOverlayPosition(string appName)
{
var hwnd = Process.GetProcessesByName(appName).FirstOrDefault().MainWindowHandle;
if (hwnd == IntPtr.Zero) return false;
GetClientRect(hwnd, out var test);
var top = new Point();
ClientToScreen(hwnd, ref top);
Overlay.Resize(top.X, top.Y, test.Right - test.Left, test.Bottom - test.Top);
return true;
}
notice the difference here with getwindowrect it gets the tittlebar and the invisible borders from windows 10
iswindowtopmost maybe would be better u can use the main window handle like the above code does for this (idk how ur overlaying so this may always return false because of ur overlay window u will have to test)
PHP Code:
[DllImport("user32.dll", SetLastError=true)]
static extern int GetWindowLong(IntPtr hWnd, int nIndex);
const int GWL_EXSTYLE = -20;
const int WS_EX_TOPMOST = 0x0008;
public static bool IsWindowTopMost(IntPtr hWnd)
{
int exStyle = GetWindowLong(hWnd, GWL_EXSTYLE);
return (exStyle & WS_EX_TOPMOST) == WS_EX_TOPMOST;
}
Last edited by Icesythe7; 03-12-2019 at 09:23 AM.
Got it fixed, two issues in the end.
1. As Icesythe7 said getwindowrect was off - got the hWnd from (LPDIRECT3DDEVICE9)pDevice->GetCreationParameters
2. DDCtoNDC seems to fix the rest of the allignment issues
and if anyone else needs a template for world to screenCode:// at 0x41ADE0 void __fastcall DDCToNDC(float *pfParm1,float *pfParm2,float param_1,float param_2) { if (pfParm1 != (float *)0x0) { *pfParm1 = param_1 / _DAT_00832a44; } if (pfParm2 != (float *)0x0) { *pfParm2 = param_2 / _DAT_00832a48; } return; }
fixed.jpgCode:// uint __thiscall GetScreenCoordinates(int iParm1,float param_1,float *param_2) // 1.12.1 drawVector = WorldToScreen(framePtr, &targetPos, &drawPos); RECT windowRect; bool noVal = GetClientRect(clientHwnd, &windowRect); if (noVal && drawVector) { float x, y; DDCToNDC(&x, &y, drawPos.x, drawPos.y); float width = windowRect.right - windowRect.left; float height = windowRect.bottom - windowRect.top; drawPos.x = (x * width); drawPos.y = height -(y * height); }
Last edited by boipus; 03-13-2019 at 09:06 AM. Reason: added img
hmm I'm having a hard time with this function aswell
nvm had an address wrong is working now ^ (if u dont want to use ddctondc)Code:ImVec2 WorldToScreen(Reclass::Vector3 inPos) { auto io = ImGui::GetIO(); ImVec2 tempOut; if (reinterpret_cast<bool(__thiscall*)(uintptr_t framePtr, Reclass::Vector3* posIn, ImVec2* screenPosOut)>(0x483EE0)(*reinterpret_cast<uintptr_t*>(0xB4B2BC), &inPos, &tempOut)) { tempOut.x = tempOut.x / 0.8715755343 * io.DisplaySize.x; tempOut.y = io.DisplaySize.y - tempOut.y / 0.4902612269 * io.DisplaySize.y; return tempOut; } return ImVec2(-1, -1); }
Last edited by Icesythe7; 03-16-2019 at 12:00 AM.
full python 3 implementation of a world to screen viewer of game object coordinates for version 1.12.1
it might not work for other resolutions than 1920x1080
Code:""" Made for wow 1.12.1.5875, python>=3.6 ````sh $ pip install pypiwin32==224 Pymem==1.0 psutil mss numpy matplotlib ``` # Links ### Fishbot https://github.com/WowDevs/Fishbot-1.12.1/blob/fd3855845ae12e32ca5477526017b0b9ee680b9c/FishBot%201.12.1/GUI/MainWindow.cs https://github.com/WowDevs/Fishbot-1.12.1/blob/fd3855845ae12e32ca5477526017b0b9ee680b9c/FishBot%201.12.1/Helpers/Offsets.cs?ts=4 https://github.com/WowDevs/Fishbot-1.12.1/blob/fd3855845ae12e32ca5477526017b0b9ee680b9c/FishBot%201.12.1/Hook/Hook.cs?ts=4 ### WowObjects / offsets https://www.ownedcore.com/forums/world-of-warcraft/world-of-warcraft-bots-programs/wow-memory-editing/208754-guide-kind-of-how-i-handle-objects.html https://www.ownedcore.com/forums/world-of-warcraft/world-of-warcraft-bots-programs/wow-memory-editing/328263-wow-1-12-1-5875-info-dump-thread-3.html#post2436167 https://www.ownedcore.com/forums/world-of-warcraft/world-of-warcraft-bots-programs/wow-memory-editing/328263-wow-1-12-1-5875-info-dump-thread-29.html#post3680708 https://www.ownedcore.com/forums/world-of-warcraft/world-of-warcraft-bots-programs/wow-memory-editing/328263-wow-1-12-1-5875-info-dump-thread-38.html#post3859175 # world to screen ### First attempt https://www.ownedcore.com/forums/world-of-warcraft/world-of-warcraft-bots-programs/wow-memory-editing/599004-world-screen.html#post3661355 ### Second attempt https://www.ownedcore.com/forums/world-of-warcraft/world-of-warcraft-bots-programs/wow-memory-editing/535748-world-screen.html#post3347571 ### Third Attempt https://www.ownedcore.com/forums/world-of-warcraft/world-of-warcraft-bots-programs/wow-memory-editing/271612-world-screen.html#post1754193 ### Misc https://www.ownedcore.com/forums/world-of-warcraft/world-of-warcraft-bots-programs/wow-memory-editing/328263-wow-1-12-1-5875-info-dump-thread-40.html#post4022185 https://www.ownedcore.com/forums/world-of-warcraft/world-of-warcraft-bots-programs/wow-memory-editing/544312-12-1-2016-bans-3.html#post3386119 """ import numpy as np import pymem import psutil import mss import matplotlib.pyplot as plt MAGIC_SCALE_FACTOR = 1 / 1.10 # TODO: Find the real formula SCREEN_SIZE = 1920, 1080 # TODO: Find in memory class Offset: player_name = 0x827D88 obj_manager = 0x00741414 camera = 0x0074B2BC class ObjectManager: first_obj = 0xAC class Object: type = 0x14 next = 0x3C class GameObject: guid = 0x30 name1 = 0x214 name2 = 0x8 xyz = 0x248 class Camera: offset = 0x65B8 xyz = 0x8 facing = xyz + 3 * 4 fov = xyz + 14 * 4 aspect = xyz + 15 * 4 class WoW: def __init__(self, pid=None): if pid is None: pid, = [ps.pid for ps in psutil.process_iter() if ps.name() == 'WoW.exe'] pm = pymem.Pymem() pm.open_process_from_id(pid) self.pid = pid self.pm = pm mod, = [mod for mod in pm.list_modules() if mod.name == 'WoW.exe'] base_address = mod.lpBaseOfDll obj_mgr_addr = pm.read_uint(base_address + Offset.obj_manager) first_obj_addr = pm.read_uint(obj_mgr_addr + Offset.ObjectManager.first_obj) self.mod = mod self.base_address = base_address self.player_name = pm.read_string(self.base_address + Offset.player_name) self.first_obj_addr = first_obj_addr def pull_floats(self, addr, shape): a = np.empty(shape, 'float32') for i, idxs in enumerate(np.ndindex(*shape)): a[idxs] = self.pm.read_float(addr + i * 4) return a.astype('float64') def gen_objects(self): obj_addr = self.first_obj_addr while True: if not (obj_addr != 0 and obj_addr & 0x1 == 0): break yield obj_addr next_addr = self.pm.read_uint(obj_addr + Offset.Object.next) if next_addr == obj_addr: break obj_addr = next_addr def gen_game_objects(self): for obj_addr in self.gen_objects(): if self.pm.read_int(obj_addr + Offset.Object.type) == 5: yield GameObject(self, obj_addr) class Camera(): def __init__(self, w): cam0 = w.pm.read_uint(w.base_address + Offset.camera) cam1 = w.pm.read_uint(cam0 + Offset.Camera.offset) self.xyz = w.pull_floats(cam1 + Offset.Camera.xyz, (3,)) self.facing = w.pull_floats(cam1 + Offset.Camera.facing, (3, 3)) self.fov = w.pull_floats(cam1 + Offset.Camera.fov, ()) self.aspect = w.pull_floats(cam1 + Offset.Camera.aspect, ()) self.size = np.asarray(SCREEN_SIZE) assert np.allclose(self.aspect, np.divide.reduce(self.size.astype(float))) def world_to_screen(self, xyz): diff = xyz - self.xyz """ At this point: - Origin is the center of the screen - Unit vector is a yard long - Axes are right handed z-axis (sky) ^ | 7 x-axis (north) | / y-axis |/ <-------+ (west) """ view = diff @ np.linalg.inv(self.facing) """ At this point: - Origin is the center of the screen - Unit vector is ~a yard long - Axes are right handed z-axis (top of the screen) ^ | 7 x-axis (depth) | / y-axis |/ <-------+ (left of the screen) """ cam = np.asarray([-view[1], -view[2], view[0]]) """ At this point: - Origin is the center of the screen - Unit vector is a yard long - Axes are right handed 7 z-axis (depth) / / x-axis +---------> | (right of the screen) | | v y-axis (bottom of the screen) """ fov_x = (1 / (1 + 1 / self.aspect ** 2)) ** 0.5 fov_y = fov_x / self.aspect fov_x *= self.fov fov_y *= self.fov fov_x *= MAGIC_SCALE_FACTOR screen_right_at_unit_depth = np.tan(fov_x / 2) screen_bottom_at_unit_depth = np.tan(fov_y / 2) screen_right_at_point_depth = screen_right_at_unit_depth * cam[2] screen_bottom_at_point_depth = screen_bottom_at_unit_depth * cam[2] screen = np.asarray([ cam[0] / screen_right_at_point_depth, cam[1] / screen_bottom_at_point_depth, ]) """ At this point: - Origin is the center of the screen - Unit vector is half of the screen x-axis +---------> | (right of the screen) | | v y-axis (bottom of the screen) """ raster = self.size / 2 * (1 + screen) """ At this point: - Origin is the top left of the screen - Unit vector is a pixel x-axis +---------> | (right of the screen) | | v y-axis (bottom of the screen) """ behind = cam[2] < 0 in_fov = np.all(np.abs(screen) <= 1) and not behind return raster, in_fov, behind class GameObject: def __init__(self, w, addr): assert w.pm.read_int(addr + Offset.Object.type) == 5 self.addr = addr a = addr a += Offset.GameObject.name1 a = w.pm.read_uint(a) a += Offset.GameObject.name2 a = w.pm.read_uint(a) self.name = w.pm.read_string(a) self.xyz = w.pull_floats(addr + Offset.GameObject.xyz, (3,)) w = WoW() cam = Camera(w) print(' Snapping...') with mss.mss() as sct: monitor = sct.monitors[1] img = sct.grab(monitor) img = np.asarray(img)[:, :, [2, 1, 0]] print(' Snaped!', img.shape) fig = plt.figure() ax = fig.add_subplot(111) ax.imshow(img) for go in list(w.gen_game_objects()): x, y, z = go.xyz ox = x - cam.xyz[0] dx = ['south', 'north'][int(ox > 0)] oy = y - cam.xyz[1] dy = ['east', 'west'][int(oy > 0)] print(f'{go.name:>30}: (' f'{ox:+7.2f}({dx})({x:<10.2f}), ' f'{oy:+7.2f}({dy})({y:<10.2f}), ' f'{z - cam.xyz[2]:+7.2f}({z:<10.2f})), ' ) (x, y), in_fov, behind = cam.world_to_screen(go.xyz) print('>', x, y, in_fov, behind) if in_fov: ax.annotate(go.name, xy=(x, y), xytext=(x - 150, y + 150), arrowprops=dict(facecolor='black', shrink=0.005)) plt.show() plt.close('all')
Figure_wow.jpg
Hello guys. Please tell me how i can get the time that character spent in game? Maybe someone has the address where this data is stored.
Thank you in advance. And i apologize for my english.
Hey ! nice to see pymem beeing used here !
(btw I'm the author of pymem).
My blog: https://pimpmykitty.wordpress.com
PyFasm: https://github.com/srounet/pyfasm
Pymem: https://github.com/srounet/pymem
Hi,
Anyone who can help with a function that can find the angle between the player and the target position. - What i want, is to figure out if the bot needs to go left or right to face its target, but i have actually no idea how to do that.
I have created the WorldToScreen function in C#, based on the python code, which is working perfectly.
Code:public ScreenModel WorldToScreen(Vector3 unitPosition) { var diff = unitPosition - Position; Matrix4x4 invertedMatrix; Matrix4x4.Invert(Facing, out invertedMatrix); var view = Vector3.Transform(diff, invertedMatrix); var cam = new Vector3(-view.Y, -view.Z, view.X); var fovx = Math.Pow((1 / (1 + 1 / Math.Pow(Aspect, 2))), 0.5); var fovy = fovx / Aspect; fovx *= Fov; fovy *= Fov; fovx *= 1 / 1.10; var screen_right_at_unit_depth = Math.Tan(fovx / 2); var screen_bottom_at_unit_depth = Math.Tan(fovy / 2); var screen_right_at_point_depth = screen_right_at_unit_depth * cam.Z; var screen_bottom_at_point_depth = screen_bottom_at_unit_depth * cam.Z; var screen = new Vector2((float)(cam.X / screen_right_at_point_depth), (float)(cam.Y / screen_bottom_at_point_depth)); var raster = ScreenSize / 2 * (Vector2.One + screen); var behind = cam.Z < 0; var infov = Math.Abs(screen.X) <= 1 && Math.Abs(screen.Y) <= 1 && !behind; var model = new ScreenModel(); model.Point = raster; model.IsBehind = behind; model.IsInFov = infov; return model; }
I don't think you need to do world-to-screen to make that decision. If you look at their position relative to yours you should be able to determine what angle you should be facing. And then you just figure out if turning right or left will get you to that orientation more quickly.