Description:
It's simple script which allow to catch and summon monster thanks to magic vial.
You need to get item with id 7488 and then use it on the monster. You have some chance to catch and some chance to fail.
When you finally catch the monster you are able to summon it by right clicking of vial and then on ground. If you want monster back just click vial on yourself.
Change log:
Script:
/data/actions/actions.xml
/data/actions/scripts/catch_monster.lua
/data/actions/scripts/summon_monster.lua
Optional function:
/data/creaturescripts/creaturescripts.xml
/data/creaturescripts/scripts/summon_death.lua
Add this to every monster .xml which you want to.
After this:
Add this:
Credits: Me && Knight God
It's simple script which allow to catch and summon monster thanks to magic vial.
You need to get item with id 7488 and then use it on the monster. You have some chance to catch and some chance to fail.
When you finally catch the monster you are able to summon it by right clicking of vial and then on ground. If you want monster back just click vial on yourself.
Change log:
9 May 2012:
- Added new optional function
8 May 2012:
- Added summon exhaust
- Added effect on summon
- Small fixes
6 May 2012:
- Now you can't summon monster in pz
- Can't catch your own summon
5 May 2012:
- Added message on summon monster
- Added min level to catch
Script:
/data/actions/actions.xml
XML:
-
<action itemid="7488" event="script" value="catch_monster.lua"/>
<action itemid="5468" event="script" value="summon_monster.lua"/>
/data/actions/scripts/catch_monster.lua
Lua:
local t = {
percent = 40, -- percent of health which allow to catch a monster
vial = 5468, -- vial which should appear instead empty one.
monsters = {
--['monsterName'] = {min level to catch, chance to catch a monster},
['demon'] = {100, 20},
['troll'] = {10, 50},
['cyclops'] = {30, 70},
['hydra'] = {50, 100}
}
}
function onUse(cid, item, fromPosition, itemEx, toPosition)
local desc = getItemAttribute(item.uid, 'description') == nil and getItemInfo(item.itemid).description or getItemAttribute(item.uid, 'description')
if isMonster(itemEx.uid) then
if t.monsters[getCreatureName(itemEx.uid):lower()] then
if getCreatureHealth(itemEx.uid) <= getCreatureMaxHealth(itemEx.uid) * t.percent / 100 then
local desc = getItemAttribute(item.uid, 'description') == nil and getItemInfo(item.itemid).description or getItemAttribute(item.uid, 'description')
if string.find(desc:lower(), 'catched monster:') == nil then
if getPlayerLevel(cid) < t.monsters[getCreatureName(itemEx.uid):lower()][1] then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You can\'t catch this monster. You are not enough experienced to do it.')
elseif getCreatureMaster(itemEx.uid) == cid then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You can\'t catch your own summon.')
end
if math.random(1, 100) < t.monsters[getCreatureName(itemEx.uid):lower()][2] then
doSendMagicEffect(toPosition, CONST_ME_YALAHARIGHOST)
local newItem = doPlayerAddItem(cid, t.vial, 1)
doItemSetAttribute(newItem, 'description', desc .. ' Catched monster: ' .. getCreatureName(itemEx.uid):lower() .. '.')
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You successful catched ' .. getCreatureName(itemEx.uid):lower() .. '\'s soul into vial.')
doRemoveCreature(itemEx.uid)
else
doSendMagicEffect(toPosition, CONST_ME_GROUNDSHAKER)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You failed at catching monster.')
doRemoveCreature(itemEx.uid)
end
doRemoveItem(item.uid)
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You can\'t catch monster two times into same vial.')
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Creature do not have require low health.')
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You can use it only specific monsters.')
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You can use it only on monsters.')
end
return true
end
/data/actions/scripts/summon_monster.lua
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
local desc = getItemAttribute(item.uid, 'description') == nil and getItemInfo(item.itemid).description or getItemAttribute(item.uid, 'description')
local config = {
storageExhaust = 55668,
exhaustTime = 10,
effect = CONST_ME_HITBYFIRE
}
if exhaustion.check(cid, config.storageExhaust) ~= false then
return doPlayerSendCancel(cid, 'You must wait '..exhaustion.get(cid, config.storageExhaust)..' seconds to use this item again.')
end
if not isCreature(itemEx.uid) then
if string.find(desc:lower(), 'catched monster:') ~= nil then
local x, y = string.find(desc, ': %a+.')
local a, b = string.find(desc, ': %a+ %a+.')
if getTileInfo(getThingPos(cid)).protection then
return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You can\'t summon monster in protection zone.')
end
if a ~= nil then
if #getCreatureSummons(cid) == 0 then
local x = doSummonMonster(cid, string.sub(desc, a + 2, b - 1))
doCreatureSay(cid, 'Go '..string.sub(desc, a + 2, b - 1)..'!', TALKTYPE_MONSTER_YELL)
doSendMagicEffect(getThingPos(x), config.effect)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You summoned monster.')
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You already have summon.')
end
elseif x ~= nil then
if #getCreatureSummons(cid) == 0 then
local x = doSummonMonster(cid, string.sub(desc, x + 2, y - 1))
doCreatureSay(cid, 'Go '..string.sub(desc, x + 2, y - 1)..'!', TALKTYPE_MONSTER_YELL)
doSendMagicEffect(getThingPos(x), config.effect)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You summoned monster.')
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You already have summon.')
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Unknow monster.')
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You didn\'t catch anything into vial.')
end
elseif itemEx.uid == cid then
if #getCreatureSummons(cid) > 0 then
if string.find(desc:lower(), 'catched monster:') ~= nil then
local x, y = string.find(desc, ': %a+.')
if x ~= nil then
for k, v in pairs(getCreatureSummons(cid)) do
if getCreatureName(v):lower() == string.sub(desc, x + 2, y - 1) then
doRemoveCreature(v)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Your summon backed to vial.')
break
end
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'Unknow monster.')
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You didn\'t catch anything into vial.')
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You didn\'t summon anything.')
end
else
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You can summon catched monster if you will use it on tile or, on self if you want to that summon back to vial.')
end
exhaustion.set(cid, config.storageExhaust, config.exhaustTime)
return true
end
Optional function:
Will remove vial (and add empty) with monster soul if your summon dies.
/data/creaturescripts/creaturescripts.xml
XML:
-
<event type="death" name="summonDeath" script="summon_death.lua"/>
/data/creaturescripts/scripts/summon_death.lua
Lua:
function onDeath(cid, corpse, deathList)
if isMonster(cid) then
local x = getCreatureMaster(cid)
if isPlayer(x) then
if getPlayerItemCount(x, 5468) > 0 then
doPlayerRemoveItem(x, 5468, 1)
doPlayerAddItem(x, 7488, 1)
end
end
end
return true
end
Add this to every monster .xml which you want to.
After this:
XML:
-
</flags>
Add this:
XML:
-
<script>
<event name="summonDeath"/>
</script>
Credits: Me && Knight God
Last edited: