• 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!

Fixed Tutorial: Levelling up during Sword Fight triggers end to the fight

Pieter Boelen

Navigation Officer
Administrator
Storm Modder
Hearts of Oak Donator
This bug is a PROPER ANCIENT one; I just never bothered to report it until now.
Used to not be so much of a problem, but now that this sword fight is so much harder than it used to be, it was quite annoying this time.

The problem is simple: You fight Malcolm and gain a Level-Up through the experience you gained.
But the moment you do, that triggers the dialog of "apparently you need more training".

The check is triggered through this line of code:
Code:
Lai_SetCheckMinHP(PChar, 0.5*LAi_GetCharacterHP(PChar), false, "SeriousFightFinished"); // KK
I'm assuming the actual checking is being done by the game engine and we cannot quite see how it works.

Not sure why though. Is there a tiny period of time where your HP is set to 0?
Or does your HP get set to a lower relative value than before?
But I cannot see in the ResetMaxHP that it should be doing any of that. :confused:
 
Couldn't find why it was doing that.
But this should fix the problem too:
Code:
float ResetMaxHP(ref chr)
{
    //Save the hpchecker for this moment
    float hpchecker = 0;
    if(CheckAttribute(chr, "chr_ai.hpchecker")) hpchecker = chr.chr_ai.hpchecker;
    DeleteAttribute(chr,"chr_ai.hpchecker");
    //First let's save the percentage of HP we have at the moment.
    float HPper = 1;
    if(CheckAttribute(chr,"chr_ai.hp") && CheckAttribute(chr,"chr_ai.hp_max")) HPper = stf(chr.chr_ai.hp)/stf(chr.chr_ai.hp_max);
    int type = 0;
    int PlayerHPperLevel = CHAR_HITPOINTS_PER_LEVEL;
    float HP = CHAR_START_HITPOINTS;
    float level = makefloat(GetLevel(&chr));
    if(!CheckAttribute(chr,"FakeLevels")) chr.FakeLevels = 0; //Levis
    level = level + sti(chr.FakeLevels); //Levis
    if(CheckAttribute(chr, "HPBonus")) HP += stf(chr.HPBonus);
    HP += GetHPBaseBonusOT(chr);
    //For now friendly and not friendly are the same, might change later.
    if(CharacterIsFriend(chr))
    {
        //Friendly
        PlayerHPperLevel = (PlayerHPperLevel+1)-GetDifficulty()+GetHPLevelBonusOT(chr);
    }
    else
    {
        //Not Friendly
        PlayerHPperLevel = (PlayerHPperLevel)-(4-GetDifficulty())+GetHPLevelBonusOT(chr);
    }
    HP += (level-1) * PlayerHPperLevel;
    if(IsCharacterPerkOn(chr, "Toughness"))
    {
        HP = HP * 1.1;            // 10% health bonus for the tough guys
        chr.chr_ai.hp_dlt = LAI_DEFAULT_DLTHP * TOUGHNESS_REGEN_MULT; // higher regeneration rate, default is 0.1 - LDH 14Apr09
    }
    chr.chr_ai.hp_max = HP;
    //Apply the percentage again to the new HP (if we have any change)
    chr.chr_ai.hp = HP * HPper;
    //Return the hp checker
    if(hpchecker > 0) chr.chr_ai.hpchecker = hpchecker;
    return HP;
}

just disable the HPchecker for a moment when doing the hp change
 
Is there any point in me later doing a line-by-line check on this one or did you already do that?
 
it doesn't work. made a mistake. new version coming shortly.
testing it very closely because this problem might pop up at other points too.
 
@Levis: Would you explaining how this fix is now meant to work? I'm confused by all that 'old' stuff. :facepalm
 
@Levis: Would you explaining how this fix is now meant to work? I'm confused by all that 'old' stuff. :facepalm
The problem was for the tutorial your HP is also set to 400 and if it goes below 200 you fail.
So what the game does is it stores your old HP in a variable and overwrites it with a new one. As soon as resetHP is called the HP is set back to the normal calculated HP.
At least thats what is happening now. Before during resetmaxhp this was also happening. so your HP was set to 79 or so (what is should be) when you level up, so it dropped below 200.
I now remember I do need to look into NPC's which are set this way in the character init and call resetHP at least once during the init.
Could you maybe change the ResetMaxHP in FinishCharInit to ResetHP?
 
Back
Top