• New Horizons on Maelstrom
    Maelstrom New Horizons


    Visit our website www.piratehorizons.com to quickly find download links for the newest versions of our New Horizons mods Beyond New Horizons and Maelstrom New Horizons!

Fix in Progress [SOLUTION PROVIDED: EDITED FILE] Jar of Leeches is top priority target by Quick Heal hotkey

MrMister

Sailor Apprentice
Jar of Leeches is (I assume, going by the description) a cheap antidote that with suck away a bit of your health.

The Quick Heal function (from what I remember when I checked it out years ago) chooses by default the medicament item in your inventory that a) has health gain/regen and b) has the smallest health gain/regen (to both use cheaper stuff first and to avoid overhealing).

The problem is that Jar of Leeches' negative health regen makes it a valid target for Quick Heal, unlike normal antidotes (which lack any health regen). And not just that, but it will always be used (unless you change the setting to use the most powerful healing potions first), since its negative regen makes it the one with the smallest regen, and thus the highest priority target for the b) check.

I was not amused when I needed a patch-me-up and Eduardo went for a kiss instead.

Suggestion: slightly edit the quickheal function to also check that the item's health regen is positive.

If this is not fixed and just treated as a feature, then you *must* always manually select healing items when you carry leeches. You can't even give it yo your companions to carry I'm pretty sure, as they will succumb to the same fate. EDIT: Actually, LAi_UseHealthBottle has a `if(healthInBottle <= 0) return;` check, so they should be fine.
 
Last edited:
Here's the solution, PROGRAM\ITEMS\items_utilite.c.
Extract with changes:
//NK - 04-09-08 brand new, for finding _max_
float MaxHealthPotionForCharacter(ref chref, ref idx)
{
float ftmp;
bool isFinded = false;
idx = -1;
aref chritems; makearef(chritems, chref.items);
int n;
for(int i = 0; i < GetAttributesNum(chritems); i++)
{
if(sti(GetAttributeValue(GetAttributeN(chritems, i))) > 0)
{
n = GetItemIndex(GetAttributeName(GetAttributeN(chritems, i)));
if(CheckAttribute(&Items[n],"potion"))
{
if(CheckAttribute(&Items[n],"potion.health") && stf(Items[n].potion.health)>0)
{
if(isFinded)
{
if( stf(Items[n].potion.health)>ftmp )
{
ftmp = stf(Items[n].potion.health);
idx = n;
}
}else{
ftmp = stf(Items[n].potion.health);
isFinded = true;
idx = n;
}
}
}
}
}
if(!isFinded) return 0.0;
return ftmp;
}


// NK 04-09-08 rewrite for speed to search chref.items and match to array rather than vice versa. -->
float MinHealthPotionForCharacter(ref chref, ref idx)
{
float ftmp;
bool isFinded = false;
idx = -1;
aref chritems; makearef(chritems, chref.items);
int n;
for(int i = 0; i < GetAttributesNum(chritems); i++)
{
if(sti(GetAttributeValue(GetAttributeN(chritems, i))) > 0)
{
n = GetItemIndex(GetAttributeName(GetAttributeN(chritems, i)));
if(n >= 0 && CheckAttribute(&Items[n],"potion")) // LDH fix for negative index
{
if(CheckAttribute(&Items[n],"potion.health") && stf(Items[n].potion.health)>0)
{
if(isFinded)
{
if( stf(Items[n].potion.health)<ftmp )
{
ftmp = stf(Items[n].potion.health);
idx = n; // NK
}
}else{
ftmp = stf(Items[n].potion.health);
isFinded = true;
idx = n; // NK
}
}
}
}
}
if(!isFinded) return 0.0;
return ftmp;
}

I've tested it and can confirm that it works. I changed MaxHealthPotionForCharacter as well because otherwise if the player has no healing items besides the leeches, they would still use them.

Alternatively, you could instead change the leeches' "ispotion" value in PROGRAM\ITEMS\initItems.c from 1 to 0.

And while we are at it, testing seems to show that the leeches fail to apply the intended -10HP to to the player (value set initItems.c), they just cure poison and don't affect HP at all. I'll be posting this as its own bug on a new thread.
 
Thanks! I'll give that a try when I have time. Meanwhile, I've posted an attempted fix for negative HP in that other thread.
 
Back
Top