• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Usewith bugged on 7.4 (creature missing on battle and self using)

slimow4s

Member
Joined
Aug 27, 2012
Messages
59
Reaction score
5
Hi, I would like to disable battle for player shooting on 7.7, can you help me?

The stock otclient version for 7.7 comes with an issue that you can't use anything with crosshair on you, like mana fluids. To fix that I found a solution using this
Code:
    else(toThing->isCreature() && g_game.getClientVersion() >= 860)
instead this
Code:
    else(toThing->isCreature()
on game.cpp of otclient, and it works. But I don't know why, it gets the second issue: shooting runes on creatures using battle misses the creature sometimes. Than I found this commit Fixed problem with function "useWith" on creatures by EgzoT · Pull Request #874 · edubart/otclient (https://github.com/edubart/otclient/pull/874) on github and I saw that the function that I have deactivated with >860 code was the solution for battle miss.

Is there anyway to get battle working again? I found this code on DemonicaOT for usewith, but it doenst compile because g_window is not recognized.

Code:
void Game::useWith(const ItemPtr& item, const ThingPtr& toThing)
{
    if (!canPerformGameAction() || !item || !toThing)
        return;

    Position pos = item->getPosition();

    if (!pos.isValid()) // virtual item
        pos = Position(0xFFFF, 0, 0); // means that is a item in inventory

    UIWidgetPtr clickedWidget = g_ui.getRootWidget()->recursiveGetChildByPos(g_window.getMousePosition(), false);
    if (clickedWidget->getStyleName() == "BattleButton") {
#if defined(HOTKEYS)
        m_protocolGame->sendUseOnCreature(pos, item->getId(), item->getStackPos(), toThing->getId());
#else
        if (toThing->isPlayer())
            g_lua.callGlobalField("g_game", "onTextMessage", 19, "You are not allowed to shoot directly on players.");
        else
            m_protocolGame->sendUseOnCreature(pos, item->getId(), item->getStackPos(), toThing->getId());
#endif
    }
    else {
        if (toThing->isPlayer() || toThing->isItem())
            m_protocolGame->sendUseItemWith(pos, item->getId(), item->getStackPos(), toThing->getPosition(), toThing->getId(), toThing->getStackPos());
        else
            m_protocolGame->sendUseOnCreature(pos, item->getId(), item->getStackPos(), toThing->getId());
    }
}
 
Back
Top