ToME: the Tales of Maj'Eyal

Everything about ToME
It is currently Fri Jul 21, 2017 6:51 am

All times are UTC




Post new topic Reply to topic  [ 15 posts ] 
Author Message
PostPosted: Fri Jun 16, 2017 2:34 am 
Offline
Sher'Tul Godslayer

Joined: Mon Feb 14, 2011 11:16 pm
Posts: 2242
Ok, I'm sort of going to start this again, now that I've figured out a lot more. Here are the main functions in order, without all the internal stuff. So, this is the BIG picture.

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:
functions attackTarget > attackTargetWith (per weapon), attackTargetHitProcs in combat.lua

Code:
attackTarget()

1. if attacker is afraid or terrified, the attack is cancelled
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:
attackTargetWith()
-- called per weapon as per above
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:
defaultProjector in damage_types.lua

1. ignore_direct_crits (these talents/equipment reverse the crit damage, but the hit still counts as a critical hit)
- 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 :-o)
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


onTakeHit() in actor.lua
1. invulnerable (then exit Stage Three)
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

_________________
MADNESS rocks


Last edited by jenx on Thu Jul 20, 2017 7:42 pm, edited 35 times in total.

Top
 Profile  
 
PostPosted: Fri Jun 16, 2017 10:58 pm 
Offline

Joined: Mon Apr 17, 2017 2:27 pm
Posts: 4
Helpful, quality post. Thank you!


Top
 Profile  
 
PostPosted: Sat Jun 17, 2017 5:22 am 
Offline
Sher'Tul Godslayer

Joined: Mon Feb 14, 2011 11:16 pm
Posts: 2242
Quidix wrote:
Helpful, quality post. Thank you!


Thanks. I ran an adventurer on insane and used this to guide my defensive choices. It helped a lot. I'm going to do this again and I'll post the results here.

_________________
MADNESS rocks


Top
 Profile  
 
PostPosted: Sat Jun 17, 2017 5:02 pm 
Offline
Magical Girl

Joined: Wed Aug 27, 2014 11:36 am
Posts: 388
It'd be nice if you could work on adding this information to the wiki :)

_________________
"As dying is one of the leading causes of death, you should avoid dying." -rekenner

"I'll bond with a cactus until my buttcheeks touch the sand before I play nethack again" -Gagarin


Top
 Profile  
 
PostPosted: Sat Jun 17, 2017 10:07 pm 
Offline
Sher'Tul Godslayer

Joined: Mon Feb 14, 2011 11:16 pm
Posts: 2242
Sheila wrote:
It'd be nice if you could work on adding this information to the wiki :)


Sure - where does it go in the wiki?

_________________
MADNESS rocks


Top
 Profile  
 
PostPosted: Sat Jun 17, 2017 10:09 pm 
Offline
Uruivellas

Joined: Sun Jun 15, 2014 12:19 am
Posts: 967
Location: Yeehaw, pardner
jenx wrote:
Sheila wrote:
It'd be nice if you could work on adding this information to the wiki :)


Sure - where does it go in the wiki?


I'm no wiki expert, but this seems like a good place.
https://te4.org/wiki/Combat_Damage#Damage_Reduction

_________________
A little bit of a starters guide written by yours truly here.


Top
 Profile  
 
PostPosted: Tue Jun 20, 2017 3:03 pm 
Offline
Thalore

Joined: Mon Mar 28, 2011 12:42 pm
Posts: 167
I believe you missed Possessor's Channel Pain.

Does Danger Sense's second save apply to Dismissal?


Top
 Profile  
 
PostPosted: Wed Jun 21, 2017 8:19 am 
Offline
Sher'Tul Godslayer

Joined: Mon Feb 14, 2011 11:16 pm
Posts: 2242
Snarvid wrote:
I believe you missed Possessor's Channel Pain.

Does Danger Sense's second save apply to Dismissal?


Aha - well spotted. I'll code dive to find where CP goes.

Re Dismissal, for all these talents, I just want to know the order and, with my addon, the value. So I don't go into all the factors that affect each.

_________________
MADNESS rocks


Top
 Profile  
 
PostPosted: Thu Jun 22, 2017 6:56 am 
Offline
Cornac

Joined: Wed Sep 28, 2016 8:07 pm
Posts: 38
I would love it SOOOO much if your addon also added numbers to talent description corresponding to when its damage reduction gets applied (so crit reduction talents would have a 1, abyssal shield would have 12, etc.) so that it would be easier to compare talents/plan builds without having to tab between tome and a browser.


Top
 Profile  
 
PostPosted: Thu Jun 22, 2017 7:24 am 
Offline
Sher'Tul Godslayer

Joined: Mon Feb 14, 2011 11:16 pm
Posts: 2242
Pisastrish wrote:
I would love it SOOOO much if your addon also added numbers to talent description corresponding to when its damage reduction gets applied (so crit reduction talents would have a 1, abyssal shield would have 12, etc.) so that it would be easier to compare talents/plan builds without having to tab between tome and a browser.


Ok, I"ll do what I can!

This would be in the log of course, otherwise the onscreen display will be filled up with info

_________________
MADNESS rocks


Top
 Profile  
 
PostPosted: Sun Jul 16, 2017 10:57 am 
Offline
Sher'Tul Godslayer

Joined: Mon Feb 14, 2011 11:16 pm
Posts: 2242
just to say, i'm working hard on this, and the addon is getting closer to being ready!

_________________
MADNESS rocks


Top
 Profile  
 
PostPosted: Sun Jul 16, 2017 11:52 am 
Offline
Wyrmic

Joined: Tue Feb 10, 2015 1:41 pm
Posts: 283
You didn't mention the heavy armor mastery crit reduction I think. If I'm not wrong it should be the very first thing checked since it actually works on the very chance to crit in the first place.


Top
 Profile  
 
PostPosted: Sun Jul 16, 2017 12:44 pm 
Offline
Sher'Tul Godslayer

Joined: Mon Feb 14, 2011 11:16 pm
Posts: 2242
Mordy wrote:
You didn't mention the heavy armor mastery crit reduction I think. If I'm not wrong it should be the very first thing checked since it actually works on the very chance to crit in the first place.


Aha - well spotted. I actulaly have it in my addon, but not in the list above. It is checked after armor reduction occurs. I've edited the list.

_________________
MADNESS rocks


Top
 Profile  
 
PostPosted: Mon Jul 17, 2017 10:14 pm 
Offline
Archmage

Joined: Mon Dec 15, 2014 10:08 pm
Posts: 326
ontakehit section, chance to avoid any damage, did you leave out The Cog, 10% chance if I recall correctly? I think it was a limited time item to celebrate the launch of EoR

_________________
"You could skip it, i think it drops 0 xp and 1 copper [at most], you are better off selling oxygen to beggars to become rich."


Top
 Profile  
 
PostPosted: Wed Jul 19, 2017 9:46 am 
Offline
Sher'Tul Godslayer

Joined: Mon Feb 14, 2011 11:16 pm
Posts: 2242
Coldbringer wrote:
ontakehit section, chance to avoid any damage, did you leave out The Cog, 10% chance if I recall correctly? I think it was a limited time item to celebrate the launch of EoR


Yes. I'll add it in. Thanks

_________________
MADNESS rocks


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 15 posts ] 

All times are UTC


Who is online

Users browsing this forum: Bing [Bot] and 1 guest


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group