• 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 Buff Spell from Item. Simple script.

Guitar Freak

_LüA_n☺b_
Joined
Dec 27, 2008
Messages
831
Reaction score
13
Location
Caracas, Venezuela
As title says, I just made a simple spell that buffs you adding 20% HP for 20 seconds, but you can ONLY use it if you have 15 "whatever Items" on you (in this case, I used "talons").

So after you say the words for the spell, it checks if you have the 15 talons on you and if you do, it removes them and buffs you.

If you dont, it sends a cancel message telling you that you need 15 talons and it wont buff you nor waste your mana.

Here's the spell, I know its simple but Im just starting on lua scripting so bare with me. I also added comment lines (--) after important lines of the script in case you're learning like me and want to know what's going on or what everything means.

You may aswell use it in your server if you desire or modify it as you wish.

In spells.xml (dont mind about the name or words lol, they're just a reference):

Lua:
	<instant name="Item HP Buff" words="hpbuff" lvl="1" mana="10" aggressive="0" selftarget="1" params="1" exhaustion="2000" needlearn="0" event="script" value="itembuff.lua">
        <vocation name="Druid"/>
	</instant>

Change the name/words/mana/lvl/vocation/etc. to anything you want.

And in itembuff.lua:

Lua:
-- Simple "HP Buff from Item" spell by Guitar Freak.

local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, 39)		-- You can change to any effect you desire.
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, FALSE)

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 20000)					-- Amount of time the buff lasts in miliseconds, so 20000 = 20 seconds.
setConditionParam(condition, CONDITION_PARAM_STAT_MAXHEALTHPERCENT, 120)	-- Amount of HP % added, 100% = Total HP so if you put 120% it adds 20% to the total HP. Putting like 50% cuts your HP to half, etc.
setConditionParam(condition, CONDITION_PARAM_BUFF, TRUE)
setCombatCondition(combat, condition)

function onCastSpell(cid, var)
	if getPlayerItemCount(cid,2151) >= 15 then			-- This line checks if the player has the 15 talons. (2151 is the ItemID of the "talon", but you can change it to whatever you want. The "15" is the amount of talons you need for the buff to work)
		doPlayerRemoveItem(cid, 2151, 15)				-- If he does, it removes the 15 talons and:
		return doCombat(cid, combat, var)				-- Adds the buff, sends the magic effect, etc.
	else												-- Otherwise if he doesnt have 15 talons:
		doPlayerSendCancel(cid, "You do not have enough talons, you need 15 talons to execute this spell.")		-- It sends him this cancel message,
		doSendMagicEffect(getCreaturePos(cid), 2)	-- Also shows this magic effect on the player which is a "puff" to tell the spell didnt work.
	return LUA_ERROR								-- And finally cancels everything so the spell doesnt work, the mana is not spent nor any talons taken, and the player is not buffed.
	end
end

And thats it. Tested and working on TFS 0.3.2 but should work with any other 0.3+ I think.

<----->

As requested by Jixx~, in the following link is this same spell but instead of adding 20% HP, it adds 20% Mana:

http://otland.net/f132/buff-spell-item-simple-script-33781/#post366552

Cheers~
 
Last edited:
Replying to a request.

its possible to druid can buff other players?

Yep, the only thing you need to change is a parameter in spells.xml.

Change:

Lua:
        <instant name="Item HP Buff" words="hpbuff" lvl="1" mana="10" aggressive="0" selftarget="1" params="1" exhaustion="2000" needlearn="0" event="script" value="itembuff.lua">
        <vocation name="Druid"/>
        </instant>

To:

Lua:
        <instant name="Item HP Buff" words="hpbuff" lvl="1" mana="10" aggressive="0" needtarget="1" params="1" exhaustion="2000" needlearn="0" event="script" value="itembuff.lua">
        <vocation name="Druid"/>
        </instant>

So the only thing I did is change the selftarget="1" parameter to needtarget="1" and everything else including the .lua remains the same.

Tested and works :thumbup:

Cheers.
 
Can you make a buff for me?
I want a Regeneration buff that will heal your hp every 1 second and add mana every 1 second for 30 seconds.

Thanks a lot :)
 
Can you make a buff for me?
I want a Regeneration buff that will heal your hp every 1 second and add mana every 1 second for 30 seconds.

Thanks a lot :)

Hey man, well I made the HP buff and its working (heals an X amount every 1 second for 30 seconds, and at the last second it gives a "final hp boost" :p), but the mana one I couldnt get it work, no idea how that one is done :/

Here is the HP one. In spells.xml:

PHP:
<instant name="HP Regen Buff" words="hpregen" lvl="1" mana="10" aggressive="0" selftarget="1" params="1" exhaustion="2000" needlearn="0" event="script" value="hpregen.lua"/>

And in hpregen.lua:

Lua:
-- "HP Regen Buff" spell by Guitar Freak.

local HPregen = createCombatObject()
local HPfinalboost = createCombatObject()

local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, 12)
setCombatParam(combat1, COMBAT_PARAM_AGGRESSIVE, FALSE)
setCombatParam(combat1, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, 1, 0, 1.5, 0)

local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, 39)
setCombatParam(combat2, COMBAT_PARAM_AGGRESSIVE, FALSE)
setCombatParam(combat2, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
setCombatFormula(combat2, COMBAT_FORMULA_LEVELMAGIC, 3, 0, 3.5, 0)

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 2000)
setConditionParam(condition, CONDITION_PARAM_BUFF, TRUE)
setCombatCondition(combat1, condition)

local condition2 = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 1)
setConditionParam(condition2, CONDITION_PARAM_BUFF, FALSE)
setCombatCondition(combat2, condition2)


arr1 = {
	{0, 0, 0},
	{0, 3, 0},
	{0, 0, 0}
}

local area1 = createCombatArea(arr1)

arr2 = {
	{0, 0, 0},
	{0, 3, 0},
	{0, 0, 0}
}

local area2 = createCombatArea(arr2)

setCombatArea(HPregen, area1)
setCombatArea(HPfinalboost, area2)

function onTargetTile(cid, pos)
    doCombat(cid,combat1,positionToVariant(pos))
end

function onTargetTile2(cid, pos)
    doCombat(cid,combat2,positionToVariant(pos))
end

setCombatCallback(HPregen, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
setCombatCallback(HPfinalboost, CALLBACK_PARAM_TARGETTILE, "onTargetTile2")

local function onCastSpell1(parameters)
    doCombat(parameters.cid, HPregen, parameters.var)
end 

local function onCastSpell2(parameters)
    doCombat(parameters.cid, HPfinalboost, parameters.var)
end 

function onCastSpell(cid, var)
local parameters = { cid = cid, var = var}
addEvent(onCastSpell1, 0, parameters)
addEvent(onCastSpell1, 1000, parameters)
addEvent(onCastSpell1, 2000, parameters)
addEvent(onCastSpell1, 3000, parameters)
addEvent(onCastSpell1, 4000, parameters)
addEvent(onCastSpell1, 5000, parameters)
addEvent(onCastSpell1, 6000, parameters)
addEvent(onCastSpell1, 7000, parameters)
addEvent(onCastSpell1, 8000, parameters)
addEvent(onCastSpell1, 9000, parameters)
addEvent(onCastSpell1, 10000, parameters)

addEvent(onCastSpell1, 10000, parameters)
addEvent(onCastSpell1, 12000, parameters)
addEvent(onCastSpell1, 13000, parameters)
addEvent(onCastSpell1, 14000, parameters)
addEvent(onCastSpell1, 15000, parameters)
addEvent(onCastSpell1, 16000, parameters)
addEvent(onCastSpell1, 17000, parameters)
addEvent(onCastSpell1, 18000, parameters)
addEvent(onCastSpell1, 19000, parameters)
addEvent(onCastSpell1, 20000, parameters)

addEvent(onCastSpell1, 21000, parameters)
addEvent(onCastSpell1, 22000, parameters)
addEvent(onCastSpell1, 23000, parameters)
addEvent(onCastSpell1, 24000, parameters)
addEvent(onCastSpell1, 25000, parameters)
addEvent(onCastSpell1, 26000, parameters)
addEvent(onCastSpell1, 27000, parameters)
addEvent(onCastSpell1, 28000, parameters)
addEvent(onCastSpell1, 29000, parameters)

addEvent(onCastSpell2, 30000, parameters)

end

It can probably be done easier and shorter but Im not so great in lua scripting so this is my shot at it :) It works at least :thumbup:

Btw if anyone knows how to make and want to share the mana one, or if you want to shorten my scripts and post them here shortened, feel free to! ;)

Cheers.

EDIT: I just realized that this "HP regen" spell can actually be abused, because if the player uses it more than once then he starts getting several regenerations every second.. I guess you could add an exhaustion on the buff so the players are not allowed to do any spells during that 30 seconds or something.

Other than that I dont know how else, sorry =/
 
Last edited:
Hey man, well I made the HP buff and its working (heals an X amount every 1 second for 30 seconds, and at the last second it gives a "final hp boost" :p), but the mana one I couldnt get it work, no idea how that one is done :/

Here is the HP one. In spells.xml:

PHP:
<instant name="HP Regen Buff" words="hpregen" lvl="1" mana="10" aggressive="0" selftarget="1" params="1" exhaustion="2000" needlearn="0" event="script" value="hpregen.lua"/>

And in hpregen.lua:

Lua:
-- "HP Regen Buff" spell by Guitar Freak.

local HPregen = createCombatObject()
local HPfinalboost = createCombatObject()

local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, 12)
setCombatParam(combat1, COMBAT_PARAM_AGGRESSIVE, FALSE)
setCombatParam(combat1, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, 1, 0, 1.5, 0)

local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, 39)
setCombatParam(combat2, COMBAT_PARAM_AGGRESSIVE, FALSE)
setCombatParam(combat2, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
setCombatFormula(combat2, COMBAT_FORMULA_LEVELMAGIC, 3, 0, 3.5, 0)

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 2000)
setConditionParam(condition, CONDITION_PARAM_BUFF, TRUE)
setCombatCondition(combat1, condition)

local condition2 = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 1)
setConditionParam(condition2, CONDITION_PARAM_BUFF, FALSE)
setCombatCondition(combat2, condition2)


arr1 = {
	{0, 0, 0},
	{0, 3, 0},
	{0, 0, 0}
}

local area1 = createCombatArea(arr1)

arr2 = {
	{0, 0, 0},
	{0, 3, 0},
	{0, 0, 0}
}

local area2 = createCombatArea(arr2)

setCombatArea(HPregen, area1)
setCombatArea(HPfinalboost, area2)

function onTargetTile(cid, pos)
    doCombat(cid,combat1,positionToVariant(pos))
end

function onTargetTile2(cid, pos)
    doCombat(cid,combat2,positionToVariant(pos))
end

setCombatCallback(HPregen, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
setCombatCallback(HPfinalboost, CALLBACK_PARAM_TARGETTILE, "onTargetTile2")

local function onCastSpell1(parameters)
    doCombat(parameters.cid, HPregen, parameters.var)
end 

local function onCastSpell2(parameters)
    doCombat(parameters.cid, HPfinalboost, parameters.var)
end 

function onCastSpell(cid, var)
local parameters = { cid = cid, var = var}
addEvent(onCastSpell1, 0, parameters)
addEvent(onCastSpell1, 1000, parameters)
addEvent(onCastSpell1, 2000, parameters)
addEvent(onCastSpell1, 3000, parameters)
addEvent(onCastSpell1, 4000, parameters)
addEvent(onCastSpell1, 5000, parameters)
addEvent(onCastSpell1, 6000, parameters)
addEvent(onCastSpell1, 7000, parameters)
addEvent(onCastSpell1, 8000, parameters)
addEvent(onCastSpell1, 9000, parameters)
addEvent(onCastSpell1, 10000, parameters)

addEvent(onCastSpell1, 10000, parameters)
addEvent(onCastSpell1, 12000, parameters)
addEvent(onCastSpell1, 13000, parameters)
addEvent(onCastSpell1, 14000, parameters)
addEvent(onCastSpell1, 15000, parameters)
addEvent(onCastSpell1, 16000, parameters)
addEvent(onCastSpell1, 17000, parameters)
addEvent(onCastSpell1, 18000, parameters)
addEvent(onCastSpell1, 19000, parameters)
addEvent(onCastSpell1, 20000, parameters)

addEvent(onCastSpell1, 21000, parameters)
addEvent(onCastSpell1, 22000, parameters)
addEvent(onCastSpell1, 23000, parameters)
addEvent(onCastSpell1, 24000, parameters)
addEvent(onCastSpell1, 25000, parameters)
addEvent(onCastSpell1, 26000, parameters)
addEvent(onCastSpell1, 27000, parameters)
addEvent(onCastSpell1, 28000, parameters)
addEvent(onCastSpell1, 29000, parameters)

addEvent(onCastSpell2, 30000, parameters)

end

It can probably be done easier and shorter but Im not so great in lua scripting so this is my shot at it :) It works at least :thumbup:

Btw if anyone knows how to make and want to share the mana one, or if you want to shorten my scripts and post them here shortened, feel free to! ;)

Cheers.

EDIT: I just realized that this "HP regen" spell can actually be abused, because if the player uses it more than once then he starts getting several regenerations every second.. I guess you could add an exhaustion on the buff so the players are not allowed to do any spells during that 30 seconds or something.

Other than that I dont know how else, sorry =/


PHP:
--Script Request--By Wlj--

local HPregen = createCombatObject()
local HPfinalboost = createCombatObject()

local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat1, COMBAT_PARAM_EFFECT, 12)
setCombatParam(combat1, COMBAT_PARAM_AGGRESSIVE, TRUE)
setCombatParam(combat1, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
setCombatFormula(combat1, COMBAT_FORMULA_LEVELMAGIC, 1, 0, 1.5, 0)

local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat2, COMBAT_PARAM_EFFECT, 39)
setCombatParam(combat2, COMBAT_PARAM_AGGRESSIVE, TRUE)
setCombatParam(combat2, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
setCombatFormula(combat2, COMBAT_FORMULA_LEVELMAGIC, 3, 0, 3.5, 0)

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 2000)
setConditionParam(condition, CONDITION_PARAM_BUFF, TRUE)
setCombatCondition(combat1, condition)

local condition2 = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 1)
setConditionParam(condition2, CONDITION_PARAM_BUFF, FALSE)
setCombatCondition(combat2, condition2)


arr1 = {
        {0, 0, 0},
        {0, 3, 0},
        {0, 0, 0}
}

local area1 = createCombatArea(arr1)

arr2 = {
        {0, 0, 0},
        {0, 3, 0},
        {0, 0, 0}
}

local area2 = createCombatArea(arr2)

setCombatArea(HPregen, area1)
setCombatArea(HPfinalboost, area2)

function onTargetTile(cid, pos)
    doCombat(cid,combat1,positionToVariant(pos))
end

function onTargetTile2(cid, pos)
    doCombat(cid,combat2,positionToVariant(pos))
end

setCombatCallback(HPregen, CALLBACK_PARAM_TARGETTILE, "onTargetTile")
setCombatCallback(HPfinalboost, CALLBACK_PARAM_TARGETTILE, "onTargetTile2")

local function onCastSpell1(parameters)
    doCombat(parameters.cid, HPregen, parameters.var)
end 

local function onCastSpell2(parameters)
    doCombat(parameters.cid, HPfinalboost, parameters.var)
end 

function onCastSpell(cid, var)
local parameters = { cid = cid, var = var}
addEvent(onCastSpell1, 0, parameters)
addEvent(onCastSpell1, 1000, parameters)
addEvent(onCastSpell1, 2000, parameters)
addEvent(onCastSpell1, 3000, parameters)

end
 
@wlj:

Nothing mate, doesnt work.

It shows the effect but it doesnt heal, and doesnt add the "buff" sign either..

PHP:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_POFF)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, FALSE)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)

function onGetFormulaValues(cid, level, maglevel)
	min = (level * 1 + maglevel * 4) * 2.08
	max = (level * 1 + maglevel * 4) * 2.7
	if min < 250 then
		min = 1000
	end
	return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(cid, var)
	return doCombat(cid, combat, var)
end

a small need to sleep soon....
 
If its selfbuff you can store a caster storagevalue when a spell is casted, its prevent for multiply casting the same spell, also you must run some timer function to decrease this storagevalue in future(when the buffs ends).

Someone can make it this way?

edit. there are some tips http://otland.net/f82/justu-shadow-clones-43068/
 
Last edited:
If you place exhaustion="20000" instead of exhaustion="2000", I guess its solved, yet then we got another problem, you can't cast any spells in a while. :p (not sure though).
 
If its selfbuff you can store a caster storagevalue when a spell is casted, its prevent for multiply casting the same spell, also you must run some timer function to decrease this storagevalue in future(when the buffs ends).

Someone can make it this way?

edit. there are some tips http://otland.net/f82/justu-shadow-clones-43068/

Thanks a lot for the tips +Repped ya, didnt think of the storage value idea before, Imma work on that this week when I have a chance, maybe Ill make it work then Ill post a new thread with it cause this went too offtopic lol :D
 
You can add this in the script to make the player exhausted.

Lua:
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, 1)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 30000)
setCombatCondition(combat, exhaust)

30000 = 30 seconds.
 
Back
Top