I list first the .lua file, and then the function called. And to reiterate, this is only for melee hits so far. VARIOUS indicates that the callbacks are located in various files (obviously!).
1. attackWith() in Combat.lua -- attempts to attack a Player or NPC with all melee weapons, and calls attackTargetWith() for each
--2. attackTargetWith() in Combat.lua -- attacks with one weapon, and calls setDefaultProjector() for each damage type (ie BLIGHT, PHYSICAL, etc), and then calls attackTargetHitProcs()
----callbackOMeleeAttackBonuses() in mental.lua (for talent Expose Weakness)
----3. setDefaultProjector() in damage_types.lua -- determines damage to a grid (i.e. Player, NPC, etc), and calls takeHit() to do the damage
------callbackOnTakeDamageBeforeResists() in VARIOUS
------callbackOnTakeDamage() in VARIOUS -- note that this can reduce damage taken, as it has still not been subtracted from Player's life
------4. takeHit() in ActorLife.lua -- will actually do damage to Player or NPC, but first calls onTakeHit(), which can reduce damage to zero
--------5. onTakeHit() in Actor.lua -- adjusts value of damage that has been sent to takeHit()
----------callbackOnHit() in VARIOUS
----callbackOnMeleeHit() in VARIOUS
----6. attackTargetHitProcs() in Combat.lua -- manages procs from one weapon, as called in 2. above
------3. to 5. as per above, for each damage type
--------callbackOnMeleeAttack() in VARIOUS
The functions interact in a less linear way than I first realised, so I've removed the Stage 1,2, 3 ideas below and just given the lua files, which correspond to above.
This is very complicated, but I'm making great progress on my addon, which is why I'm learning so much more about how this works in detail.
Also, I've changed the addon to track both the damage you receive AND the damage you dish out (melee only so far).
And, I've added a system of indents to the log so I can see how the code moves between functions. This is really cool and once it is ready, I'll post it.
----------------------------------------
It's also crucial to realise that for almost all steps below, the reduced value is passed onto the next step. For example, let's say 2000 damage comes your way. Daze reduces this to 1200. Stun then reduces 1200 to 600. then if a talent reduces by 100 up to 50%, then it will change to 500. If the next talent reduces by 20% it will change to 400, which is 80% of 500. etc etc This is why fixed amount reductions, and daze and stun (and armour if applicable) in particular are more valuable than you might think, because in percentage terms they before MORE effective at each stage.
For my own record-keeping, I've put an asterisk after each one that I've tried to code so far.
So, here are the talents/equipment/prodigy/whatever that reduce damage in the various functions above:
Code: Select all
functions attackTarget > attackTargetWith (per weapon), attackTargetHitProcs in combat.lua
Code: Select all
attackTarget()
2. breaking stealth is checked (and so this affects dmg)
3. intuitive shots (cancels attack)
4. warding weapon (cancels attack)
5. gesture of pain modifies attack
6. mainhand weapon attacks with attackTargetWith()
7. offhand weapon attacks with attackTargetWith()
8. otherwise unarmed attacks with attackTargetWith()
9. cleave can trigger attackTarget again (so back to 1)
10. flexible combat can trigger attackTarget again (so back to 1)
Code: Select all
attackTargetWith()
11. does the blow connect? (it's complicated... and effected by talents: stalker, predator)
12. repel (strife tree) can repel an attack
triggerHook()
callbackOnMeleeAttackBonuses()
13. Checks for talents that repel a melee attack, in the following order. If any succeed, attack is cancelled
- skirmisher buckler expertise
- weapon warding
- blade ward
- intuitive shots
- stoneskin
14. evasion, which also cancels attack
if no evasion, code then proceeds, as follows
15. parry (removes crit damage)
16. gesture of guarding (reduces dmg)
17. knife accuracy bonus increases APR
18. armour (minus opponent's APR), affected by hardiness% then reduces damage <== IMPORTANT
19. range multiplier of weapon increases damage
physicalCrit() to determine critical damage (lots of talents affect this!)
--includes callbackOnCrit()
--includes crit chance reduction, which is given by: heavy/massive armour, Borfast's Armour (+20), Daneth's Neckguard (+10)
20. mace accuracy increase damage
21. if target has counterstrike effect, damage is increased further (by lots !)
22. crushing blow
23. damage conversion then takes place, because any converted damage does NOT pass to Stage Two
24. finally, damage is now determined and Stage Two is called
callbackOnMeleeHit()
if attack misses btw, callbackOnMeleeMiss() occurs here
25. crosstier effects are applied
callbackTargetHitProcs()
- staff accuracy bonus
- ogre 2handed penalty
- stalker
- spread diseases
- melee projection (calls Stage Two)
- shadow combat
- ruin (calls Stage Two)
- weapon folding
- arcane combat
- on hit talents
- on crit talents
- shattering impact
- backlash
- burst on hit
- critical burst on hit
- arcane destruction
- onslaught
- reflected damage/armour
- acid splash
- blood bath
- mortal terror
- psi auras
- static discharge
- exploit weakness
- on kill effects
- regen on hit
- ablative armour
- stone shield
- step up
- counter attack
- gesture of guarding
- defensive throw
- zero gravity
- roll with it
- weakness
- marked prey
- dismayed
- curses
- shards
- callbackOnMeleeAttack
26. life steal occurs
27. weapons with multiple attacks trigger attackTargetWith() (so go back to step 11

Code: Select all
defaultProjector in damage_types.lua
- Reflex Defence
- Foresight
- Ice Core
- Indiscernible Anatomy
- Petrified Wood (eq)
- Rogue's Plight (eq)
- high-level randarts can get this, but it is rare
1.1 increase dmg for unseen attackers *
2. easy difficulty of game reduces all damage now by 70% *
2.1 increase damage for global accuracy damage bonus *
3. dazed (source) reduces by 40% *
4. stunned (source) reduces by 50% *
5. invisible (source) *
6. numbed (source) *
7. generic damage penalty (source) *
premonition is added to resistance at this point, but the effect isn't operative until 12 below *
8. ward(s) *
9. block (i.e. using your shield) *
10. forge shield *
a number of talents at this point can increase damage before it hits
- demonic blood (source)
- entity type (undead, demon etc)
- being asleep
- mind link
- rigor mortis
- dark vision
-back stab
callbackOnTakeDamageBeforeResists()
11. resistance to entity type (e.g. resistance to summoned creatures dmg)
12. resistance (this also takes into account things like resistance penetration, domination, expose weakness, and being asleep)
- premonition (it gets added to resistance)
13. kinetic shield *
14. psionic shield *
15. charged shield *
16. abyssal shield *
17. antimagic shield *
18. armor * (??? but it is used in Stage One, so not entirely sure what happens here

Note that several talents can add armor-like negation of damage:
- Eternity's Counter (equipment)
- striking stance
- tessellation
20. roll with it (a prodigy) *
21. resistance to unseen attackers *
22. sanctuary *
23. dark empathy (reduce dmg to self from your minions) *
24. curse of misfortunte (can increase damage) *
25. crushing blow (if it lands, you die

callbackOnTakeDamage
- energy decomposition
- chant of acolyte
- damage smearing (strictly speaking this spreads dmg out over turns, it doesn't reduce dmg)
- webs of fate
- forcefield
- molten metal
- agile defence
- trained reactions (mobility and acrobatics)
- temporal fugue
- brawler block
- chromatic resonance (given by Ureslak's Molted Scales)
25. resolve
26. unstoppable will be checked here
Code: Select all
onTakeHit() in actor.lua
2. chance to avoid any damage (then exit Stage Two). This chance can be granted by:
- windborne azurite 8%) - equipment
- flash of the blade (100%) *
- leaves tide (~ 25-40%) *
- concealment (~ 18-48%) *
- tempest of metal (~ 8-25%) *
3. phase shift (each has a different percentage chance to avoid damage) *
- elemental surge prodigy (100% chance)
- phase shift chronomancy effect (variable chance of reduction ??)
- fast as lightning prodigy (50% chance to avoid all damage ??)
- lucky day prodigy (10% chance to avoid all damage)
4. retribution *
5. two talents reduce incoming damage: snipe and skirmisher trained reactions *
6. skirmisher defensive roll
7. mitosis *
8. displacement shield *
9. time shield *
10. damage shield (this include shielding runes and some shileding talents are simple damage shields) *
11. shadow empathy *
12. disruption shield *
13. bone shield *
===> at this point, if dmg is 0 then Exit Stage Three
14. deflection *
15. tenacity (from rampage) *
NB - Achievements for Damage Size are calculated here
16. iceblock (because it takes dmg for you) *
17. dismissal *
===> at this point, if dmg is 0 then Exit Stage Two
18. resonance field *
19. cauterize *
20. clone on hit (only horrors and oozes have this, so perhaps a possessed one would benefit??)
21. solipsism *
22. unstoppable * [no need for addon to log this]
23. second life (triggers if you are going to die otherwise)
24. heart start (triggers if you are going to die otherwise)
25. shadow decoy (triggers if you are going to die otherwise)
===> at this point, if dmg is 0 then Exit Stage Three
26. contingency (triggers here if required but I'm not sure if it works in the same hit, or waits till next hit)
27. flat damage cap talents (these limit the total dmg from a hit as a percentage of your max life) *
- grinding shield (90-60%) *
- ghoul (90-50%)
- sun cloak (87-65%) *
28. eldritch stone
29. stone shield
30. stone link
31. ## callbackOnHit (not sure of order)
- osmosis shield
- grinding shield (the melee dmg reduction part)
- link of pain
- reality smearing
- contingency
- guardian unity
- infestation
- temporal fugue
- subcutaneous metallisation
- shieldsmaiden (if equipped)
One thing I can't work out is the order in which callbacks occur, so I state this whereever they are listed.
Edit History:
18 June 17 - added phase shift to Stage 3
18 June 17 - added snipe and clarified trained reactions
20 June 17 - added Subcutaneous Metallisation
22 June 17 - added Grinding Shield melee reduction in callbackOnHit code section
23 June 17 - moved premonition to resistances
23 June 17 - started to code Stage 2 damage output to log
23 June 17 - began to add steps in damage calculation that increase damage too, numbering them x.1, x.2 etc in the lists above
23 June 17 - added daze, stun, invisible, numb, and generic dmg penalty adjustments to Stage 2
23 June 17 - added molten metal to stage 2
24 June 17 - added sources of increase dmg in stage 2
26 June 17 - realised there are three main stages for melee hits/talents (LOL) and so redid the whole lot above, adding a new first stage (and there are still other pathways to continue)
15 July 17 - rewrote new overview at start of post, as I realised it was even more complex than I thought (duh!)
16 July 17 - added crit chance reduction from heavy/massive armour, Borfast's Cage, and Daneth's Neckguard
To Do:
projectile evasion (lots of talents to look at here)
work out order of callback talents
add Channel Pain (possessor talent), and check other possessor talents
build adventurer with sun cloak and grinding shields to see if flat_damage_cap applies twice, or ???
work out the effects of callbackOnMeleeHit