how about making a monster that behaves passively, like sheep, until it is attacked, then it turns hostile to only those who attacked it?
is it possible with creaturescripts?
- - - Updated - - -
I was thinking of something like this
is it possible with creaturescripts?
- - - Updated - - -
I was thinking of something like this
Lua:
local targetlist = {n=0}
local hostile = false
local lasthitcreature = 0
local target = 0
function onThink(cid, interval)
local m = getLastHitCreature(cid)
if m ~= lasthitcreature then
lasthitcreature = m
if not targetlist[m] then
if targetlist.n == 0 then
target = m
end
targetlist[m] = true
targetlist.n = targetlist.n+1
end
end
if not hostile and targetlist.n > 0 then
cleartargetlist(cid)
setneutral(cid, true) --neutral means it wont add
sethostile(cid, true)
hostile = true
for k,v in pairs(targetlist) do
doMonsterAddtoTargetList(cid,k)
end
elseif hostile and targetlist.n == 0 then
sethostile(cid, false)
hostile = false
end
if targetlist.n > 0 then
if not isCreature(target) then --to know if it is alive
targetlist[target] = nil
targetlist.n = targetlist.n-1
target = getMonsterTarget(cid)
end
end
end