sestorme
Member
According to this thread, I am still battling this code:
http://otland.net/f16/lua-monsters-fight-each-other-149734/
For testing purposes I added a talkaction. Entire script is working, it does sendanimatedtext too, just don't make them to attack each other. Any clues?
http://otland.net/f16/lua-monsters-fight-each-other-149734/
Code:
function onSay(cid, words, param, channel)
local challengeMonsters = {
"Wolf Cub",
"Wolf",
"Black Wolf",
"Alpha Wolf",
"Giant Wolf",
"Species Wolf"
}
local challengeZombies = {
"Giant Spider",
"Pancer"
}
local cpos = getCreaturePosition(cid)
local pos = {
[1] = {x=cpos.x-1, y=cpos.y, z=cpos.z, stackpos=253},
[2] = {x=cpos.x-1, y=cpos.y-1, z=cpos.z, stackpos=253},
[3] = {x=cpos.x, y=cpos.y-1, z=cpos.z, stackpos=253},
[4] = {x=cpos.x+1, y=cpos.y, z=cpos.z, stackpos=253},
[5] = {x=cpos.x+1, y=cpos.y+1, z=cpos.z, stackpos=253},
[6] = {x=cpos.x, y=cpos.y+1, z=cpos.z, stackpos=253},
[7] = {x=cpos.x-1, y=cpos.y+1, z=cpos.z, stackpos=253},
[8] = {x=cpos.x+1, y=cpos.y-1, z=cpos.z, stackpos=253}
}
local thing = 0
for i = 1,#pos do
doSendMagicEffect(pos[i], CONST_ME_MAGIC_RED)
local thing = getThingFromPos(pos[i])
if isCreature(thing.uid) then
if isInArray(challengeMonsters,getCreatureName(thing.uid)) then
local cpos = getCreaturePosition(thing.uid)
local pos = {
[1] = {x=cpos.x-1, y=cpos.y, z=cpos.z, stackpos=253},
[2] = {x=cpos.x-1, y=cpos.y-1, z=cpos.z, stackpos=253},
[3] = {x=cpos.x, y=cpos.y-1, z=cpos.z, stackpos=253},
[4] = {x=cpos.x+1, y=cpos.y, z=cpos.z, stackpos=253},
[5] = {x=cpos.x+1, y=cpos.y+1, z=cpos.z, stackpos=253},
[6] = {x=cpos.x, y=cpos.y+1, z=cpos.z, stackpos=253},
[7] = {x=cpos.x-1, y=cpos.y+1, z=cpos.z, stackpos=253},
[8] = {x=cpos.x+1, y=cpos.y-1, z=cpos.z, stackpos=253}
}
local zombie = 0
for i = 1,#pos do
doSendMagicEffect(pos[i], CONST_ME_MAGIC_RED)
local zombie = getThingFromPos(pos[i])
if isCreature(zombie.uid) then
doSendAnimatedText(getCreaturePosition(thing.uid), "Loser!", 180)
doSendAnimatedText(getCreaturePosition(zombie.uid), "Loser!", 180)
if isInArray(challengeZombies,getCreatureName(zombie.uid)) then
doMonsterSetTarget(thing.uid, zombie.uid)
end
end
end
end
end
end
return true
end
For testing purposes I added a talkaction. Entire script is working, it does sendanimatedtext too, just don't make them to attack each other. Any clues?