• 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 Street Merchant HP Increasing during Attack

Pieter Boelen

Navigation Officer
Administrator
Storm Modder
Hearts of Oak Donator
So I wanted to do a quick check on the performance of the LoginCharacter function.
Therefore I wanted to kill a street merchant as that makes for quite a good test.
But it didn't go as planned. While I was attacking, the merchant HP kept increasing up to the point where it reached 3000(!):
upload_2015-9-12_10-58-34.png


This went together with the occasional very serious lag in the middle of me attacking; I thought the game was going to crash!
And when I face the merchant, is the guy dead or not?
upload_2015-9-12_10-59-45.png


None of this seems to make ANY sense and definitely didn't use to be like this.
I suspect it is related to @Levis' levelling changes, but how or why, I do not know.

Can somebody else try to confirm this?
I simply:
- Started a new game with Assassin
- Checked the first trader's good so he would actually have some
- Start hacking away and observe the weirdness o_O
 
For reference, here are his skills before my attack:
upload_2015-9-12_11-4-48.png

Seems like surprisingly high skills to begin with! Really high level too.

Should should his HP not be 24*10+40 = 280? 308 doesn't match with the character level and is also quite a strange number as you get "10" per level.

The same applies to the merchant next to him.
For abilities, they've got all the personal ones down to "Professional Gunman":
upload_2015-9-12_11-7-59.png
 
This weird "HP increasing while being attacked" thing does NOT apply to the soldiers.
 
The most recent older version I've got is "Build 14 Beta 3.5 WIP: 25 Jul 2015".
That one definitely did NOT have this issue yet, so it was introduced somewhere in the last two months.
 
Can somebody else try to confirm this?
I simply:
- Started a new game with Assassin
- Checked the first trader's good so he would actually have some
- Start hacking away and observe the weirdness o_O

Tried to check this - got inconsistent results

1) - Started Game - Started Assassin story - Attacked Merchant:-

Merchant HP increased as per your image - NO large gain in Player Experience & Leveling.

2) - Went back to main Game Screen then Started New Assassin Story - Attacked Merchant:

Merchant HP increased as per your image - PLUS large gain in Player Experience & Leveling.

3) - Exited Game completely - Started game - Started Assassin story - Attacked Merchant:-

Merchant HP increased as per your image up to 2000approx then started to slowly decline - NO large gain in Player Experience & Leveling.

4) - Went back to main Game Screen again then Started New Assassin Story - Attacked Merchant:

Large gain in Player Experience & Leveling. - managed to kill merchant ( HP not increasing ) - Large number of soldiers attack player - manage to kill them all - no player large amounts of Leveling up while fighting soldiers.

Attached are logs from #4

from compile .log - what is this doing if I am playing Assassin Story :napoleon

Init character names complete.
storyline\WoodesRogers\SL_utils.c not loaded, loading now!
Init character names complete.



:drunk
 

Attachments

  • compile.log
    11.1 KB · Views: 109
  • system.log
    8 KB · Views: 101
Last edited:
@Pieter Boelen could you enable the xp debug and try again and post the log? I can look at it later. Sound like he is levelling way to quickly...
 
@Levis: Why is that street merchant showing as officer type "tough" in that interface screenshot above?
I thought you deliberately added a new officer type specially for merchants. :confused:
 
@Levis: Why is that street merchant showing as officer type "tough" in that interface screenshot above?
I thought you deliberately added a new officer type specially for merchants. :confused:
Probably because either there is a officertype set for him already somewhere. Or someone didn't set Lai_merchant type for him. In that case he get a random civilian type assigned.
 
Where is his officer type supposed to be set to merchant then?
I don't remember that being set deliberately for any character in the init files.
 
Where is his officer type supposed to be set to merchant then?
I don't remember that being set deliberately for any character in the init files.
If there Lai template is set to Merchant they will get the offictype now.
There is something like setmerchanttype or so in them.
 
If there Lai template is set to Merchant they will get the offictype now.
There is something like setmerchanttype or so in them.
There are two item traders in the "Douwesen_Port" location and they both already have this applied:
Code:
LAi_SetMerchantType(ch);

Looks like that adds an attribute to these characters:
Code:
//Установить персонажу тип торговца
void LAi_SetMerchantType(aref chr)
{
   chr.chr_ai.type = LAI_DEFAULT_TYPE;
   LAi_type_merchant_Init(chr);
   LAi_group_MoveCharacter(chr, LAI_DEFAULT_GROUP);
   chr.isMerchant = true; //Levis
}

//Установить персонажу тип торговца, без перемещения в группу
void LAi_SetMerchantTypeNoGroup(aref chr)
{
   chr.chr_ai.type = LAI_DEFAULT_TYPE;
   LAi_type_merchant_Init(chr);
   chr.isMerchant = true; //Levis
}
Which should later trigger the "merchant" officer type in Leveling.c:
Code:
void CheckCharacterSetup(ref chref)
{
   if (!CheckAttribute(chref,"id")) {chref.id = "without_id"; }
   if (!CheckAttribute(chref,"rank")) {chref.rank = 1; }
   if (!CheckAttribute(chref,"Experience")) {chref.Experience = 1; }
   if (!CheckAttribute(chref,"perks.FreePoints")){chref.perks.FreePoints = 0; }
   if (!CheckAttribute(chref,"skill.freeskill")){chref.skill.freeskill = 0; }
   if (!CheckAttribute(chref,"quest.officertype"))
   {
     if(DEBUG_EXPERIENCE>0) TraceAndLog("Character "+GetMySimpleName(chref)+" is missing his officertype");
     if(CheckAttribute(chref,"isOfficer"))
     {
       if(chref.isOfficer == "1") chref.quest.officertype = GetRandomOfficerType();
     }
     else
     {
       if(CheckAttribute(chref,"issoldier"))
       {
         if(chref.issoldier == "1") chref.quest.officertype = OFFIC_TYPE_GUARD;
       }
       else
       {
         if(CheckAttribute(chref,"isMerchant"))
         {
           if(chref.isMerchant == "1") chref.quest.officertype = OFFIC_TYPE_SHOPKEEPER;
         }
But apparently it doesn't in this case? o_O
 
Found the problem.
In initcharacter it says this:
Code:
    if (!CheckAttribute(ch, "isSoldier")) ch.isSoldier = false;
So isSoldier will always be set (except probably for phantoms)
So I need to change the logic instead of using an else it should be an new if statement.
 
What about GetAttribute? That one can check also if it is set to 'true' .
 
Now changed to this:
Code:
bool isset = false;
    if (!CheckAttribute(chref,"quest.officertype"))
    {
        if(DEBUG_EXPERIENCE>0) TraceAndLog("Character "+GetMySimpleName(chref)+" is missing his officertype");
        if(CheckAttribute(chref,"isOfficer") && !isset)
        {
            if(chref.isOfficer == "1") { chref.quest.officertype = GetRandomOfficerType(); isset=true; }
        }

        if(CheckAttribute(chref,"issoldier") && !isset)
        {
            if(chref.issoldier == "1") { chref.quest.officertype = OFFIC_TYPE_GUARD; isset=true;}
        }
       
        if(CheckAttribute(chref,"isMerchant") && !isset)
        {
            if(chref.isMerchant == "1") { chref.quest.officertype = OFFIC_TYPE_SHOPKEEPER; isset=true;}
        }
       
        if(!isset)
        {
            chref.quest.officerType = GetRandomNPCType();
        }
    }

I think this works just as fine. I expect more cases will be added there later ;).
 
Last edited:
Could someone test this?
I tried this section of code which looks a bit shorter and should do the same thing:
Code:
    if(GetAttribute(chref,"isOfficer") == 1)
     {
       chref.quest.officertype = GetRandomOfficerType();
     }
     else
     {
       if(GetAttribute(chref,"issoldier") == 1)
       {
         chref.quest.officertype = OFFIC_TYPE_GUARD;
       }
       else
       {
         if(GetAttribute(chref,"isMerchant") == 1)
         {
           chref.quest.officertype = OFFIC_TYPE_SHOPKEEPER;
         }
         else
         {
           chref.quest.officerType = GetRandomNPCType();
         }
       }
     }
Result:
upload_2015-9-16_19-38-59.png


The guy DOES get the "Shop Merchant" type now, which is good.
But how about that 116% Commerce skill?

Similar for the other guy there so it isn't an isolated incident:
upload_2015-9-16_19-39-52.png


This is right after the start of a new game, so they haven't had the chance to gain any XP during the game itself.
 
Not fixed yet. Here you have a save in which I fight against some bandits outside the city of Martinique. Basically, I appear to have GOD mode activated when I DON'T have it activated by the numpad cheats. Also, my other active officer attacked them and killed two of them, but the third one, which received a hit from me, started to get increases and decreases of HP when fighting to my other officer. Very WHAAAA???? o_Oo_Oo_O
 

Attachments

  • -=Free1Test=- Martinique.zip
    727.2 KB · Views: 70
Basically, I appear to have GOD mode activated when I DON'T have it activated by the numpad cheats. Also, my other active officer attacked them and killed two of them, but the third one, which received a hit from me, started to get increases and decreases of HP when fighting to my other officer. Very WHAAAA???? o_Oo_Oo_O
Could that be because your HP resets back to max upon Level-Up?
@Levis mentioned that was the case here: http://www.piratesahoy.net/threads/characters-gain-hp-too-fast-during-fights.25843/
 
Back
Top