• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Creature that spawns another creature on death [Request]

mike800

New Member
Joined
Mar 9, 2015
Messages
30
Reaction score
1
Hey, I'm looking to learn how to make a creature spawn a new creature when it dies. For example, I could have a ghoul, kill it, and it will spawn a skeleton. I tried using the search function, but couldn't find anything. I'm not good at scripts so if you could explain a little further that would be great.

Edit: It would be nice if it could say something when it dies and the new creature could say something when it spawns.

Thanks in advance
 
You would need to create an onKill event in creaturescripts, sorry but I don't know how to write those :(
 
You would need to create an onKill event in creaturescripts, sorry but I don't know how to write those :(
creaturescripts.lua
Code:
<event type="kill" name="AAAAAAAA" event="script" value="script.lua"/>
login.lua
Code:
registerCreatureEvent(cid, "AAAAAAAA")
script.lua
Code:
local creatureName = 'cave rat' -- creaturename (must be lowercase letters)
local newCreature = 'rat'
local creatureSay = 'I am saying something'

function onKill(cid, target, damage, flags)
   if isPlayer(target) then
     return false
   end
   local name = getCreatureName(target):lower()
   if name ~= creatureName then
     return false
   end
   local position = getCreaturePosition(target)

   -- player says something
   -- doCreatureSay(cid, ''.. creatureSay ..'', TALKTYPE_ORANGE_1)

   -- creature says something
   doCreatureSay(cid, ''.. creatureSay ..'', TALKTYPE_ORANGE_1, false, 0, position)

   -- create monster near the corpse (no delay)
   doCreateMonster(newCreature, position)

   -- create monster on the corpse (very small delay, that may or may not be noticeable to the player, however is noticeable with god on local connection)
   -- addEvent(doCreateMonster, 0, newCreature, position)
   return true
end

-- edit
I meant to reply to this thread like 2 days ago, but I'm sick and really lazy. Dx
-- edit 2
If you want anything changed or added just let us know
 
Last edited by a moderator:
Just want to point something out in your code @Xikini
Code:
local creatureName = 'cave rat' -- creaturename (must be lowercase letters)
Can be upper case it doesn't matter if its CaVe Rat, because you can use just as you did with
Code:
getCreatureName(target):lower()
on creatureName
Code:
creatureName:lower()
and still compare the 2
Code:
local name = getCreatureName(target):lower()
if name ~= creatureName:lower() then
    return false
end
:)
 
Back
Top