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

Source's custom OT game engine (TypeScriptFTW)

Boy67

Intermediate OT User
Joined
Jul 4, 2007
Messages
303
Solutions
12
Reaction score
125
Location
England
So yes, monsters on the whole map move around without players (as I understand).
So, with 10,000 monsters all executing random movements, including executing to check if a tile is walkable. That is very bad logic and a huge cost.

And if you're looking for a shortest path algorithm to find the nearest target, I made my own version based on Dijkstra's shortest path algorithm. His method is probably one of the best.

Anyway, I wish you the best of luck with your development. I was also at your stage testing out stuff and trying to reinvent the wheel, but sometimes the most efficient ways already exist and I'm sure you will figure that out, but keep it up :)
 
OP
OP
Source

Source

Well-Known Member
Joined
May 31, 2020
Messages
97
Reaction score
93
Location
OpenTibia .dev
GitHub
source61
Implemented gameGetCreatures(...) today, took it for a spin and compared it with TFS.

TFS
cHk4HtK.png


TSS
pi8Lq1l.png


Quick reference for all your questions:
  1. Yes, it's multifloor.
  2. Yes, I made sure to test that it actually get surrounding creatures, on all floors, in 18x14 squares.
  3. Yes, the code on both sides is basic.
  4. Yes, both sides had an equal amount of creatures on screen.
  5. And sure, higher numbers are better, whatever you say hehe.

Here's the full code of the script I used on TFS side (same code I used for event benchmark with that part commented out):
Code:
local counter = 0
local start
local range
local mode = 'seq'
--local mode = 'par'

function onSay(player, words, param)
	print("/bench was called")
	start = getMicrotime()
	getSpec(player)
--	range = 10000
--	if mode == 'seq' then
--		addEvent(callback, 0)
--	else
--		for i=1,range do
--			addEvent(callback, 0)
--			--callback()
--		end
--	end
end

function getSpec(player)
	-- centerPos, rangex, rangey, multifloor, onlyPlayers
	spectators = getSpectators(player:getPosition(), 18, 14, true, false)
	print(string.format("Time elapsed: %fµs", (getMicrotime()-start)*1000000))
end

function callback()
	counter = counter + 1
	--print(counter)
	--print(time, count)
	if counter >= range then
	--	addEvent(callback, 0.1, start, count+1)
	--else
		print(string.format("Counter: %d. Time elapsed: %fms", counter, (getMicrotime()-start)*1000))
		counter = 0
	elseif mode == 'seq' then
		addEvent(callback, 0)
	end
end
 
Top