• 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!

Target runes rules

chucky91

Active Member
Joined
Apr 8, 2010
Messages
78
Reaction score
35
Before compiling nostalrius 7.72, i wanted to change the way of striking runes on players, as the rule 7.4. runes only attack in the battle list for monsters.
can someone help me where i change this cpp or client?
 

Terotrificy

Active Member
Joined
Oct 18, 2020
Messages
155
Solutions
5
Reaction score
44
Location
Santiago, Chile.
Hello, i has that issue and just 1 guy gave me hints of where i could fix it, finally i managed to make it work as 7.4 pvp system through the server side, although i'm using Othire 1.0, maybe it works the same for you.

The answer is in this thread i made some time ago: Otclient runes target behaviour in stack (uh trap) (https://otland.net/threads/otclient-runes-target-behaviour-in-stack-uh-trap.274392/#post-2643076)

If it works for your distro then mark it as the correct answer, maybe can be helpful for ppl using your distro too.

Edit: I noticed you're looking also for aim runes only with crosshair in players, that's in the client side, you must look in the game.cpp of the compiler and gameinterface.lua of your client folder.

Looking at the 7.72 otclient, you should add something like this:

game.ccp:


Lua:
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 an item in inventory

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

gameinterface.lua:


Code:
function onUseWith(clickedWidget, mousePosition)
  if clickedWidget:getClassName() == 'UIGameMap' then
    local tile = clickedWidget:getTile(mousePosition)
    if tile then
      if selectedThing:isFluidContainer() or selectedThing:isMultiUse() then
        g_game.useWith(selectedThing, tile:getTopMultiUseThing())
      else
        g_game.useWith(selectedThing, tile:getTopUseThing())
      end
    end
  elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
    g_game.useWith(selectedThing, clickedWidget:getItem())
  elseif clickedWidget:getClassName() == 'UICreatureButton' then
    local creature = clickedWidget:getCreature()
    if creature then
      if creature:isPlayer() then
        modules.game_textmessage.displayFailureMessage('You are not allowed to shoot directly on players.')
      else
        g_game.useWith(selectedThing, creature)
      end
    end
  end
end
 
Last edited:

FeLiPe-Eduardo

New Member
Joined
Jun 3, 2015
Messages
33
Solutions
1
Reaction score
3
game.ccp:


Lua:
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 an item in inventory

UIWidgetPtr clickedWidget = g_ui.getRootWidget()->recursiveGetChildByPos(g_window.getMousePosition(), false);
if (clickedWidget->getStyleName() == "BattleButton") {
if (toThing->isPlayer()) {
g_lua.callGlobalField("g_game", "onTextMessage", 19, "You are not allowed to shoot directly on players.");
} else {
m_protocolGame->sendUseItemWith(pos, item->getId(), item->getStackPos(), toThing->getPosition(), toThing->getId(), toThing->getStackPos());
}
} else {
m_protocolGame->sendUseItemWith(pos, item->getId(), item->getStackPos(), toThing->getPosition(), toThing->getId(), toThing->getStackPos());
}
}
It did not work on TFS1.3. is it possible to adapt this to version 1.3?

zgJPiMv.png

FLP
 

4Nathu4

valoria.online
Joined
Oct 27, 2009
Messages
226
Solutions
8
Reaction score
126
GitHub
4mrcn4
The solution has been posted in this thread by @Terotrificy.
To clear this out, the issue is client-side and there is no reason to edit/send over the server files.

Just substitute your onUseWith function in modules/game_interface/gameinterface.lua with
Lua:
function onUseWith(clickedWidget, mousePosition)
  if clickedWidget:getClassName() == 'UIGameMap' then
    local tile = clickedWidget:getTile(mousePosition)
    if tile then
      if selectedThing:isFluidContainer() or selectedThing:isMultiUse() then
        g_game.useWith(selectedThing, tile:getTopMultiUseThing())
      else
        g_game.useWith(selectedThing, tile:getTopUseThing())
      end
    end
  elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
    g_game.useWith(selectedThing, clickedWidget:getItem())
  elseif clickedWidget:getClassName() == 'UICreatureButton' then
    local creature = clickedWidget:getCreature()
    if creature then
      if creature:isPlayer() then
        modules.game_textmessage.displayFailureMessage('You are not allowed to shoot directly on players.')
      else
        g_game.useWith(selectedThing, creature)
      end
    end
  end
end
 

FeLiPe-Eduardo

New Member
Joined
Jun 3, 2015
Messages
33
Solutions
1
Reaction score
3
Send me your whole game.cpp and game.h

Download link : Option 1 --- Option 2(discord)

by code:

game.cpp : https://pastebin.com/Ye5rJgfr

game.h : game.h - Pastebin.com (https://pastebin.com/t7eFXJwf)


The solution has been posted in this thread by @Terotrificy.
To clear this out, the issue is client-side and there is no reason to edit/send over the server files.

Just substitute your onUseWith function in modules/game_interface/gameinterface.lua with
Lua:
function onUseWith(clickedWidget, mousePosition)
  if clickedWidget:getClassName() == 'UIGameMap' then
    local tile = clickedWidget:getTile(mousePosition)
    if tile then
      if selectedThing:isFluidContainer() or selectedThing:isMultiUse() then
        g_game.useWith(selectedThing, tile:getTopMultiUseThing())
      else
        g_game.useWith(selectedThing, tile:getTopUseThing())
      end
    end
  elseif clickedWidget:getClassName() == 'UIItem' and not clickedWidget:isVirtual() then
    g_game.useWith(selectedThing, clickedWidget:getItem())
  elseif clickedWidget:getClassName() == 'UICreatureButton' then
    local creature = clickedWidget:getCreature()
    if creature then
      if creature:isPlayer() then
        modules.game_textmessage.displayFailureMessage('You are not allowed to shoot directly on players.')
      else
        g_game.useWith(selectedThing, creature)
      end
    end
  end
end

I'm using client 12.64 I didn't find any file with the name: gameinterface.lua

FLP
 

Attachments

4Nathu4

valoria.online
Joined
Oct 27, 2009
Messages
226
Solutions
8
Reaction score
126
GitHub
4mrcn4
I'm using client 12.64 I didn't find any file with the name: gameinterface.lua
12.64 is a protocol version and tells nothing about the fact if you are using otc or retail.
I think you didn't understand this yet, the issue is client-side, your server cannot tell if you sent 0xA1 after clicking on battle or not.
 

Pox

Well-Known Member
Joined
Apr 28, 2020
Messages
126
Solutions
7
Reaction score
87
Top