Salvaging with GWCA

02/01/2020 23:42 havochavoc2#1
I tried implementing a salvage tool in GWCA, but i guess it doesn't really support it. Does anyone know how to start a salvage with it? Should it work with a packet?
02/02/2020 04:20 list comprehension#2
So the general flow is something like this:

check loading for in town, explorable, or loading screen

White or blacklist of items you want to salvage

Confirm player is alive

base ptr->player->bag->slot to get info such as modelid for the target salvage and if stackable, this means iterate over the bags and slots

Follow that same pointer chain to find if you have the specific salvage kit you want to use and get the data, this means iterate over the bags and slots

Record the location of salvage kit and item you want to salvage in a struct or other method.

start a salvage session from the local client function

make sure the item based on the previous iterations isn't null

then take the packet header, item ID, Salvagekit ID, and salvage session ID and send a packet with the header indicating a salvage with that data.
02/02/2020 18:19 havochavoc2#3
Thanks for the help!

Quote:
Originally Posted by list comprehension View Post

start a salvage session from the local client function
I think this is what's missing but I don't know how to get the function. With a pattern i guess?

This is what I have at the moment, it kicks you to the character select screen. The problem is definately the first packet.

Code:
void SalvageForMaterials(GW::Item* item) {
    if (item == nullptr) return;
    GW::Item* salvage_kit = GW::Items::GetItemByModelId(2992);
    if (salvage_kit == NULL) return;
    uint32_t salvage_session_id = GW::GameContext::instance()->world->salvage_session_id;
    uint32_t salvage_kit_id = salvage_kit->item_id;
    uint32_t item_id = item->item_id;
    GW::GameThread::Enqueue([item_id, salvage_kit_id, salvage_session_id] {GW::CtoS::SendPacket(0x10, 0x7D, item_id, salvage_kit_id, salvage_session_id);});
    RndSleep(500);
    if (GetRarity(item) == RARITY_GOLD || GetRarity(item) == RARITY_PURPLE) {
        GW::GameThread::Enqueue([] {GW::CtoS::SendPacket(0x4, 0x80);});
        RndSleep(1000);
    }
}
02/03/2020 08:41 3vangelist#4
GWA2's salvage function hooked into a method that does more than just send the packet as you're doing here. GWCA doesn't have this method hooked because none of the projects that depend on it use automated salvaging.

Also your packet content is in the wrong order, 500ms won't guarantee a response, 1000ms won't guarantee your salvage is complete, and blue items may also have upgrades to salvage.
02/07/2020 23:42 Zvend#5
as 3vangelist said. GWA2 hooks a function. with c++ u can call the function directly. so u dont need a hook. u just need to care about a few things. u will need 2 patterns to be able to do so.

u will probably get kicked with code 007 or get a crash when u send a salvage packet for a weapon. thats why some items can be salvaged only into materials.
For weapons u get a packet back from the Gameserver, which contains the the array of the mods.
So if you send the salvage packet for a weapon, then u get some packets back, where ur client cannot handle it, bcs it was not prepared for the incoming packets.
you will need to prepare a few things clientside before sending the final packet for weapon salvaging. Thats why GWA2 hooked the function, which also sends the right packet. There is a workaround for that where u block the incoming packets and just send the salvage packet. but thats nasty and will only update the inventory when changing the map and will also probably crash when the bot tries to do sth with the item or the invisible items u got through the salvage.

Quote:
Also your packet content is in the wrong order, 500ms won't guarantee a response, 1000ms won't guarantee your salvage is complete, and blue items may also have upgrades to salvage.
you will probably want to wait for the incoming packet which tells ur client that u successfully salvaged. so working with GStoC is probably ur way to go too.
02/08/2020 20:04 phat34#6
they obviously want to get salvaging working with something so they can get it fixed in gwa2... not a bad plan!