Tried done it my self but don't have enough knowledge to make it work (you can use it as idea)
local function getMonstersInFrontNew(width,length)
if not g_game.isOnline() then return end
local width = 2
local length = 5
local MonstersInRange = 0
local direction = g_game.getLocalPlayer():getDirection()
if direction == 0 then
local width = width
local length = -length
end
if direction == 1
local width = length
local length = width
end
if direction == 2
local width = width
local length = length
end
if direction == 3 then
local width = length
local length = -width
end
for _, creature in pairs(g_game.getCreatures()) do
if creature:isMonster() and creature:getPosition():isInRange(g_game.getLocalPlayer():getPosition(), length, width) then
MonstersInRange = MonstersInRange + 1
end
return MonstersInRange
end
end
Tried also without success
local function getMonstersIn6x3beam()
if not g_game.isOnline() then return end
if not g_game.isAttacking() or not g_game.getAttackingCreature() then return 0 end
local direction = g_game.getLocalPlayer():getDirection()
local MonstersInRange = 0
local monsters = 0
posN = [[
000000000000000
000000111000000
000000111000000
000000111000000
000000111000000
000000111000000
000000111000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
]]
posW = [[
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
011111100000000
011111100000000
011111100000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
]]
posE = [[
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000001111110
000000001111110
000000001111110
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
]]
posS = [[
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000000000000
000000111000000
000000111000000
000000111000000
000000111000000
000000111000000
000000111000000
000000000000000
]]
local monsters = 0
if direction == 0 then
actualdirection = posW
monsters = getCreaturesInArea(pos(), posW, 3)
end
if direction == 1 then
actualdirection = posN
monsters = getCreaturesInArea(pos(), posN, 3)
end
if direction == 2 then
actualdirection = posE
monsters = getCreaturesInArea(pos(), posE, 3)
end
if direction == 3 then
actualdirection = posS
monsters = getCreaturesInArea(pos(), posS, 3)
end
local target = g_game.getLocalPlayer()
local creatures = g_game.getCreatures()
for k, v in pairs(creatures) do
if v:isMonster() and v:getPosition():isInRange(target:getPosition(), actualdirection, 3) then
MonstersInRange = MonstersInRange + 1
end
end
return MonstersInRange
end
g_game.talk(getMonstersIn6x3beam())
auto(5000)
and
local function getMonstersInFront3x6()
if not g_game.isOnline() then return end
local offsetX1 = 0
local offsetY1 = 0
local offsetX2 = 0
local offsetY2 = 0
local MonstersInRange = 0
if direction == 0 then
offsetX1 = -2
offsetX2 = -5
end
if direction == 1 then
offsetY1 = 2
offsetY2 = 5
end
if direction == 2 then
offsetX1 = 2
offsetX2 = 5
end
if direction == 3 then
offsetY1 = -2
offsetY2 = -5
end
for _, creature in pairs(g_game.getCreatures()) do
if creature:isMonster() and creature:getPosition():isInRange({x = g_game.getLocalPlayer():getPosition().x + offsetX1, y = g_game.getLocalPlayer():getPosition().y + offsetY1, z = g_game.getLocalPlayer():getPosition().z}, 1, 1) then
MonstersInRange = MonstersInRange + 1
end
end
for _, creature in pairs(g_game.getCreatures()) do
if creature:isMonster() and creature:getPosition():isInRange({x = g_game.getLocalPlayer():getPosition().x + offsetX2, y = g_game.getLocalPlayer():getPosition().y + offsetY2, z = g_game.getLocalPlayer():getPosition().z}, 1, 1) then
MonstersInRange = MonstersInRange + 1
end
end
return MonstersInRange
end
g_game.talk(getMonstersInFront3x6())
auto(1000)