• 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!

Action Catch/Summon monster by vial

VirrageS

←•†ĿuĀ && ©¤¤•→
Joined
May 30, 2010
Messages
984
Reaction score
63
Location
Poland
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:

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:
Work perfect i tested on 0.4 :3

Need some adjustments.

* If you've caught the monster, you can't re-capture, I mean, you can't recapture your same monster.
* I would like to say "Go demon", when using the Firebug, depending on which monster you captured.
* When you enter pz, the monster disappears.
* When you're transported to another place, the monster disappears.
* To raise levels depending on how much exp you recieved.
* When level up, get a bit of HP.
 
Last edited:
11:59 You arleady have summon.

I hope to see this script get updated with more functions!
 
* If you've caught the monster, you can't re-capture, I mean, you can't recapture your same monster.
I don't understand. You can re-capture monster to the same vial? Or what?


* When you enter pz, the monster disappears.
* When you're transported to another place, the monster disappears.
I think I will add it later but not sure about trasnported/teleported player.


* To raise levels depending on how much exp you recieved.
* When level up, get a bit of HP.
It's simple script and I don't want to develop it to pet system.


11:59 You arleady have summon.

And how to recall the summon? I hope to see this script get updated!
If you want monster back just click vial on yourself.
 
I don't understand. You can re-capture monster to the same vial? Or what?

Nonono, if you using a vial in you same summon the vial re caputre you summon.

*Need in pz can't summon monster.


You can't catch this monster. You are not enough experienced to do it.

i can't catch monster and i am are level 160 D:!
 
Last edited:
suggestions.

* Remove summon if you go into pz.
* Effect when the captured summon is summoned.
* I can remove the monster with the same item used to summon.

* Added exaust time for summon again by me.

PHP:
---- Catch system by VirrageS
---- Added small edit for exhauste time for summon again by Knight God.

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local exh = 300
	local storage = 50500

	local desc = getItemAttribute(item.uid, 'description') == nil and getItemInfo(item.itemid).description or getItemAttribute(item.uid, 'description')
 	if getPlayerStorageValue(cid, storage) <= os.time() then
	setPlayerStorageValue(cid, storage, os.time() + exh)
	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
					doSummonMonster(cid, string.sub(desc, a + 2, b - 1))
					doCreatureSay(cid, 'Go '..string.sub(desc, a + 2, b - 1)..'!', TALKTYPE_MONSTER_YELL)
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You summoned monster.')
				else
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You arleady have summon.')
				end
			elseif x ~= nil then
				if #getCreatureSummons(cid) == 0 then
					doSummonMonster(cid, string.sub(desc, x + 2, y - 1))
					doCreatureSay(cid, 'Go '..string.sub(desc, x + 2, y - 1)..'!', TALKTYPE_MONSTER_YELL)
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You summoned monster.')
				else
					doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, 'You arleady 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
    else
        	    doPlayerSendCancel(cid, "Your captured monster can not appear that this exhausted, to summon him again you have to wait: ".. getPlayerStorageValue(cid, storage) - os.time() .." seconds.")
        end
	return true
end
 
If Monster Die, We Can Call Him Again Without Problem.
When would be good if the monster died Vial was broken!
 
Thanks because u sold me a similar script then u released a better :D
 
Can You Give Me A Code To Change This!
I Like When Monster Die His Soul Die Together.

Awaiting
 
Like That:

Use The Vial: Summon De The Monster - Vial Back To Normal
Summon Back: Vial Return To Vial With Monster Inside
Monster Die: Vial Back To His Normal Form Without A Monster On It!
 
Like That:

Use The Vial: Summon De The Monster - Vial Back To Normal
Summon Back: Vial Return To Vial With Monster Inside
Monster Die: Vial Back To His Normal Form Without A Monster On It!

Try it and tell me if there will be any errors.

BTW. You know that players will be able to bypass this function: drop item and before summon death, pick up it.
 
Last edited:
Thank You!!!

But, This Little Fail is Breaking My Legs!
;D

How I Can Change This!?
 
Last edited:
Back
Top