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

Solved Rebalancing the Fighting System

@Pieter Boelen, I'm sure you remember how "fun" you and I had with the "noExp problem". For others who want to see, check the posts starting from here: Solved - Rebalancing the Fighting System

We fixed it, but I have found more about it that can be good to know for other cases. The game apparently does not like "else if" even though it supposedly is valid in C and/or C++:
Code:
    if(IsCharacterPerkOn(attack, "SwordplayProfessional"))
    {
        if(rand(100) <= 25)
        {
            critical = damage*2.0;
        }
    }
    else if(IsCharacterPerkOn(attack, "CriticalHit"))
    {
        if(rand(100) <= 10)
        {
            critical = damage*2.0;
        }
    }
    else
    {
        if(rand(100) <= 5)
        {
            critical = damage*2.0;
        }
    }
For some reason this caused the problems. It is avoided by doing this instead:
Code:
    if(IsCharacterPerkOn(attack, "SwordplayProfessional"))
    {
        if(rand(100) <= 25)
        {
            critical = damage*2.0;
        }
    }
    else
    {
        if(IsCharacterPerkOn(attack, "CriticalHit"))
        {
            if(rand(100) <= 10)
            {
                critical = damage*2.0;
            }
        }
        else
        {
            if(rand(100) <= 5)
            {
                critical = damage*2.0;
            }
        }
    }
With this "bool noExp = false;" can be on one line.
However, following @Levis' example for ranged weapons, I changed it to be like this instead:
Code:
    int critchance = 5;
    if(IsCharacterPerkOn(attack, "CriticalHit")) critchance += 5;
    if(IsCharacterPerkOn(attack, "SwordplayProfessional")) critchance += 15;
    if(rand(100) <= critchance)
    {
        critical = damage*2.0;
    }
This also avoids the problem and allows for other abilities to modify the chance of scoring a critical hit.

So, it can be good to know that it seems to be best to avoid "else if" with this game and in similar cases instead put the if statement inside the else statement.

Chance of critical hit with abilities also seemed to be too high for ranged weapons, so some changes to that and the ability descriptions are also included.
 

Attachments

  • critical hit and ability fixes.zip
    17.2 KB · Views: 49
Last edited:
No, and I never will. You will recall that some years ago, when someone else was running the updates, I took serious exception to various "fixes", to the extent that I reverted to an earlier version without the updates and then searched through the forum looking for genuine bug-fixes, storyline updates and harmless cosmetic alterations. Then I uploaded my own collection of fixes in case anyone else was of similar mind. The fully updated version became an unplayable mess and at the start of the following year, the next installer was basically the previous version without updates, plus my collection, and that's when you invited me to continue collecting updates.

I've become less paranoid since then, due to increasing experience of the game code plus increasing familiarity with WinMerge. But I will not compromise gameplay.

If you or @Baste want to take over running the updates, you can add this "fix" if you like.
 
Since it has been years since I last said it I might reiterate that I don't play the Build Mod. I contribute to it when I have something that might be applicable to it, yes - but I don't actually play it, so to include or not include any of my changes are both fine. If something isn't included it can still be added separately by anyone who wants it.

The only real change to gameplay in the files in my previous post is how high the critical hit chance can be for ranged weapons. It seemed to be too high - even higher than what is possible with melee weapons - so I changed it back to what it was before. The change to critical hits for melee weapons makes no difference in-game, it is just handled differently in the code. Since I'm the one who wrote the critical hit code that is used in the Build Mod I figured I could add a more proper fix to it now that I found one as a form of good practice.

Obviously I wouldn't be a suitable coordinator since I'm not particularly involved in the Build Mod and the forum, but I figured I could add more about what the files in my previous post actually do.
 
Back
Top