Hello, i found this request:
And i gave it a try, also got help from @Dalkon
One problem which i couldn't figure it out, was that how to make it not attack players, now it wont attack player but it will steer on the player. It wants to attack it, but there is a line which prevent it. But i would like to cancel it from even checking on the player, but if there is a monster on the screen it will directly switch focus to the monster instead of the player. Feel free if you have any idea.
Add it on creaturescript:
And here is a example how to register it:
And i gave it a try, also got help from @Dalkon
One problem which i couldn't figure it out, was that how to make it not attack players, now it wont attack player but it will steer on the player. It wants to attack it, but there is a line which prevent it. But i would like to cancel it from even checking on the player, but if there is a monster on the screen it will directly switch focus to the monster instead of the player. Feel free if you have any idea.
Add it on creaturescript:
Code:
<event type="think" name="aA" script="autoAttack.lua"/>
Code:
function onThink(cid, interval)
local monster = Monster(cid)
if monster ~= nil then
local targets = monster:getTargetList()
local currentTarget = monster:getTarget()
if not currentTarget then
return monster:searchTarget()
end
if currentTarget ~= nil then
for i = 1, #targets do
local target = targets[i]
if target:isPlayer() then
monster:addFriend(target)
monster:removeTarget(target)
end
end
local newTarget = monster:getTargetList()[1]
monster:setTarget(newTarget)
monster:setFollowCreature(newTarget)
end
end
return true
end
And here is a example how to register it:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local monster = doSummonCreature("Rattata", getPlayerPosition(cid))
doConvinceCreature(cid, monster)
registerCreatureEvent(monster, "aA")
return true
end