nikolai
Althea ¤ A New World Developer
Hello!
Im struggling on getting this code to work.. So, the start of this function is 4x different creatures(not random) summoned when performing an action. What i want this script to do, is to search an area defined in the code, to confirm that all 4 creatures are killed. That is, 1 ghoul, 1 ghost , 1 demon skeleton and 1 skeleton has to be killed to create a teleport. Can't get my head around this.
Im struggling on getting this code to work.. So, the start of this function is 4x different creatures(not random) summoned when performing an action. What i want this script to do, is to search an area defined in the code, to confirm that all 4 creatures are killed. That is, 1 ghoul, 1 ghost , 1 demon skeleton and 1 skeleton has to be killed to create a teleport. Can't get my head around this.
Lua:
local area = {
centerTilePos = Position(558, 744, 7),
tilesToLeft = 5,
tilesToRight = 5,
tilesToTop = 2,
tilesToBottom = 2,
teleportPos = Position(554,745,7)
}
local monsterNames = {"ghoul","ghost","demon skeleton","skeleton",
}
function onKill(cid, target, lastHit)
local targetName = string.lower(getCreatureName(target))
if isMonster(target) and table.contains(monsterNames, targetName) then -- checks if killed thing is monster and monster with right name
local spectators = Game.getSpectators(area.centerTilePos, false, false, 5,5,2,2) -- find every creature in room
for key, creature in pairs(spectators) do
if isMonster(creature) then -- finish script
return true
else
doCreateTeleport(1387, getThingPos(target), area.teleportPos)-- creating teleport at position
end
end
end
return true
end