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

Lua Damage Formula's

Codinablack

Dreamer
Content Editor
Joined
Dec 26, 2013
Messages
1,635
Solutions
11
Reaction score
880
Hello Otland I was wondering if I could get just a little help here with damage calculations. I have a wand I have made and the damage it does is good but it increases with level and magic level (I want it that way) and this becomes a problem if a level 100 sorceror is running around with ml 80 doing 100+ damage each hit and this is the weakest wand. So I want to set a max if the max goes above my secondary max then max is now the second max... Here is example that doesn't work...


Code:
function onGetFormulaValues(cid, level, maglevel)
min = -((level * 0.2 + maglevel * 1.5) + 1)
max = -((level * 0.3 + maglevel * 1.8) + 1)

    if max >= -2 then max = -2
    end

    return min, max
end

And Secondly I would like to invite anyone to help me with trying to get the target's total arm value to take into consideration for the damage process, seeing as how with the above method arm becomes pointless....

I figure useing getArmor() method would be how its done I just can't get my head around how to go about doing it, and there aren't many examples here on otland, just search "getarmor" and see how few results return....
 
The problem is because youre still returning a min value that can be higher than the max. You need to return the min value aswell, i added the 0.66 multiplier so the min value will keep the same randomized damage.

function onGetFormulaValues(cid, level, maglevel)
min = (level * 0.2 + maglevel * 1.5) + 1
max = (level * 0.3 + maglevel * 1.8) + 1

if max >= 2 then
max = 2
min = 2 * (2/3)
end

return -min, -max
end
 
Oh! I see what you are saying! Thanks! Any ideas about the second part?
 
Last edited:
This is how it looks now and the player is still regularly hitting 3's


Code:
function onGetFormulaValues(cid, level, maglevel)
min = -((level * 0.2 + maglevel * 1.5) + 1)
max = -((level * 0.3 + maglevel * 1.8) + 1)

if max >= -2 then
    max = -2
    min = -2 * (2/3)
end

    return min, max
end
 
Thats because
Code:
if max >= -2 then
should be
Code:
if max <= -2 then

If you write the code like i did you will avoid such mixups
 
Why dont you just make wands in weapons.xml? Then damage will stay within the range you choose and you can set level req etc.

Code:
    <wand id="2190" level="10" mana="0" min="5" max="10" type="energy" function="default">
        <vocation name="Sorcerer" showInDescription="1"/>
    </wand>
 
Why dont you just make wands in weapons.xml? Then damage will stay within the range you choose and you can set level req etc.

Code:
    <wand id="2190" level="10" mana="0" min="5" max="10" type="energy" function="default">
        <vocation name="Sorcerer" showInDescription="1"/>
    </wand>

Because then the damage would not be dependent upon level or magic level, instead it would only be a set rate, and if I really wanted to do that I could do same thing with this script but change min and max to constants as well, and still be able to change the shoottype and area affect to two totally different types and damage type a third if I wanted, so basically your example is just not dynamic enough by any means, and technically, I am still using weapons.xml only mine as script="magewand.lua" in it....

P. S. I have programmed in a hit chance into the lua whereas wands the normal way always hit, which to me I think is very unfair....
 
Ok, well that I cant help you with, I am not a good .lua scripter myself, I can only do basics and modify, best of luck to you.

Just a tip; people love simplicity, but never abandon your ambitions for that reason.
 
First problem is solved thanks to Giddran, but for now the second part is my only issue how to make armor matter in all types of magic damage....
 
Back
Top