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

onHealthChange question regarding parameters

Dayon

New Member
Joined
Nov 12, 2012
Messages
15
Reaction score
1
Hello again and sorry for a lot of questions - I'm on a coding spree lmao.
Anyways.. I'm tinkering with different conditions to apply extra damage and such depending on attack type using the "onHealthChange" function in a creaturescript.
My question however is about what is referred to and being the differences between primary and secondary in the parameters of the function call?
Would a mutliplier on both primaryDamage and secondaryDamage for example apply on all type of damage or is it just auto attacks in one and runes/spells in another for example?

Lua:
 function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)

~BR
 
Solution
Primary and Secondary damage almost exclusively is for weapons with multiple attack damages.

Examples: Firesword. Has physical and fire damage.

So with regular hits and spell attack that use the weapon damage, these would give it primary and secondary damage types in the onHealthChange callback.


creature -- the one being attacked
attacker -- the one dealing damage
primaryDamage/secondaryDamage -- the amount of damage being dealt
primaryType/secondaryType -- the type of damage being dealt (physical,fire,ice,healing.. et cetera)
origin -- depending on your server version.. you might have none, some or all of these types. check luascript.cpp for what one's you have.
In most use-cases...
Primary and Secondary damage almost exclusively is for weapons with multiple attack damages.

Examples: Firesword. Has physical and fire damage.

So with regular hits and spell attack that use the weapon damage, these would give it primary and secondary damage types in the onHealthChange callback.


creature -- the one being attacked
attacker -- the one dealing damage
primaryDamage/secondaryDamage -- the amount of damage being dealt
primaryType/secondaryType -- the type of damage being dealt (physical,fire,ice,healing.. et cetera)
origin -- depending on your server version.. you might have none, some or all of these types. check luascript.cpp for what one's you have.
In most use-cases, you'll never need this though.
Code:
    ORIGIN_NONE
    ORIGIN_CONDITION
    ORIGIN_SPELL
    ORIGIN_MELEE
    ORIGIN_RANGED
    ORIGIN_WAND
    ORIGIN_REFLECT
 
Last edited:
Solution
Primary and Secondary damage almost exclusively is for weapons with multiple attack damages.

Examples: Firesword. Has physical and fire damage.

So with regular hits and spell attack that use the weapon damage, these would give it primary and secondary damage types in the onHealthChange callback.


creature -- the one being attacked
attacker -- the one dealing damage
primaryDamage/secondaryDamage -- the amount of damage being dealt
primaryType/secondaryType -- the type of damage being dealt (physical,fire,ice,healing.. et cetera)
origin -- depending on your server version.. you might have none, some or all of these types. check luascript.cpp for what one's you have.
In most use-cases, you'll never need this though.
Code:
    ORIGIN_NONE
    ORIGIN_CONDITION
    ORIGIN_SPELL
    ORIGIN_MELEE
    ORIGIN_RANGED
    ORIGIN_WAND
    ORIGIN_REFLECT
Thanks a lot. That made everything way more clear!
Quick question tho.. If there is an origin for spell and it doesn't consider a wand, spell - is there then another way within this function to get spelldamage done? If not you don't happen to know where that is handled and able to point me in the right direction? :p
I mean, I have successfully applied a damage bonus on weapon attacks but I'd like to also be able to apply a multiplier on casted spells.
 
Thanks a lot. That made everything way more clear!
Quick question tho.. If there is an origin for spell and it doesn't consider a wand, spell - is there then another way within this function to get spelldamage done? If not you don't happen to know where that is handled and able to point me in the right direction? :p
I mean, I have successfully applied a damage bonus on weapon attacks but I'd like to also be able to apply a multiplier on casted spells.
I haven't personally tested origin, but I assume ORIGIN_SPELL triggers for all instant spells in spells.xml.. maybe runes as well.

ORIGIN_WAND would only trigger for item.xml items that are listed as wands.. but might not trigger if they have some sort of custom script attached to them.

again, haven't touched it or tested. Best way to check is to just do tests yourself.

Lua:
if origin == ORIGIN_NONE then
    print("ORIGIN_NONE")
elseif origin == ORIGIN_CONDITION then
    print("ORIGIN_CONDITION")
elseif origin == ORIGIN_SPELL then
    print("ORIGIN_SPELL")
elseif origin == ORIGIN_MELEE then
    print("ORIGIN_MELEE")
elseif origin == ORIGIN_RANGED then
    print("ORIGIN_RANGED")
elseif origin == ORIGIN_WAND then
    print("ORIGIN_WAND")
elseif origin == ORIGIN_REFLECT then
    print("ORIGIN_REFLECT")
end
 
Back
Top