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

Lua [Advanced] Wolf to attack deer

sestorme

Member
Joined
Dec 9, 2011
Messages
272
Reaction score
6
Location
Birmingham, UK
According to this thread, I am still battling this code:

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?
 
Back
Top