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

Buff Spell from Item. Simple script.

Guitar Freak

_LüA_n☺b_
Joined
Dec 27, 2008
Messages
831
Reaction score
13
Location
Caracas, Venezuela
IMPORTANT EDIT: OOPS! Since I already got the fixes and re-edited the whole code, cleaned, etc, and also cleaned the thread, I realized this is still on the "request" subforum but its a "release spell" not a "request", my bad. Ill make the proper thread in "GlobalEvents, Spells & CreatureEvents" forum. Sorry U_u This thread can be deleted/locked by any mods if you wish. There'll be an identical one on the proper subforum in a few minutes.

-------------------------------------------------
-------------------------------------------------

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 anything else I think.

<----->

As requested, 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:
an easy fix is if they dont have talons make it so it adds mana back to them. if its 10 then give them 10 mana if they dont have the talons. may be abused though
 
did you try to returning false?

Code:
else
 doSendPlayerCancel(cid, "yadda")
 return false
end
end
idk if that will work or not haven't tested it on my server <_<
There is some kind of error msg you can return 2 I'll go find it
 
Lua:
  local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, FALSE)

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 20000)
setConditionParam(condition, CONDITION_PARAM_STAT_MAXHEALTHPERCENT, 120)
setConditionParam(condition, CONDITION_PARAM_BUFF, TRUE)
setCombatCondition(combat, condition)

function onCastSpell(cid, var)
    if getPlayerItemCount(cid,2151) >= 15 then
        doPlayerRemoveItem(cid, 2151, 15)
        return doCombat(cid, combat, var)
    end

    doPlayerSendCancel(cid, "You need at least 15 talons to execute this spell.")
    return LUA_ERROR
end

Won't take mana now :)
 
Lua:
  local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_RED)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, FALSE)

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 20000)
setConditionParam(condition, CONDITION_PARAM_STAT_MAXHEALTHPERCENT, 120)
setConditionParam(condition, CONDITION_PARAM_BUFF, TRUE)
setCombatCondition(combat, condition)

function onCastSpell(cid, var)
    if getPlayerItemCount(cid,2151) >= 15 then
        doPlayerRemoveItem(cid, 2151, 15)
        return doCombat(cid, combat, var)
    end

    doPlayerSendCancel(cid, "You need at least 15 talons to execute this spell.")
    return LUA_ERROR
end

Won't take mana now :)

Works perfectly :thumbup:

Ty +Rep to both of you for helping out. (Alindane I repped you earlier so I need to wait a bit until repping you again, but thanks anyways :))

Updated first post and also added a magic effect so it looks more real when it cancels :p

Cheers.
 
can u make spell like that but for add 20% of mana points?

Sure, the only thing you need to do is change the MAXHEALTHPERCENT parameter to MAXMANAPERCENT.

Here it is:

In spells.xml:

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

And in manabuff.lua:

Lua:
-- Simple "Mana 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_MAXMANAPERCENT, 120)	-- Amount of MANA % added, 100% = Total MANA so if you put 120% it adds 20% to the total MANA. Putting like 50% cuts your MANA 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.

<---->

On a side-note, I updated the first post, cleaned the code a bit and added comment lines in the script so if anyone is learning lua it may help you a bit on understanding every part of the code :thumbup:.

Cheers.

EDIT: Just realized this is the "request & support" subforum, forgot about that since after cleaning and redoing this spell, this is a release spell now. I've posted the thread in the proper subforum now.

Link here:
http://otland.net/f82/buff-spell-item-simple-script-36317/

Sorry for that U_u
 
Last edited:
Back
Top