• 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.
 
Let me get it right, you want it to add xxx armor to a certain item just for a certain amount of time?
@Codinablack

Yes, but through a spell, an actual spell... It doesn't have to be a certain item like it adds arm to your helmet, although that would be nice, but as long as it does add armor for a certain time, its a buff.... And having it increase shielding isn't the same...
 
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)
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)
    if getPlayerVocation(cid) == xx then
    doPlayerAddShielding(cid, amount)
    return doCombat(cid, combat, var)
end
It probly wont work at all as i think you MIGHT get a error at doPlayerAddShielding. try anyway
@Codinablack
 
Odd that armor can't be changed with ease as with all the other attributes. Make a suggestion to mark to update tfs to support it =)
 
I have this option in my new version of TFS, but it isn't currently possible in any current version of TFS.

Without source edits... you would have to do it in a really cheesey way.
An example would be something like:
Code:
function armorPercent(cid, percent, time)
  local armor = 0
  for a = 0, 10 do
    local item = getPlayerSlotItem(cid, a)
    if item then
      local itemArmor = getItemInfo(item.uid).armor
      if itemArmor > 0 then
        armor = armor + itemArmor
      end
     end
   end
if armor > 0 then
  armor = armor - (armor * percent)
  local item = getPlayerSlotItem(cid, 3) -- backpack slot
  doItemSetAttribute(item, "armor", armor)
  addEvent(doItemSetAttribute, time, "armor", 0)
  return true
else
  return false
end

(The above function may or may not work in your version of TFS depending on what you use)
 
I have this option in my new version of TFS, but it isn't currently possible in any current version of TFS.

Without source edits... you would have to do it in a really cheesey way.
An example would be something like:
Code:
function armorPercent(cid, percent, time)
  local armor = 0
  for a = 0, 10 do
    local item = getPlayerSlotItem(cid, a)
    if item then
      local itemArmor = getItemInfo(item.uid).armor
      if itemArmor > 0 then
        armor = armor + itemArmor
      end
     end
   end
if armor > 0 then
  armor = armor - (armor * percent)
  local item = getPlayerSlotItem(cid, 3) -- backpack slot
  doItemSetAttribute(item, "armor", armor)
  addEvent(doItemSetAttribute, time, "armor", 0)
  return true
else
  return false
end

(The above function may or may not work in your version of TFS depending on what you use)


So I add the above into my spells .lib file right?

Then in a spell try this...

function onCastSpell(cid, var)
if getPlayerVocation(cid) == xx then
armorPercent(cid, percent, time)
return doCombat(cid, combat, var)
end

?
 
Ok so I added the function Flatlander made into my spells.lua file inside my .lib folder (needed to add one more end :) then made this spell,

Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
 
function onCastSpell(cid, var)
    if getPlayerVocation(cid) == 6 then
    armorPercent(cid, 50, 2000)
    return doCombat(cid, combat, var)
end
end

Nothing happens inside the console, no errors.... Nothing happens inside the game, spell words don't pop up, no cancel is returned, (no sorry this is not possible) nothing at all, not even an animation... Any ideas?
 
Is the player's vocation 6?

All my extremely broken and shitty function does, is get your total armor, multiply it by the percentage, then add that armor value to your backpack (if you don't have a backpack, then your spell won't work)

It will set your backpack's armor back to 0 after the "time" you entered.
 
removed the check for the vocation (was trying spell on GM) and now it's returning an error...

Code:
[6/2/2014 15:49:11] [Error - Spell Interface]
[6/2/2014 15:49:11] data/spells/scripts/support/enhancearmor.lua:onCastSpell
[6/2/2014 15:49:11] Description:
[6/2/2014 15:49:11] data/spells/lib/spells.lua:186: attempt to index a boolean value
[6/2/2014 15:49:11] stack traceback:
[6/2/2014 15:49:11]    data/spells/lib/spells.lua:186: in function 'armorPercent'
[6/2/2014 15:49:11]    data/spells/scripts/support/enhancearmor.lua:7: in function <data/spells/scripts/support/enhancearmor.lua:6>

Problem is in this line

local itemArmor = getItemInfo(item.uid).armor

changed to

local itemArmor = getItemInfo(item.itemid).armor

and still same problem... I do have a working upgrade crystal that will upgrade armor, and works perfectly on my server, would you like to see its code?
 
Please someone help me!!

Or maybe I could just make them conjure an item, an item that only they can use, that will temporarily boost the arm of w/e armor they put it on.... Any idea how to make an attribute added to the armor only temporary?
 
TFS 1.0 runs WAY better than TFS 0.3.
BUT!
TFS 0.3 has WAY better functionality than TFS 1.0.

TFS 1.0 is made for "Real Tibia Maps". Because of this, it has almost no functionality for making custom anything, because it is specifically designed to be the best possible solution for running RL Tibia Maps. (Which as you know, are the opposite of custom according to OT Lingo).

If you aren't good at source editing and an expert at coding in LUA, and you want to make a custom OT, I BEG you not to use TFS 1.0, you will waste a lot of your time, and not be able to do many of the things you would like to, and would be much easier to make a fun and successful custom OT in TFS 0.3.

This is of course my personal opinion as someone that designs custom OTs and has attempted to use TFS 1.0 to see what I could do with it.
(not much)

Sorry but I won't be helping with TFS 1.0 issues, simply because I don't have much knowledge of TFS 1.0 yet.
 
I thought you made TFS 1.0 and Idk why but someone else has told me tfs 1.0 was best way to go because it had more functionality, I joined his test server and seen he had some pretty awesome stuff, and besides it would appear as though the rest of the community is moving towards using tfs 1.0... Idk I have spent a lot of time downloading and trying, and if you ask me, ALL of the old versions are exactly that OLD, with lots and lots of problems... I am pretty confused.... I don't want to run a "Real Tibia Map", but I also am tired of absolutely no support... I understand that I am a noob at C++ and .lua... In general programming noob, but I will soon be going to school and learning both of those languages as well as much more such as .xml. I actually found a class I can get into that covers everything we use in OT's except the webdesign department....
 
I can make a script what adds a REAL armor (not shielding, not bonus armor to wearing items).
But I'll write it for 0.3.x and I hate wasting time. So, do you really need it?
 
Yes Sir! Not only I, but I have searched and seen others requesting something very similar. I am sure if you made and released MANY would be very appreciative!
 
I have this option in my new version of TFS, but it isn't currently possible in any current version of TFS.

Without source edits... you would have to do it in a really cheesey way.
An example would be something like:
Code:
function armorPercent(cid, percent, time)
  local armor = 0
  for a = 0, 10 do
    local item = getPlayerSlotItem(cid, a)
    if item then
      local itemArmor = getItemInfo(item.uid).armor
      if itemArmor > 0 then
        armor = armor + itemArmor
      end
     end
   end
if armor > 0 then
  armor = armor - (armor * percent)
  local item = getPlayerSlotItem(cid, 3) -- backpack slot
  doItemSetAttribute(item, "armor", armor)
  addEvent(doItemSetAttribute, time, "armor", 0)
  return true
else
  return false
end

(The above function may or may not work in your version of TFS depending on what you use)
How do you do it in your version of TFS then?
 
Back
Top