devilutionX icon indicating copy to clipboard operation
devilutionX copied to clipboard

Plr2PlrMHit and PlayerMhit refactoring

Open k-bar opened this issue 3 years ago • 1 comments

As Plr2PlrMHit and PlayerMhit both has duplicate code. This PR focus mainly on clean that code and merge it together into one TryHitPlayer function without any important changing to how game mechanics works.

It is highly recommended to review commit by commit, since many things are moved in files.

Some small not important changes to mechanics will be noted here:

  1. Some redundant RNG rolls are not done if not needed (thanks to unified reorder of functions internals)
  2. Added check for player immunity for Holy Bolt missiles from monsters and trap.
  3. Added check for positive player HP for missiles from player (could be redundant, but it is unified in extracted function)
  4. Added check for MIS_ACIDPUD for Player missile while checking block possibility.

k-bar avatar May 27 '22 14:05 k-bar

Please assist me with extracted functions placement in files for this commit: https://github.com/diasurgical/devilutionX/pull/4606/commits/7b03ba60fb58408461fd64e6707ef15c3987419b I placed new functions at the end of struct / file.

k-bar avatar May 27 '22 21:05 k-bar