• 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 Levelling: Cannonball Hits Slow Down Game

I would like to hear what others have to say. Maybe it's the problem with my PC (CPU, GPU or who knows what)... I don't want to waste your time correcting the naval battles if everything works on other PC's. On my PC, it's impossible to play when you shoot cannons on enemy ship, especially if I'm sailing a ship with a lot of guns (which I do at the moment)...
 
What are your computer specifications?

I have only been sailing small ships and have had no problems. Well, that's not strictly true. There have been times when the game slows waay down in battles and I do not know why. Then there are other times when it is fine. :facepalm It is probably more because of WinX than anything else. All I know is that it is the cannon smoke that is the culprit when it goes bad.

I should get a big ship and get into a big battle and see just what happens.
 
What are your computer specifications?

I have only been sailing small ships and have had no problems. Well, that's not strictly true. There have been times when the game slows waay down in battles and I do not know why. Then there are other times when it is fine. :facepalm It is probably more because of WinX than anything else. All I know is that it is the cannon smoke that is the culprit when it goes bad.

I should get a big ship and get into a big battle and see just what happens.

Intel Core 2 Quad Q9450 2.66GHz
Nvidia GT630 2GB DDR3
4GB DDR3
Windows 7 Professional 32 bit

You are wrong, cannon smoke barely affects performance. It is the Auto_skill_system, I have tested it and I'm 100% sure that it causes the stuttering in naval battles. I even played a large naval battle (with more than 10 ships) without Auto_skill, and it was great. It is fine only when you are fighting 2-3 ships and if your ship does not have many guns. With 20+ guns, stuttering is really, really bad...
 
I think the problem is because the "adding XP function" is relatively heavy and it gets called EVERY time a cannonball hits.
So big ship = More cannons = More hits at the same time = More lag.
Also, Higher Skills = Cannons Firing At the Same Time (instead of after each other with a random delay) = More lag at the same time.

My attempted fix reduces the number of function calls. @Levis' one, if I understand correctly, tries to make the function calls that are left more efficient.
So it should at least be better than it was. Hopefully? Perhaps?

I definitely have been noticing the effects on my computer as well.
Not enough to call it "unplayable" but definitely noticeable and I'd much rather have the game without cannonball hits causing that lag at all.
 
I think the problem is because the "adding XP function" is relatively heavy and it gets called EVERY time a cannonball hits.
So big ship = More cannons = More hits at the same time = More lag.
Also, Higher Skills = Cannons Firing At the Same Time (instead of after each other with a random delay) = More lag at the same time.

My attempted fix reduces the number of function calls. @Levis' one, if I understand correctly, tries to make the function calls that are left more efficient.
So it should at least be better than it was. Hopefully? Perhaps?

I definitely have been noticing the effects on my computer as well.
Not enough to call it "unplayable" but definitely noticeable and I'd much rather have the game without cannonball hits causing that lag at all.
what I did was moving the addxp function to a event call also so it should work alongside the game instead of halting the game....
So if it still stutters this is kind of weird.... I do have some optimalization things I might be able to do concerning the officer prices. this made the function heavier. I think I should also reduce the amount of function calls by maybe adding them up and only calling it once a while. so if you have a lot of hits it wont be called that often.
 
I think I should also reduce the amount of function calls by maybe adding them up and only calling it once a while. so if you have a lot of hits it wont be called that often.
That's what I was thinking too. If you have a 100 gun ship and good Accuracy skills, you could end up getting that function called 100 times within a few frames.
With that being the case, ANY addition could make for a HUGE increase in processing power needed, with the resulting potential lag. :facepalm
 
That's what I was thinking too. If you have a 100 gun ship and good Accuracy skills, you could end up getting that function called 100 times within a few frames.
With that being the case, ANY addition could make for a HUGE increase in processing power needed, with the resulting potential lag. :facepalm
I've set it up now so that during 2 seconds (after the first call) all xp is added together. And after these 2 seconds the function is called.
This should reduce the lag significatly
 
There is still a few fps drop when in large naval battles (8+ ships), but that doesn't have to do anything with cannon fire, the stuttering is gone...
 
So I can mark this... "Fixed" then? Maybe we should keep this on "Needs Testing" until I've had a chance to give this a quick try as well.
 
So I can mark this... "Fixed" then? Maybe we should keep this on "Needs Testing" until I've had a chance to give this a quick try as well.

Ok, we can wait for other feedback, and then mark it as Fixed. But since I was the only one complaining, I guess others won't have issues :D
 
Last edited:
It would be good though to see what happens when firing with 1st class ships. Unfortunately, I don't own one at the moment, but with my 72 guns 3rd class ship, it performs nicely!
 
It would be good though to see what happens when firing with 1st class ships. Unfortunately, I don't own one at the moment
You can obtain one by executing something like that:
Code:
GiveShip2Character(pchar, "manowar_gub", "Cheat-o-War", -1, GetServedNation(), true, true);

from the console... but be sure to make a reserve copy of your save first.
 
It would be good though to see what happens when firing with 1st class ships. Unfortunately, I don't own one at the moment, but with my 72 guns 3rd class ship, it performs nicely!
I've tested it agains forts ;).
But the leveling shouldn't become more intents anymore with more cannons now.
If needed we could move the relation stuff into this function also. But if @Pieter Boelen Looks at it he should be able to figure out how it works and fix that if needed.
 
If needed we could move the relation stuff into this function also. But if @Pieter Boelen Looks at it he should be able to figure out how it works and fix that if needed.
We already agreed to take most of that relation stuff completely out.
I just didn't get round to actually doing that yet. But that'll clean it up a bit further.
 
@Levis about this code:
Code:
     int cexp = 0;
     int aexp = 0;
     if (bSeriousBoom)
     {
       [...]
       cexp += 500;
       aexp += 500;
     }
     else
     {
       [...]
       cexp += 100;
       aexp += 100;
     }
     [...]
   }

   if(cexp > 0) Ship_AddDelayedCumXP(GetCharacter(iBallCharacterIndex), "Cannons", cexp); //Levis
   if(aexp > 0) Ship_AddDelayedCumXP(GetCharacter(iBallCharacterIndex), "Accuracy", aexp); //Levis
Why are you doing a cumulative adding on 'cexp' and 'aexp'? They can only be either '100' or '500' as written there anyway.

And would it be of any help now anymore to use my recent frnd() trick to attempt to further improve performance?
Code:
         if (frnd() > 0.5)   Ship_AddCharacterExpChar(rBallCharacter, "Cannons" , 1000);
         else         Ship_AddCharacterExpChar(rBallCharacter, "Accuracy", 1000);

Just curious. :doff
 
Back
Top