elnelson
Lunaria World Dev
Hello ,otlanders. ive been trying to do something with the function onSpawn, basically i want to modify the spawns of X creatures.
for example:
i have a cave full of rats, but i want to change the creature to a rat_elite onSpawn (after being killed/removed and pass X time), so there is a % chance to spawn a rat_elite instead of a rat (both has same name), i've been trying to make the script but i cant find a way to avoid duplicated spawn (the script its looping continues creating creatures every spawn timer)
this is the script so far:
PD: i've tried placing RETURN FALSE on line 13 to terminate the onSpawn, but the rat still spawning.
Anyone could help me achieve this?
as title says im using OTX 2.X (v7.72)
for example:
i have a cave full of rats, but i want to change the creature to a rat_elite onSpawn (after being killed/removed and pass X time), so there is a % chance to spawn a rat_elite instead of a rat (both has same name), i've been trying to make the script but i cant find a way to avoid duplicated spawn (the script its looping continues creating creatures every spawn timer)
this is the script so far:
Lua:
function onSpawn(cid)
local pos = getCreaturePosition(cid)
if getCreatureName(cid) == "Rat" then
if doCreateMonster('Rat_elite', getClosestFreeTile(cid, pos) then
print("success")
doRemoveCreature(cid) --this suppose to remove the RAT and leave only the RAT_ELITE, but when the creature is removed it continues to loop the spawn until it get 9+ creatures on the same spot and spam errors on console
else
print("fail")
end
end
return true
end
PD: i've tried placing RETURN FALSE on line 13 to terminate the onSpawn, but the rat still spawning.
Anyone could help me achieve this?
as title says im using OTX 2.X (v7.72)