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

[Weapon] Weapon with healing (healing % of weapon damage)

Limos

Senator
Premium User
Joined
Jun 7, 2010
Messages
10,013
Solutions
8
Reaction score
3,056
Location
Netherlands
The idea is based on lifesteal weapons. It heals % of the average damage that people will hit with a certain level, skills and attack of the weapon.
Tested with TFS 0.3.6pl1 8.54

Attack damage weapons

Weapons.xml
XML:
<melee id="XXXX" level="20" unproperly="1" event="script" value="weapon.lua"/>

Weapon.lua
Lua:
     local combat = createCombatObject()
    setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
    setCombatParam(combat, COMBAT_PARAM_BLOCKSHIELD, 1)
    setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
    setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)
 
function onUseWeapon(cid, var)
	local skill = getPlayerSkill(cid,SKILL_SWORD) -- Change this to the type of weapon you are using
	local mat = 0.085*0.5*50*skill+(getPlayerLevel(cid)/5) -- Change 50 to the attack of the weapon
	local min = 5 -- this means 5% minimum healing
	local max = 15 -- this means 15% maximum healing
	local addhealth = math.random((mat * (min/100)), (mat * (max/100)))
 
    if getPlayerLevel(cid) >= 20 then
        doCreatureAddHealth(cid, addhealth)
        doSendAnimatedText(getPlayerPosition(cid),"+"..addhealth.."", TEXTCOLOR_GREEN)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE) 
        doCombat(cid, combat, var)
    else
        doPlayerSendCancel(cid, 'You need level 20 to use this weapon.')
    end
end


Wands

Weapons.xml
XML:
	<wand id="XXXX" level="50" mana="15" event="script" value="wand.lua"> <!-- Healing Wand -->
		<vocation id="1"/>
	</wand>

wand.lua
Lua:
    local combat = createCombatObject()
    setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
    setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
    setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HOLY)
 
    function onGetFormulaValues(cid, level, maglevel)
    min = -(maglevel*4) -level/5 
    max = -(maglevel*6) -level/5
 
    return min, max
    end
 
    setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")
 
function onUseWeapon(cid, var)

	local level, magic, target = getPlayerLevel(cid), getPlayerMagLevel(cid), getCreatureTarget(cid)
	local mat1, mat2 = magic*2+level/10, magic*3+level/10 -- 50% from the min/max above
	local xmat1, xmat2 = magic*4+level/5, magic*6+level/5 -- same as the min/max above
	local percent = 10 -- change here the % of the healing. 
	local health, xhealth = math.random((mat1 * (percent/100)), (mat2 * (percent/100))), math.random((xmat1 * (percent/100)), (xmat2 * (percent/100)))
 
	if isPlayer(target) then
		doCreatureAddHealth(cid, health)
        	doSendAnimatedText(getPlayerPosition(cid),"+"..health.."", TEXTCOLOR_GREEN)
        	doCombat(cid, combat, var)
	else
		doCreatureAddHealth(cid, xhealth)
        	doSendAnimatedText(getPlayerPosition(cid),"+"..xhealth.."", TEXTCOLOR_GREEN)
        	doCombat(cid, combat, var)
	end
	return true
end
 
Last edited:
does it apply defences and decrease healing if damage was decreased?
also weapon damage is distributed in Gaussian Distribution, not "plain" one, if you want to emulate using normal weapon you'd need to hack it
 
The idea is based on lifesteal weapons, it's not exactly like normal lifesteal. It is more like a random gain from lifesteal. It has no effect on higher or lower hits, same as it has no effect of the defence of the target.
The healing is a % of the average damage someone will hit with a certain weapon, what gives a bit the same idea as lifesteal, only now the % healing is not precisely the % of a certain hit.
It's like an alternative idea for people who want something similar to lifesteal without source edits.

About the damage. The average damage is based on real tibia weapons. I tested it ingame and the healing was the % of the average damage I had on a monster.
 
Last edited:
*sigh* Let's just inject one line of my pro code from Frozen into this and make in a lot better.

Edit: Changed my mind. Make that two lines and a lookup table.

How about we do this: replace the lines starting from onUseWeapon to the assignment of 'mat' with this code:
Code:
function onUseWeapon(cid, var)
    local skillType = {
        [WEAPON_FIST ] = SKILL_FIST     ;
        [WEAPON_CLUB ] = SKILL_CLUB     ;
        [WEAPON_SWORD] = SKILL_SWORD    ;
        [WEAPON_AXE  ] = SKILL_AXE      ;
        [WEAPON_DIST ] = SKILL_DISTANCE ;
        } ; 
    local attackWeapon   = getItemAttribute(getPlayerWeapon(cid, true).uid,  "attack") or getItemInfo(getPlayerWeapon(cid,  true)["itemid"])["attack"] ;
    local skill = getPlayerSkill(cid, skillType[getItemWeaponType(getPlayerWeapon(cid, true).uid)]) ;
    local level = getPlayerLevel(cid)/5 ;
    local mat = ( 0.085 * attackWeapon * skill + level ) ;

Now you don't have to multiple copies of this script with just one thing changed for different weapons, it will just read the value from the item itself. Additionally, any upgrade system that modifies the items attributes properly will properly be interactive with this.
 
Last edited:
I'm sorry if the tone of my post came across like 'as if I were a distant deity and was only taking pity on you.' But that's just me. It puts a lot of people off. I know. But there's not much I can do to change it, it's just who I am.

Do you like the suggestion or not?
 
*sigh* Let's just inject one line of my pro code from Frozen into this and make in a lot better.

Edit: Changed my mind. Make that two lines and a lookup table.

How about we do this: replace the lines starting from onUseWeapon to the assignment of 'mat' with this code:
Code:
function onUseWeapon(cid, var)
    local skillType = {
        [WEAPON_FIST ] = SKILL_FIST     ;
        [WEAPON_CLUB ] = SKILL_CLUB     ;
        [WEAPON_SWORD] = SKILL_SWORD    ;
        [WEAPON_AXE  ] = SKILL_AXE      ;
        [WEAPON_DIST ] = SKILL_DISTANCE ;
        } ; 
    local attackWeapon   = getItemAttribute(getPlayerWeapon(cid, true).uid,  "attack") or getItemInfo(getPlayerWeapon(cid,  true)["itemid"])["attack"] ;
    local skill = getPlayerSkill(cid, skillType[getItemWeaponType(getPlayerWeapon(cid, true).uid)]) ;
    local level = getPlayerLevel(cid)/5 ;
    local mat = ( 0.085 * attackWeapon * skill + level ) ;

Now you don't have to multiple copies of this script with just one thing changed for different weapons, it will just read the value from the item itself. Additionally, any upgrade system that modifies the items attributes properly will properly be interactive with this.

No appreciation!? LOL, very clean.
Dem semi-colon!! <3 :p

@Limos
He means no harm, rough on the edges, but non the less he does it with intent to teach ;)
All items can use one script, All scripts cannot use one item.
BTW nice script, all in all!
 
Trying to use this, added mana, but i wana know if there is a way to round off the numbers...

EXAMPLE UNROUNDED:
Code:
12:29 +8.02 Hp.
12:29 +2.6733333333333 Mana.
12:29 +9.02 Hp.
12:29 +3.6733333333333 Mana.


EXAMPLE ROUNDED (What i want it to be like):
Code:
12:29 +8 Hp.
12:29 +2.5 Mana.
12:29 +9 Hp.
12:29 +3.5 Mana.

So for whole numbers like 8.00 it would become 8 or even 8.02, round down to 8, and then like 8.3 would become 8.5... round up or down to the whole or 1/2 number.. just for display purposes, although having them rounded off would be nice.

ok nvm, found code
Code:
---=========================================================---
------== rounds a number to the nearest decimal place ==-------
---=========================================================---
function round(val, decimal)
  if (decimal) then
    return math.floor( (val * 10^decimal) + 0.5) / (10^decimal)
  else
    return math.floor(val+0.5)
  end
end
 
Last edited:
sorry bro i checked again and that working very good !!! :D just look at this screen below this text V

10814215_824541520941471_262848676_n.jpg
 
The idea is based on lifesteal weapons. It heals % of the average damage that people will hit with a certain level, skills and attack of the weapon.
Tested with TFS 0.3.6pl1 8.54

Attack damage weapons

Weapons.xml
XML:
<melee id="XXXX" level="20" unproperly="1" event="script" value="weapon.lua"/>

Weapon.lua
Lua:
     local combat = createCombatObject()
    setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 1)
    setCombatParam(combat, COMBAT_PARAM_BLOCKSHIELD, 1)
    setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
    setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)

function onUseWeapon(cid, var)
    local skill = getPlayerSkill(cid,SKILL_SWORD) -- Change this to the type of weapon you are using
    local mat = 0.085*0.5*50*skill+(getPlayerLevel(cid)/5) -- Change 50 to the attack of the weapon
    local min = 5 -- this means 5% minimum healing
    local max = 15 -- this means 15% maximum healing
    local addhealth = math.random((mat * (min/100)), (mat * (max/100)))

    if getPlayerLevel(cid) >= 20 then
        doCreatureAddHealth(cid, addhealth)
        doSendAnimatedText(getPlayerPosition(cid),"+"..addhealth.."", TEXTCOLOR_GREEN)
        doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_BLUE)
        doCombat(cid, combat, var)
    else
        doPlayerSendCancel(cid, 'You need level 20 to use this weapon.')
    end
end


Wands

Weapons.xml
XML:
    <wand id="XXXX" level="50" mana="15" event="script" value="wand.lua"> <!-- Healing Wand -->
        <vocation id="1"/>
    </wand>

wand.lua
Lua:
    local combat = createCombatObject()
    setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
    setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
    setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HOLY)

    function onGetFormulaValues(cid, level, maglevel)
    min = -(maglevel*4) -level/5
    max = -(maglevel*6) -level/5

    return min, max
    end

    setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onUseWeapon(cid, var)

    local level, magic, target = getPlayerLevel(cid), getPlayerMagLevel(cid), getCreatureTarget(cid)
    local mat1, mat2 = magic*2+level/10, magic*3+level/10 -- 50% from the min/max above
    local xmat1, xmat2 = magic*4+level/5, magic*6+level/5 -- same as the min/max above
    local percent = 10 -- change here the % of the healing.
    local health, xhealth = math.random((mat1 * (percent/100)), (mat2 * (percent/100))), math.random((xmat1 * (percent/100)), (xmat2 * (percent/100)))

    if isPlayer(target) then
        doCreatureAddHealth(cid, health)
            doSendAnimatedText(getPlayerPosition(cid),"+"..health.."", TEXTCOLOR_GREEN)
            doCombat(cid, combat, var)
    else
        doCreatureAddHealth(cid, xhealth)
            doSendAnimatedText(getPlayerPosition(cid),"+"..xhealth.."", TEXTCOLOR_GREEN)
            doCombat(cid, combat, var)
    end
    return true
end

Its Perfect script but i need it to make mana not hp
and I want to be pinned No. strike like 1000-1400 ;)
 
to chnage for mana chnage it
Code:
if isPlayer(target) then
doCreatureAddMana(cid, mana)

Code:
doSendAnimatedText(getPlayerPosition(cid),"+"..mana.."", TEXTCOLOR_BLUE)
doCombat(cid, combat, var)
else
doCreatureAddMana(cid, xmana)
doSendAnimatedText(getPlayerPosition(cid),"+"..xmana.."", TEXTCOLOR_BLUE)
 
to chnage for mana chnage it
Code:
if isPlayer(target) then
doCreatureAddMana(cid, mana)

Code:
doSendAnimatedText(getPlayerPosition(cid),"+"..mana.."", TEXTCOLOR_BLUE)
doCombat(cid, combat, var)
else
doCreatureAddMana(cid, xmana)
doSendAnimatedText(getPlayerPosition(cid),"+"..xmana.."", TEXTCOLOR_BLUE)
made it but its give mana and hp atm >.<
 
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HOLY)

function onGetFormulaValues(cid, level, maglevel)
min = -(maglevel*4) -level/5
max = -(maglevel*6) -level/5

return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onUseWeapon(cid, var)

local level, magic, target = getPlayerLevel(cid), getPlayerMagLevel(cid), getCreatureTarget(cid)
local mat1, mat2 = magic*2+level/10, magic*3+level/10 -- 50% from the min/max above
local xmat1, xmat2 = magic*4+level/5, magic*6+level/5 -- same as the min/max above
local percent = 10 -- change here the % of the healing.
local mana, xmana = math.random((mat1 * (percent/100)), (mat2 * (percent/100))), math.random((xmat1 * (percent/100)), (xmat2 * (percent/100)))

if isPlayer(target) then
doCreatureAddMana(cid,mana)
doSendAnimatedText(getPlayerPosition(cid),"+"..Mana.."", TEXTCOLOR_BLUE)
doCombat(cid, combat, var)
else
doCreatureAddMana(cid, xmana)
doSendAnimatedText(getPlayerPosition(cid),"+"..xmana.."", TEXTCOLOR_BLUE)
doCombat(cid, combat, var)
end
return true
end
 
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HOLY)

function onGetFormulaValues(cid, level, maglevel)
min = -(maglevel*4) -level/5
max = -(maglevel*6) -level/5

return min, max
end

setCombatCallback(combat, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onUseWeapon(cid, var)

local level, magic, target = getPlayerLevel(cid), getPlayerMagLevel(cid), getCreatureTarget(cid)
local mat1, mat2 = magic*2+level/10, magic*3+level/10 -- 50% from the min/max above
local xmat1, xmat2 = magic*4+level/5, magic*6+level/5 -- same as the min/max above
local percent = 10 -- change here the % of the healing.
local mana, xmana = math.random((mat1 * (percent/100)), (mat2 * (percent/100))), math.random((xmat1 * (percent/100)), (xmat2 * (percent/100)))

if isPlayer(target) then
doCreatureAddMana(cid,mana)
doSendAnimatedText(getPlayerPosition(cid),"+"..Mana.."", TEXTCOLOR_BLUE)
doCombat(cid, combat, var)
else
doCreatureAddMana(cid, xmana)
doSendAnimatedText(getPlayerPosition(cid),"+"..xmana.."", TEXTCOLOR_BLUE)
doCombat(cid, combat, var)
end
return true
end
thx its working but i dont need effect of HP appears on game ;D like this
and if you can make it for pinning number like 1000-1400 not more cuz its now attacking on magic level
4g1clx.jpg
 
Back
Top