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

Spell Refill your empty vials! [0.2]

Znote

<?php echo $title; ?>
Staff member
Global Moderator
Premium User
Joined
Feb 14, 2008
Messages
7,030
Solutions
256
Reaction score
2,117
Location
Norway
GitHub
Znote
edit1 2009: This here was one of my first scripts that I created, with lots of help from other scriptwriters.
Funny to see it still working :D
Still compatible with at least TFS 0.2 Mystic Spirit.

Greetings
I would like to thank Nahruto <3<3<3 right ahead for making me the correct script setup, so I could easily make this possible. Thanks in advance!

WTF is this?
I will show you how to create scripts so you can refill empty vials, for an example, you drink a health potion, and if you a knight, you can sacrifice some of your health points, to refill that empty vial to a health potion again.

To refill a health potion you need to have xxx hp, since you need to sacrifice some of it.
You need to hold the potion in your hand to refill it.

To refill a mana potion you need to have xxx mana, since you need to sacrifice some of it.
You need to hold the potion in your hand to refill it.

To refill a Great Spirit Potion (that gives both hp and mana when drink)
You need to hold a hp potion in your hand, and a manapotion in your other hand.

FAQ:
It cost more hp to refill a potion than what it cost to use it.
It cost more mana to refill a potion than what it cost to use it.

kk, lets getting started:
Open data/spells/spells.xml
search for
Code:
<instant name=
You will find spells under the "instant" catogory, between and end and start tag add this:

PHP:
	<instant name="Refill Health Potion" words="exevo hopa" lvl="1" mana="0" aggressive="0" selftarget="1" exhaustion="1000" needlearn="0" script="support/hp.lua">
		<vocation name="Paladin"/>
		<vocation name="Knight"/>
		<vocation name="Royal Paladin"/>
		<vocation name="Elite Knight"/>
	</instant>
	<instant name="Refill great Health Potion" words="exevo gran hopa" lvl="1" mana="0" aggressive="0" selftarget="1" exhaustion="1000" needlearn="0" script="support/ghp.lua">
		<vocation name="Paladin"/>
		<vocation name="Knight"/>
		<vocation name="Royal Paladin"/>
		<vocation name="Elite Knight"/>
	</instant>
	<instant name="Refill strong Health Potion" words="exevo mas hopa" lvl="1" mana="0" aggressive="0" selftarget="1" exhaustion="1000" needlearn="0" script="support/shp.lua">
		<vocation name="Knight"/>
		<vocation name="Elite Knight"/>
	</instant>

Then search after
Code:
<conjure name

You will find spells under the "conjure" category, between and end and start tag add this:

PHP:
	<conjure name="Refill mana Potion" words="exevo manera" reagentId="7636" conjureId="7620" aggressive="0" conjureCount="1" maglv="0" mana="175" soul="0" prem="0" enabled="1" function="conjureRune">
		<vocation name="Sorcerer"/>
		<vocation name="Druid"/>
		<vocation name="Paladin"/>
		<vocation name="Master Sorcerer"/>
		<vocation name="Elder Druid"/>
		<vocation name="Royal Paladin"/>
	</conjure>
	<conjure name="Refill strong mana Potion" words="exevo gran manera" reagentId="7634" conjureId="7589" aggressive="0" conjureCount="1" maglv="0" mana="250" soul="0" prem="0" enabled="1" function="conjureRune">
		<vocation name="Druid"/>
		<vocation name="Paladin"/>
		<vocation name="Elder Druid"/>
		<vocation name="Royal Paladin"/>
	</conjure>
	<conjure name="Refill great mana Potion" words="exevo mas manera" reagentId="7635" conjureId="7590" aggressive="0" conjureCount="1" maglv="0" mana="425" soul="0" prem="0" enabled="1" function="conjureRune">
		<vocation name="Druid"/>
		<vocation name="Elder Druid"/>
	</conjure>

Then save the spells.xml document.


enter data\spells\scripts\support and create hp.lua
PHP:
local req = 7636
local hp = 330
local new = 7618


local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)

function onCastSpell(cid, var)
local h1 = getPlayerSlotItem(cid, 5)
local h2 = getPlayerSlotItem(cid, 6)
	if getCreatureHealth(cid) >= hp then
		if h1.itemid == req then
			doCreatureAddHealth(cid, -hp)
			doTransformItem(h1.uid, new)	
			doCombat(cid, combat, var)
		elseif h2.itemid == req then
			doCreatureAddHealth(cid, -hp)
			doTransformItem(h2.uid, new)	
			doCombat(cid, combat, var)
		else
			doPlayerSendCancel(cid, "You need to put a empty potion in your hand")
		end
	else
		doPlayerSendCancel(cid, "You need more HP than 330 to refill this potion.")
	end
end

Then create a lua file and call it shp.lua
PHP:
local req = 7634
local hp = 800
local new = 7588


local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)

function onCastSpell(cid, var)
local h1 = getPlayerSlotItem(cid, 5)
local h2 = getPlayerSlotItem(cid, 6)
	if getCreatureHealth(cid) >= hp then
		if h1.itemid == req then
			doCreatureAddHealth(cid, -hp)
			doTransformItem(h1.uid, new)	
			doCombat(cid, combat, var)
		elseif h2.itemid == req then
			doCreatureAddHealth(cid, -hp)
			doTransformItem(h2.uid, new)	
			doCombat(cid, combat, var)
		else
			doPlayerSendCancel(cid, "You need to put a empty strong potion in your hand")
		end
	else
		doPlayerSendCancel(cid, "You need more HP than 800 to refill this potion.")
	end
end

Then create a lua file and call it ghp.lua
PHP:
local req = 7635
local hp = 1300
local new = 7591


local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)

function onCastSpell(cid, var)
local h1 = getPlayerSlotItem(cid, 5)
local h2 = getPlayerSlotItem(cid, 6)
	if getCreatureHealth(cid) >= hp then
		if h1.itemid == req then
			doCreatureAddHealth(cid, -hp)
			doTransformItem(h1.uid, new)	
			doCombat(cid, combat, var)
		elseif h2.itemid == req then
			doCreatureAddHealth(cid, -hp)
			doTransformItem(h2.uid, new)	
			doCombat(cid, combat, var)
		else
			doPlayerSendCancel(cid, "You need to put a empty great potion in your hand")
		end
	else
		doPlayerSendCancel(cid, "You need more HP than 1300 to refill this potion.")
	end
end

If you don't bother restarting your server, you don't have to, say /reload spells in game and it should be set. Now this should fully working.

Note that this is not the new 8.11 healing potion and spirit potion, but you will have no problems to copy and extend the potion script to fit for the last potion right? Its very configurable thanks to Nahruto.

If you want to fix the spirit potion, you can base on this script, I don't got time to fix it right ahead, but you can easily do this with changing some ids:

PHP:
local req1 = xxxx --id strong mana potion
local req2 = xxxx --id strong health potion
local hp = 50 -- set how much hp it cost to drink the potion -- to make it also require mana, add some mana cost in spells.xml to launch this spell.
local new = xxxx --id empty vial u get when drinking a strong potion


local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)

function onCastSpell(cid, var)
local h1 = getPlayerSlotItem(cid, 5)
local h2 = getPlayerSlotItem(cid, 6)
	if getCreatureHealth(cid) >= hp then
		if h1.itemid == req1 and h2.itemid == req2 then
			doCreatureAddHealth(cid, -hp)
			doRemoveItem(h1.uid)
			doRemoveItem(h2.uid)
			doPlayerAddItem(cid, new)
		else
			doPlayerSendCancel(cid, "NO ITEM")
		end
	else
		doPlayerSendCancel(cid, "NO HP")
	end
end

Special note:
The mana potions conjure script is made very easily in spells.xml, so it can be abused to magic level fast up without using so much mana, just use the script nahruto made for health potions, but make it take mana instead of hp.

You can easily go based on this script to make any kind of conjures, its very easy to modify, and it might be recommended to make these potions to fit with your potions, the mana cost should always be a little higher than the max amount of mana received when drinking the potion, same goes to health.

You might see the vocations, I made so only Druids could do the greatest mana potion, just to make them a bit more special in ots. You can easily change this to another vocation.

The credits goes to Nahruto. He did the lua scripts, I only changed the ID's and came with this idea.

Compatible:
Tested and works perfectly with the latest versions from TFS in the 0.2 series. I can not guarantee it will work with other distributions.

Any questions just ask, please come with comments and replys, I want to know if you like this or not :p
 
Last edited:
Ye i'll add it to Znote server today :p
 
Seems nice... But I myself would have done like this:

Code:
min = 100
max = 300
health = math.random(min, max)
rem = math.random(30, 60)

doPlayerAddHealth(cid, -(health+rem))
-- transform vial
doSetItemActionid(thevial, health)

And then in normal potion scripts

Code:
health = math.random(min, max) -- this is normal potions, here it randomize how much mana you shall get...
if item.actionid ~= 0 then
    health = item.actionid
    doSetItemActionid(item.uid, 0)
end
doPlayerAddHealth(cid, health)

If you understand :D
 
Ye probaly, but I don't want it to be random, but more exact :p

Also note it was Nahruto who made me that lua setup, im not experienced enough to make something like that myself ^^
 
Its alot easier to tell what to do than to actually do it, believe me, I tryed a sec and was like, wtf this is just messed up. :<
 
Ahh good old days. :) Still handy though ^^
 
data\spells\scripts\support and create gsp.lua
Note that the last code is not finish, so
remember to edit
Lua:
local req1 = xxxx --id strong mana potion
local req2 = xxxx --id strong health potion
local hp = 50 -- set how much hp it cost to drink the potion -- to make it also require mana, add some mana cost in spells.xml to launch this spell.
local new = xxxx --id empty vial u get when drinking a strong potion

with the correct IDs.

And you have to edit spells.xml also

PHP:
    <instant name="Refill Health Potion" words="exevo hopa" lvl="1" mana="250" aggressive="0" selftarget="1" exhaustion="1000" needlearn="0" script="support/gsp.lua">
        <vocation name="Paladin"/>
        <vocation name="Royal Paladin"/>
    </instant>
 
Back
Top