• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Function that Raises total Armor Value

Jaed Le Raep

★Gaeming★
Joined
Sep 3, 2007
Messages
1,298
Reaction score
446
Hey everyone, I was wondering, is there a function that raises the total current armor value of a character?

Say I'm a Knight. I'd like to have a spell that raises my armor value from 14 (which is from the armor set I'm wearing), to armor value 20, without having changed the armor value on the armor(s) themselves.
 
Say someone is only wearing a plate armor and plate legs.

Plate Armor = 10 armor. Plate Legs = 7 armor. That player has an armor value of 17 because 10 + 7 = 17.

Now, I want to create a spell that buffs this player's armor value by 50%, so the player's new armor value would be 25.5.

That's essentially what I'm looking for :P
 
owhhhhhhhhhhhhhhhhhhhhhhhhhh buff player defence for x amount of time. Is that what you mean?

Well, to be -really- specific, I'm looking to buff their -armor-, not defense. Defense and Armor value are two different things in tibia. Defense Value comes from weapon and shield. Armor Value comes from Armor, Legs, boots, and Helm.
 
Oke, i've tought how to do it. I'LL post an example script soon.
Just a fast question. How do players get a buff is it a talkaction way? Or based on there level range the receive it?

- - - Updated - - -

Here is an example to rais total player Armor, NOT TESTED. And dont forget you need to call setBonusArmor(cid) for example at login.lua to activate it.

Code:
configArmor = 
	{
	work = true, --Bonus active or not (True or false)
	storageExh = 43320, --Storage value (dont touch)
	workTime = 720, -- time to work bonus exp (Bonus lenght)
	resetExp = 1.0 -- initial rate (do not change if you have not changed in vocations.xml)
	}

function setBonusArmor(cid)
t = {
--Minlvl,Maxlvl,Percent
[{10,49,5}],
[{50,99,10}],
[{100,199,15}],
[{200,math.huge,20}]
}
        for var, ret in pairs(t) do
		if getPlayerLevel(cid) >= var[1] and getPlayerLevel(cid) <= var[2] then
		local yourRates = getPlayerRates(cid)[SKILL__ARMOR]
		local bonusExpRate = yourRates + (var[3] * yourRates/100)
		if exhaustion.check(cid, configArmor.storageExh) then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "bonus, added.")
		else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "bonus, added")
		doPlayerSetRate(cid, SKILL__ARMOR, bonusExpRate)
		exhaustion.set(cid, configArmor.storageExh, configArmor.workTime * 24)
		addEvent(bonusArmor, configArmor.workTime * 60 * 1000, cid)
		local animText = math.random(1,200)
		doSendAnimatedText(getPlayerPosition(cid), 'Bonus armor', animText)	
		end
		end
end
end

map/lib/functions.lua

Code:
function bonusArmor(cid)
	if isCreature(cid) == false then
		return true
	end
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your bonus Armor just ended.")
		doPlayerSetRate(cid, SKILL__LEVEL, configExp.resetExp)
	return true
end
 
Last edited:
Oke, i've tought how to do it. I'LL post an example script soon.
Just a fast question. How do players get a buff is it a talkaction way? Or based on there level range the receive it?

If I'm understanding the question correctly, it's not going to be on the character's level, because I want it to be a level 1 skill, but it should have a built-in cooldown, of about 15 seconds (of course, the cooldown should be editable)
 
So bassicly what you want is a spell that buffs your armor for an x % for an x amount of time right?

Example
Utito Temp buff < Armor increased by 50% for 15 seconds.


I'm not building the script i just gave an example how to handle it.
 
So bassicly what you want is a spell that buffs your armor for an x % for an x amount of time right?

Example
Utito Temp buff < Armor increased by 50% for 15 seconds.


I'm not building the script i just gave an example how to handle it.

You're on the right track, but there seems to be no way to raise armor rating, and even if I try to raise defense, it'd raise the defense of a weapon or shield.
 
ofcourse there is you can build cour custom spell

example:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 10000)
setConditionParam(condition, CONDITION_PARAM_SKILL_DISTANCEPERCENT, 150)    <---- Try CONDITION_PARAM_SKILL_ARMOR
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
setCombatCondition(combat, condition)

local speed = createConditionObject(CONDITION_PARALYZE)
setConditionParam(speed, CONDITION_PARAM_TICKS, 10000)
setConditionFormula(speed, -0.7, 56, -0.7, 56)
setCombatCondition(combat, speed)

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, 2)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 10000)
setCombatCondition(combat, exhaust)

function onCastSpell(cid, var)
	return doCombat(cid, combat, var)
end
 
ofcourse there is you can build cour custom spell

example:
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)

local condition = createConditionObject(CONDITION_ATTRIBUTES)
setConditionParam(condition, CONDITION_PARAM_TICKS, 10000)
setConditionParam(condition, CONDITION_PARAM_SKILL_DISTANCEPERCENT, 150)    <---- Try CONDITION_PARAM_SKILL_ARMOR
setConditionParam(condition, CONDITION_PARAM_BUFF, true)
setCombatCondition(combat, condition)

local speed = createConditionObject(CONDITION_PARALYZE)
setConditionParam(speed, CONDITION_PARAM_TICKS, 10000)
setConditionFormula(speed, -0.7, 56, -0.7, 56)
setCombatCondition(combat, speed)

local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_SUBID, 2)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, 10000)
setCombatCondition(combat, exhaust)

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

I added end at the end and loaded the script. It loads and casts without error, but how do i truly verify that my armor value increased? Because I never imagined Armor would be seen as a skill, if you get what I mean.
 
by adding

Code:
local yourRates = getPlayerRates(cid)[SKILL__ARMOR]
selfSay:('Your armor rate is now '... yourRates ...' Proof of concept. ');

before:
Code:
function onCastSpell(cid, var)
    return doCombat(cid, combat, var)
end

it's not tested
 
The protocol function it does. Because irs a variable setting defind in vocations.xml. but i am not sure of it. The default setting is 1.0 i the armor multiplyer.
 
not as constant
LUA:
SKILL_FIRST = 0
SKILL_FIST = SKILL_FIRST
SKILL_CLUB = 1
SKILL_SWORD = 2
SKILL_AXE = 3
SKILL_DISTANCE = 4
SKILL_SHIELD = 5
SKILL_FISHING = 6
SKILL__MAGLEVEL = 7
SKILL__LEVEL = 8
SKILL__EXPERIENCE = 9
SKILL_LAST = SKILL_FISHING
SKILL__PRE_LAST = SKILL__LEVEL
SKILL__LAST = SKILL__EXPERIENCE

LUA:
CONDITION_PARAM_SKILL_MELEE = 19
CONDITION_PARAM_SKILL_FIST = 20
CONDITION_PARAM_SKILL_CLUB = 21
CONDITION_PARAM_SKILL_SWORD = 22
CONDITION_PARAM_SKILL_AXE = 23
CONDITION_PARAM_SKILL_DISTANCE = 24
CONDITION_PARAM_SKILL_SHIELD = 25
CONDITION_PARAM_SKILL_FISHING = 26
pls read 000-constant.lua before inventing things
 
Back
Top