Page 1 of 1

Catching Melee Attacks

PostPosted: Monday, 9th January 2017, 03:46
by duane
Can anyone tell me an easy way to run code whenever the player is hit by a melee attack? I'd also need the attacker's id and how much damage was done. I've been trying to follow the combat code, but it's still not crystal clear to me.

Re: Catching Melee Attacks

PostPosted: Tuesday, 10th January 2017, 10:35
by stickyfingers
Run with a debugger (for example: gdb crawl), set a breakpoint in player::hurt (b player::hurt in gdb), then go and fight. "amount" variable is the amount of damage. Note that it can get modified later in the Attack class functions and by "fineff" effects.

Re: Catching Melee Attacks

PostPosted: Tuesday, 11th April 2017, 20:52
by tasonir
Looks like that file has been changed and the correct line for hurt is now here: http://git.develz.org/?p=crawl.git;a=bl ... HEAD#l6458 (about 200 lines up)