LuaUnderstanding Spell Formulas

Strikers

Community Helper
Guide officially written from scratch by [email protected] also known as [email protected] at September 01, 2009 at 5:20PM~5:40PM GMT-05:00 (New York Time)

Hello, this is my first official tutorial, and here I am going to explain about the spell formulas and how to change them correctly.

Now let's start.

Story:
You are creating a spell and when you check on your lua *BOOM* you see the following:
Code:
``setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1.0, -900, -3.2, -1100)``
Or
Code:
``setCombatFormula(combat, COMBAT_FORMULA_SKILL, 1.0, -900, 3.2, -1100)``

And you have no idea what the hell are those numbers.

Well I am going to explain.

Code:
``1.0, -900, 3.2, -1100)``

The first number is the multiplier of your skill (If it's set to COMBAT_FORMULAT_LEVELMAGIC, then it will be based of magic level, if set to SKILL then your main melee skill will take over the others)

The second number is the minimum damage (If you want to make a healing spell, remove the - (negative) symbol of the second and fourth numbers)

The third number is the multiplier of your character level.

The fourth number is the maximum damage (Read the parenthesis of the second set of number)

Now, there is a difference between SKILL and LEVELMAGIC formulas.

If you want them to deal damage and not heal each one has a different setup.

Code:
``COMBAT_FORMULA_SKILL, 1.0, -100, 1.0, -200)``
Will deal damage

Code:
``COMBAT_FORMULA_SKILL, -1.0, -100, -1.0, -200)``
WILL HEAL THE ENEMY IF YOU ARE HIGH LEVEL OR HAVE A HIGH SKILL LEVEL

Code:
``COMBAT_FORMULA_SKILL, -1.0, 100, -1.0, 200)``
Will heal the enemy

Code:
``COMBAT_FORMULA_LEVELMAGIC, 1.0, -100, 1.0, -200)``
WILL HEAL THE ENEMY IF YOU ARE HIGH LEVEL OR HAVE A HIGH MAGIC LEVEL
Note: Will deal damage if you are low level and have a low magic level since minimum and maximum damage are negative

Code:
``COMBAT_FORMULA_LEVELMAGIC, -1.0, -100, -1.0, -200)``
Will completely deal damage to the enemy

Code:
``COMBAT_FORMULA_LEVELMAGIC, 1.0, 100, 1.0, 200)``
Will heal the enemy.

So yeah, I think you get it how SKILL and LEVELMAGIC works now.

Now let's make some calculations on how the multipliers add up to the minimum and maximum damage.

Suppose you have this:
Code:
``COMBAT_FORMULA_LEVELMAGIC, -1.0, -100, -1.0, -200)``

And you are a level 100 character with 100 Magic level

first off at level 0 you would deal 100~200 damage.
Now at level 100 with 100 Magic level you would add up the first and third value (100+100) which is 200, and then add it up to both minimum and maximum damage

Which will be 300~400 damage at level 100 with 100 magic level.

So always sum up the first and third value, and them add it to both minimum and maximum values (The second and fourth).

Renusek

beton beton beton punk!
Nice tutorial . repek <1st>.

Merkz

Creator of Arachnas.com
Thanks will help Alot of people xd

Nice Tuto =p

LaloHao

Member
Thanks, i never understood the formulas until i read this

Yngwie

Member
It's nice, but I don't think it's accurate? For skills perhaps, but levelmagic isn't that like level + mag*4 or some other value, so levelmagic * 1.0 at mag 100 lvl 100 would be 500 dmg?

OP
OP
S

Strikers

Community Helper
It's nice, but I don't think it's accurate? For skills perhaps, but levelmagic isn't that like level + mag*4 or some other value, so levelmagic * 1.0 at mag 100 lvl 100 would be 500 dmg?

DarkstaR

Banned User

Check the source code, hes right.

While your tutorial is correct for skills, magic is calculated differently.

__________________

Are you tired of the customer neglect of TibiaBotNG? Do you think LoW needs to add more updates? Are you tired of using a crappy bot because its a cheap alternative to Elf? Well, dont be tired anymore! Check out my blog!

Last edited:

Scarlet Ayleid

Senator
Here are the correct Damage Formulas for Spells(with sources included as proof)

To calculate Spell Damage:
PHP:
``setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1.0, -900, -3.2, -1100)``

MinDmg = (Level + ML * 4) * MinA + MinB
MaxDmg = (Level + ML * 4) * MaxA + MaxB

PHP:
``setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, MinA, MinB, MaxA, MaxB)``

SOURCE CODE:
PHP:
``````			case FORMULA_LEVELMAGIC:
{
min = (int32_t)((player->getLevel() + player->getMagicLevel() * 4) * 1. * mina + minb);
max = (int32_t)((player->getLevel() + player->getMagicLevel() * 4) * 1. * maxa + maxb);``````

To calculate Skill Damage:
NOTE: Max Damage depends if you have a equipped weapon or not

PHP:
``setCombatFormula(combat, COMBAT_FORMULA_SKILL, 1.0, -900, 3.2, -1100)``

MinDmg = MinB
With Equipped Weapon:
MaxDmg = ((2 * (WeaponAttack * (WeaponSkill + 5.8) / 25 + (level - 1) / 10)) / Stance) * MaxA + MaxB
Stance(1 = Attack, 1.2 = Balanced, 2 = Defense)

Without Equipped Weapon:
MaxDmg = MaxB

PHP:
``setCombatFormula(combat, COMBAT_FORMULA_SKILL, MinA, MinB, MaxA, MaxB)``

SOURCE CODE: (Too lazy to get "getWeaponDamage" using only Notepad )
PHP:
``````case FORMULA_SKILL:
{
min = (int32_t)minb;
Item* tool = player->getWeapon();
if(const Weapon* weapon = g_weapons->getWeapon(tool))
{
max = (int32_t)(weapon->getWeaponDamage(player, target, tool, true) * maxa + maxb);
if(params.useCharges && tool->hasCharges() && g_config.getBool(ConfigManager::REMOVE_WEAPON_CHARGES))
g_game.transformItem(tool, tool->getID(), std::max((int32_t)0, ((int32_t)tool->getCharges()) - 1));
}
else
max = (int32_t)maxb;

return true;
}``````

Last edited:

Magictibiaman

New Member
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -6.5, 0, -9, 0)
i should get
MinDmg = (450 + 125 * 4) * (6.5) + (0)
MaxDmg = (450 + 125 * 4) * (9)+ (0)

MinDmg = 950 * 6.5 = 6175
MaxDmg = 950 * 9 = 8550

but my average dmg is in the 1500's

Scarlet Ayleid

Senator
I'm not into OTs anymore, but its possible that the formula might have changed(although I doubt it), perhaps your damage is being changed due to elemental resistences?

Magictibiaman

New Member
no i have checked that.
this is just pure dmg
and it works perfectly with the knight. exactly like your formula
but the magic one doesn't

Member
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -1, -60, 10, -60, 15, 16, 17, 25)
???
-1-?
-60-?
10-?
-60?
15-?
16-?
17-?
25-?

Replies
0
Views
303
Replies
4
Views
505
Replies
2
Views
156
Replies
6
Views
516
Replies
39
Views
4K
Replies
5
Views
190
Replies
1
Views
249
Replies
16
Views
1K