Note: onStatsChange will only trigger if the health / mana of it's target is being moved up / down.
So if someone 'blocks' an attack, there is no trigger of onStatsChange.
onStatsChange(cid, attacker, type, combat, value)
cid
- creature being attacked or healed.
attacker
- creature attacking cid
type
- type of stat change
Lua:
STATSCHANGE_HEALTHGAIN = 0
STATSCHANGE_HEALTHLOSS = 1
STATSCHANGE_MANAGAIN = 2
STATSCHANGE_MANALOSS = 3
combat - type of combat
Lua:
COMBAT_NONE = 0
COMBAT_PHYSICALDAMAGE = 1
COMBAT_ENERGYDAMAGE = 2
COMBAT_EARTHDAMAGE = 4
COMBAT_POISONDAMAGE = 4
COMBAT_FIREDAMAGE = 8
COMBAT_UNDEFINEDDAMAGE = 16
COMBAT_LIFEDRAIN = 32
COMBAT_MANADRAIN = 64
COMBAT_HEALING = 128
COMBAT_DROWNDAMAGE = 256
COMBAT_ICEDAMAGE = 512
COMBAT_HOLYDAMAGE = 1024
COMBAT_DEATHDAMAGE = 2048
value
- amount of healing / damage being dealt to creature.
Note; This is the FINAL DAMAGE to the creature.
So if the creature has 14 hp, and is hit by a 8000 damage attack, this script will only show 14 as the value.
On a separate note, this also means that if the creatures armor reduces the damage being taken by 15%, and your script reduces it by 5%, you will be 'double dipping' on your damage calculations.
Same for increasing the damage.
Example: 8000 damage
Expected Result:
increase 15% by armor + 15% by script -> 30% total = 8000 * 1.3 = 10400
Actual Result:
increase 15% by armor -> 8000 * 1.15 = 9200 AND THEN increase by 15% in script -> 9200 * 1.15 = 10580
--
Which brings us to our last point;
You cannot adjust the amount of damage or healing being applied to the creature during the scripts execution. You only have the option of true(allow) / false(disallow) the damage.
While this does not mean we cannot adjust the damage/healing, it's just a bit more annoying to do so, and in rare cases can cause unforseen issues.
(Need to return false original statChange and make our own statChange, making sure it doesn't 'infinite loop')
---
So yes, onStatsChange is useful, but only in specific use-cases.
-----------
Onto your question.., there is no way to determine if it is an auto-attack, since it only checks the damage type, not the damage source.
Likely the only way to accomplish what you want is with a source edit so you have more parameters to work with.