• 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 primaryDamage * 2 doesn't work correctly with attacks?

Yuggi

Member
Joined
May 18, 2017
Messages
64
Reaction score
10
Code:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    primaryDamage = primaryDamage * 10
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

I have this code, whenever I attack with a spell or a wand the damage will always be 10x. However when I attack with a melee weapon or paladin weapons, the damage can be super low. I think it has something to do with the minimum attack damage done by normal weapons in the source code. For example a level 400 knight would always hit 200-400 with normal attacks, but after it has been modified by primaryDamage = primaryDamage * 10, it will sometimes even do less than 200 (and NORMAL attacks can never hit below that) and still all spells and wands will modify the damage correctly.

How can I fix this issue=?
 
Solution
What protocol?

as far I remember melee dmg was always taken from normal_random(0, max_dmg)

Add some prints and watch terminal

Code:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    print("Primary dmg = "..primaryDamage)
    primaryDamage = primaryDamage * 10
    print("Primary dmg 10x= "..primaryDamage)
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

Compare terminal output with real values ingame.
What protocol?

as far I remember melee dmg was always taken from normal_random(0, max_dmg)

Add some prints and watch terminal

Code:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    print("Primary dmg = "..primaryDamage)
    primaryDamage = primaryDamage * 10
    print("Primary dmg 10x= "..primaryDamage)
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

Compare terminal output with real values ingame.
 
Solution
you're probably registering it to your player, not monsters or creatures
that will only execute if your player is hit, not if your player hits something else
 
you're probably registering it to your player, not monsters or creatures
that will only execute if your player is hit, not if your player hits something else


thanks sir but u cant read? i state spells do the correct damage. it's registered correctly.

anyways. I think the issue is the dmg just was just too random, and i didnt test it enough. I also added a minimum extra dmg based on a players levels if the dmg is from an auto atk to make all crits feel more powerful
 
Back
Top