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

Feature [0.2.4+/0.3.4+]NG/Elf Lookbot detection

Evil Hero

Legacy Member
TFS Developer
Joined
Dec 12, 2007
Messages
1,256
Solutions
28
Reaction score
728
Location
Germany
Hello there!

Note! This code was tested on tfs 0.2.4+

Information:
This code detects people which use the well known feature from NG, which calculates Players/Monsters health points by spamming the look package from client to the server.

If a player is suspicious, there'll popup a message in your console/gui ("Anti Bot: is suspecting Evil Hero of using a bot.")
don't worry, you don't have to watch your console/gui always.
It'll also be saved in your logs/otadmin.txt file, after the message was send 3x to the console/gui.

If there are still questions about it, feel free to ask.
I'm also taking suggestions to improve the entire system, since it's pretty basic for now.

Implementation:

Player.cpp:

after
Code:
nextStepEvent = 0;

add this
Code:
//NG Lookbot detection, made by: Evil Hero and Nicaw
	lastLookTime = OTSYS_TIME() / 1000;
	lookCount = 0;
	lookCount2 = 0;

goto the bottom of the file and add this
Server version 0.2.4+
Code:
//NG Lookbot detection, made by: Evil Hero and Nicaw
void Player::onLookAt(const Position pos)
{
     if(lookCount2 > 3) 
     {
          Logger* logger = Logger::getInstance();
          logger->logMessage(NULL, LOGTYPE_WARNING, 0,getName() + " is suspected of using a lookbot.", NULL);
          lookCount2 = -1;
     }
     if(lookCount2 == -1) 
         return;
     
     lookCount++;
     if(lookCount > 100) 
     {
         std::cout << "Anti Bot: is suspecting " << getName() << " of using a bot." << std::endl;
         //<< (OTSYS_TIME() / 1000 - lastLookTime) << " seconds." << std::endl;
         //so if this time is too low player is suspicious
         if( (OTSYS_TIME() / 1000 - lastLookTime) < 55 ) 
         {
             lookCount2++;
         }
         
         lookCount = 0;
         lastLookTime = OTSYS_TIME() / 1000;
     }
}

Server version 0.3.4+
Code:
//NG Lookbot detection, made by: Evil Hero and Nicaw
void Player::onLookAt(const Position pos)
{
     if(lookCount2 > 3) 
     {
          Logger* logger = Logger::getInstance();
	  logger->eFile("admin.txt", getName() + " is suspected of using a lookbot.", true);
          lookCount2 = -1;
     }
     if(lookCount2 == -1) 
         return;
     
     lookCount++;
     if(lookCount > 100) 
     {
         std::cout << "Anti Bot: is suspecting " << getName() << " of using a bot." << std::endl;
         //<< (OTSYS_TIME() / 1000 - lastLookTime) << " seconds." << std::endl;
         //so if this time is too low player is suspicious
         if( (OTSYS_TIME() / 1000 - lastLookTime) < 55 ) 
         {
             lookCount2++;
         }
         
         lookCount = 0;
         lastLookTime = OTSYS_TIME() / 1000;
     }
}

Code:
#include "textlogger.h"

Player.h:

after
Code:
bool hasLearnedInstantSpell(const std::string& name) const;

add this
Code:
//NG Lookbot detection, made by: Evil Hero and Nicaw
		void onLookAt(const Position pos);

after
Code:
uint32_t lastIP;

add this
Code:
//NG Lookbot detection, made by: Evil Hero and Nicaw
		uint32_t lastLookTime;
		uint16_t lookCount;
		int16_t lookCount2;

Game.cpp:

search for the function
Code:
bool Game::playerLookAt(uint32_t playerId, const Position& pos, uint16_t spriteId, uint8_t stackPos)

after
Code:
Player* player = getPlayerByID(playerId);
	if(!player || player->isRemoved())
		return false;

add this
Code:
//NG Lookbot detection, made by: Evil Hero and Nicaw
	player->onLookAt(pos);

If you use 0.3.4+ then add this!

Textlogger.cpp:

Code:
#include "player.h"


Now we are done.

kind regards, Evil Hero.
 
Last edited:
Thanks for the comments so far.

I'll post the version for 0.3.4+ later on.
:peace:

kind regards, Evil Hero
 
how to check whether the code works?
(- What should be included in the Ng "Creature Spy" ?)
 
how to check whether the code works?
(- What should be included in the Ng "Creature Spy" ?)

I can't really remember what it was exactly called (kinda long ago, since I've lastly used NG).


kind regards, Evil Hero.
 
Last edited:
I'm kinda sure that you've missunderstood what this thread is about.
It's not giving your ng a nice new feature, it helps people who host servers to detect people using it.


kind regards, Evil Hero.

I'm kinda sure that you've missunderstood what he is asking.
He wanted to know how to check if this code works (what to enable in ng to make it log the users).
 
I'm kinda sure that you've missunderstood what he is asking.
He wanted to know how to check if this code works (what to enable in ng to make it log the users).

dumb me, hehe ^^

The way he was asking was not really clear to me, sounded like he wants to know what will be added by that code in ng.

but thanks for clearing my mind :p
 
I'm kinda sure that you've missunderstood what he is asking.
He wanted to know how to check if this code works (what to enable in ng to make it log the users).

NG and Elf both send look packets erratically at other players in order to get their vocation and level. Thats what this checks.
 
I've added the 0.3.4+ version, check the first post.


kind regards, Evil Hero.
 
Back
Top