[Release] auto move by clicking at map

02/10/2023 14:27 bimbum*#1
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.

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.
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...]
MOUSE EVENT HANDLING
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 coordinates

hooking the 3d events functions
Code:
    replaceAddr(0xD99BD8, addr_from_this(&CNIFWorldMap::OnMouseActions));
calculating the real game coordinates and initialize the pathfinder
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;
}
DRAW AT THE MAP
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 map

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);
    }
}
AUTO MOVE
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...]
02/11/2023 22:51 caner_tr#2
Great Release. ty for share
02/12/2023 02:25 HypnosĄ#3
OMG, that's insanely good improvement and feature! Thank you!
02/12/2023 03:22 random82600#4
Great. Thank you
02/12/2023 07:19 790312795#5
u are always making the amazing works
02/12/2023 09:57 painmaker_#6
At least there are some people who don't care about any features and if they decide to release something, they will not hesitate to do so. Keep up the good work, mate.
02/12/2023 10:39 SubZero**#7
Great work dude keep it up
02/12/2023 10:41 ssorpeg#8
You're amazing, thank you.
02/12/2023 18:18 Ferpa_#9
great work
02/12/2023 19:44 srothanglong#10
wow! good bro :lul:
02/15/2023 05:18 Sukuna1993#11
good job
02/15/2023 14:55 ZeonNETWORK#12
after these years and i still treat g_RStateMgr as g_pd3dDevice!
am i missing alot :D?
02/19/2023 11:54 kotsh23#13
waiting The biggest release :(
The in side client browser <3

Hope you help us soon and release it
Thank you for your GREAT WORK
you one of the legends of Silkroad Developers like Florine and pushedx
02/20/2023 06:08 kyuubi09#14
Just want to notice you, this release will only works on vSRO188,
In newer clients like cSRO, vSRO274, iSRO, etc they are using anewer map than vsro188.
Code:
CNIFWorldMapRenderPanel
CNIFWorldMapView
CNIFWorldMapViewBottomBox
CNIFWorldMapViewBtnHandler
CNIFWorldMapViewGuide
CWorldMap_DungeonMapInfo
CWorldMap_InstanceInfo
CWorldMap_LocalInfo
CWorldMap_MapInfo
CWorldMapDungeonColleague
CWorldMapFieldColleague
CWorldMapFortressNPCColleague
CWorldMapGuideData
CWorldMapGuideDataManager
CWorldMapLocalColleague
CWorldMapPlayerColleague
CWorldMapQuestNPCColleague
CWorldMapSkillPointColleague
CWorldMapViewController
CWorldMapViewer
IWorldMapViewerEventListener
[vSRO188 is using CNIFWorldMap.
What is the diffreent? The new map is rewrited and its just got improved from leaked memrey and the render codes are got sorted CNIFWorldMapView is the interface continer and CWorldMapViewer CNIFWorldMapRenderPanel who doing the renders stuff.
So if u want to render custom stuff in the world map it will be complex to find the funcs and do yours.
02/21/2023 21:51 T0o0P#15
Nice Keep