HAI, after seeing florian's pathfinder, i decided to make something out of it.
please note its not ready yet for production since the searching algorithm kinda slow finding the target so with proper mutex for the crucial section and multiple threads you would get over this.
our thread consists of four parts.
FINDING THE TARGET
we have the optimal path as segments , i made two timers to manage the movements
please note that its all for testing purposes, you will have to re implement everything.
Sources:
please note its not ready yet for production since the searching algorithm kinda slow finding the target so with proper mutex for the crucial section and multiple threads you would get over this.
| Gallery | |
|
|
|
our thread consists of four parts.
FINDING THE TARGET
since we implementing the auto move , we have to find the most optimal path to the position that we moving to.MOUSE EVENT HANDLING
thanks to florian0 and bueddl they implemented A* algorithm to find it not only that, they also put the collisions in considerations.
[Only registered and activated users can see links. Click Here To Register...]
after implementing the A* algorithm. we would need to detect the right mouse left up clicks (at my case you would do whatever you want) so that detecting the player coordinates piecewise detecting the real game coordinatesDRAW AT THE MAP
hooking the 3d events functions
calculating the real game coordinates and initialize the pathfinderCode:replaceAddr(0xD99BD8, addr_from_this(&CNIFWorldMap::OnMouseActions));
Code:bool CNIFWorldMap::OnMouseActions(Event3D* mouseData) { bool result = reinterpret_cast<bool (__thiscall *)(CNIFWorldMap *, Event3D*)>(0x00623220)(this, mouseData); switch(mouseData->Msg) { //right mouse up case 0x205: int currentTile_MAYBE = reinterpret_cast<int(__thiscall *) (int*)>(0x0096f4e0)(m_currentPos); float PosX = ((mouseData->lParam - m_currentPosX) * m_stateY) + (float)m_stateX; float PosY = ((-mouseData->wParam + m_currentPosY + (float)*(int *)(currentTile_MAYBE + 0x54)) * m_viewHeight) + (float)m_viewWidth; // From location LocationInfo l1 = {0, 0, 0, D3DXVECTOR3(0, 0, 0)}; l1.region = g_pCICPlayer->region; l1.pos = g_pCICPlayer->location; l1.field_0 = g_pCICPlayer->m_navcell; l1.field_1 = reinterpret_cast<int>(g_pCICPlayer->m_object_under_foot); // To location LocationInfo l2 = {0, 0, 0, D3DXVECTOR3(0, 0, 0)}; l2.pos.x = fmod(abs(PosX),192) * 10.0; l2.pos.y = fmod(abs(PosY), 192) * 10.0; l2.pos.z = fmod(abs(PosY), 192) * 10.0; l2.region.x = (PosX - (l2.pos.x) / 10.0) / 192.0 + 135; l2.region.y = (PosY - (l2.pos.z) / 10.0) / 192.0 + 92; CIFMamaMia* m_pMamaMia = (CIFMamaMia *) g_pCGInterface->GetWindowByUniqueID(1999013); m_pMamaMia->Start(l1,l2); LocationData test; test.region = (l2.region.y << 8) | l2.region.x; test.x = l2.pos.x; test.z = l2.pos.z; test.y = l2.pos.z; m_UniqueLocation[L"automove"] = test; break; } return result; }
iam drawing a duck at the click position, i made a map which includes the texture pointers while initializing them at the creation of the world mapAUTO MOVE
Code:bool CNIFWorldMap::OnWMCreate(long ln) { bool x = reinterpret_cast<bool (__thiscall *)(CNIFWorldMap *,long)>(0x0060F340)(this,ln); m_pUniqueIcon = (IDirect3DBaseTexture9 *) Fun_CacheTexture_Create("ducksoup\\logo.ddj"); //todo interface\targetwindow\tw_icon_unique.ddj return x; } void CNIFWorldMap::OnWMRenderMySelf() { reinterpret_cast<void (__thiscall *)(CNIFWorldMap *)>(0x0061BAC0)(this); std::map<std::n_wstring, LocationData>::const_iterator it = m_UniqueLocation.begin(); for (; it != m_UniqueLocation.end(); it++) { int currentTile_MAYBE = reinterpret_cast<int(__thiscall *) (int*)>(0x0096f4e0)(m_currentPos); float renderPosX = m_currentPosX + (((*it).second.x / 10.0 + (float)((((*it).second.region & 0xff) - 0x87) * 0xc0)) - (float)m_stateX) / m_stateY; float renderPosY = m_currentPosY + ((float)*(int *)(currentTile_MAYBE + 0x54) - (((*it).second.z / 10.0 + (float)((((*it).second.region >> 8) - 0x5c) * 0xc0)) - (float)m_viewWidth) / m_viewHeight); D3DVECTOR dataOut[9]; dataOut[0].x = renderPosX-5; dataOut[0].y = renderPosY-5; dataOut[0].z = 1.0; dataOut[2].x = dataOut[0].x + 45.0f; dataOut[2].y = dataOut[0].y; dataOut[2].z = 1.0; dataOut[4].x = dataOut[0].x + 45.0f; dataOut[4].y = renderPosY-5 + 45.0f; dataOut[4].z = 1.0; dataOut[6].x = dataOut[0].x; dataOut[6].y = dataOut[4].y; dataOut[6].z = 1.0; dataOut[8].z = 0.0; dataOut[1].z = 0.0; dataOut[3].z = 0.0; dataOut[5].z = 1.0; dataOut[7].z = 1.0; dataOut[1].x = 0.1; dataOut[3].x = 0.1; dataOut[5].x = 0.1; dataOut[7].x = 0.1; dataOut[1].y = 0.0; dataOut[3].y = 1.0; dataOut[5].y = 1.0; dataOut[7].y = 0.0; g_RStateMgr.m_pDevice->SetFVF(260); g_RStateMgr.m_pDevice->SetTexture(0,m_pUniqueIcon); g_RStateMgr.sub_4700A0(); g_RStateMgr.m_pDevice->DrawPrimitiveUP(D3DPT_TRIANGLEFAN,2,&dataOut,0x18); } }
we have the optimal path as segments , i made two timers to manage the movements
please note that its all for testing purposes, you will have to re implement everything.
Sources:
[Only registered and activated users can see links. Click Here To Register...] //for testing the algorithm
[Only registered and activated users can see links. Click Here To Register...]
[Only registered and activated users can see links. Click Here To Register...]
[Only registered and activated users can see links. Click Here To Register...]
[Only registered and activated users can see links. Click Here To Register...]
[Only registered and activated users can see links. Click Here To Register...]
[Only registered and activated users can see links. Click Here To Register...]