Bug - Won't Fix HP tracking for demonic Gorgolok gets thrown off by protective shells

zarqon

Well-known member
When you deal damage to the shells surrounding Gorgolok, mafia treats this as damage to Gorgolok himself, so even though 0 damage was dealt to the monster, mafia subtracts the damage dealt to the shell. This results in Gorgolok having well below -300 HP by the time you destroy all of the shells, rendering combat scripts useless in making decisions based on his HP.

Here's the message being parsed as damage, which is actually just shell destruction (pasted from source):

Code:
You deal 124 damage to one of the massive bone spikes surrounding Gorgolok, snapping it.

I was buffed to the point where I never saw the message where you fail to break one of the shells, but as it describes "X damage" it may also need to be excluded (pasted from Wiki):

Code:
You hammer on the bone spikes with all your might, but <some> damage isn't enough to break any of them.
 

slyz

Developer
I'm not really sure how to take this into account. In the regex pattern Mafia uses to match for damage, we specify things we don't want to see in front of the number (like "you lose", "you gain", etc...). Anything else that contains "X damage" will be considered damage done to the monster, and anything after "damage" won't be captured.
 

zarqon

Well-known member
Since I don't think it's possible to damage him until all the shells are smashed, you might just want to discount all damage to demon Gorgolok until the last shell image is broken one -- I'm not sure if that would work, but it would be better than the current situation, at least?
 

slyz

Developer
There are two ways to modify the RegEx pattern. I'll enclose it in a Regex Tongs block, it's a very dangerous one:
Code:
(your blood, to the tune of|stabs you for|sown|You lose|You gain|strain your neck|approximately|roughly|)\\s*#?(\\d[\\d,]*) (\\([^.]*\\) |)((?:[^\\s]+ ){0,3})(?:\"?damage|points?|bullets|hollow|notch(?:es)?|to your opponent|to the foul demon|force damage|tiny holes|like this, it's bound)
If the first group isn't empty, it's not damage. Then we capture the number, and any numbers enclosed in parenthesis that comes after it. Then we capture up to three words that precede one of the strings KoL uses for damage. This allows us to discard things like "You hand the 33398 scroll to your opponent", which look like a damage message:
PHP:
if ( m.group( 4 ).equals( "shambles up " ) || m.group( 4 ).equals( "scroll " ) )
{
	return 0;
}

In the case of Gorgolok's bone spikes, we could do two things:
  • add a negative lookahead to "damage": "damage(?! to one of the massive bone spikes)".
  • add "to one of the massive bone spikes" at the end, and check for "damage " in group( 4 ).

I wonder which is better fix, performance-wise. I also wonder if it matters much :)
If adding the lookahead is better, then it we should probably also remove the 4th capturing group and add a negative lookbehind to "to your opponent" to avoid using both the RegEx and m.group( 4 ).equals().
 

heeheehee

Developer
Staff member
Considering that this written in Java, why not just extend the Pattern class with a KoLPattern class that replaces all prepositions in the constructor argument with some pattern like "(about|above||...)"? Sure, it's not particularly efficient, but you *could* check that form iff the sword behind inappropriate prepositions is equipped (There shouldn't be any case in which you strictly can't tell that you have the sword equipped where it could affect something, right?), and just use the standard pattern otherwise.
 
Top