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

Pre B13 WIP: Boarding code

Pieter Boelen

Navigation Officer
Administrator
Storm Modder
Hearts of Oak Donator
At the moment many people are working on the same mods. This causes complications and frustration because there is not enough communication between the modders. I post this topic here for discussion on the <b>boarding code</b>, so that all people who are working on this mod can come to a mutual agreement on what code should go in and what code should go out and what should still be improved.

Hook is rewriting the boarding code entirely, so I think he should have the final say. Maximus wrote a lot of the code in LAi_boarding.c as well though, so things might get complicated.

Hook's boarding code is a part of <i>IncredibleHat Fixes and Features.zip</i>.

Please note: Other people are welcome to join in the discussion, but please keep the discussion on topic.

On the FTP there is a folder "+ Latest modpack update WIP". In it, you can find all latest codebase versions:
1) Pre Build 13 Base Version.zip
2) Maximus Fixes.zip
3) IncredibleHat Fixes and Features.zip
4) Pieter Attempted Merge.zip
 
Please note that the boarding code was NOT intended for release in its current state. I sent a copy to IncredibleHat mostly so that in case anything happened to me someone would have a copy. He didn't tell me he was putting it up for everyone, and indeed has refused all contact with me recently.

I'll have to wait until I get my computer back from the shop in a couple of days to look at everything. In the mean time, it would be nice if IncredibleHat would get in touch.

Hook
 
Ah. Ok then. We'll wait patiently until you're done then. <img src="style_emoticons/<#EMO_DIR#>/whistling.gif" style="vertical-align:middle" emoid=":wp" border="0" alt="whistling.gif" />

Could you make a short summary on what exactly you are changing as far as boarding is related? Then Maximus would know which things he won't need fixing, because you'll be working on those. <img src="style_emoticons/<#EMO_DIR#>/doff.gif" style="vertical-align:middle" emoid=":doff" border="0" alt="doff.gif" />
 
<!--quoteo(post=155892:date=Jul 30 2006, 12:23 PM:name=Pieter Boelen)--><div class='quotetop'>QUOTE(Pieter Boelen @ Jul 30 2006, 12:23 PM) [snapback]155892[/snapback]</div><div class='quotemain'><!--quotec-->
Could you make a short summary on what exactly you are changing as far as boarding is related? Then Maximus would know which things he won't need fixing, because you'll be working on those. <img src="style_emoticons/<#EMO_DIR#>/doff.gif" style="vertical-align:middle" emoid=":doff" border="0" alt="doff.gif" />
<!--QuoteEnd--></div><!--QuoteEEnd-->
A *short* summary? <img src="style_emoticons/<#EMO_DIR#>/biggrin.gif" style="vertical-align:middle" emoid=":D" border="0" alt="biggrin.gif" />

First of all, the boarding code is based off the June 28 version of the build. I'm doing it this way so that I won't have to try to merge in changes every few days, and I can be sure that any bugs I find are ones I introduced myself and not by something else that's changed in the code. Before release I will be merging in all the changes in the new versions.

StartBoarding has been broken out into two functions. One runs when boarding is actually started, and contains only the code necessary to set the boarding up. The second is InitializeDeck and runs at the beginning of each deck, even if it's the top deck of the ship. From the looks of my log files, there is some duplication of code from a few other places still remaining in this function. And since I sent the code to Hat I've moved one block of code from InitiailzeDeck back to StartBoarding.

The stock game handled boarding on multiple decks by first deciding how many PBC's (Player Boarding Characters) would be used in the entire boarding process if the boarding proceeded through all the decks and included your entire crew. It also setup EBC (Enemy) the same way. If you fought through every deck you'd end up with very few crew left on either ship. Subsequent mods changed what PBC meant. I'm not sure that PBC is even relevant any more, except for use in other calculations. Without having the code in front of me, I can't give concrete examples.

Since most of the crew on both ships would be dead at the end of boarding, especially if all your boarding characters were killed on each deck, there were a lot of kludges added to create crew out of thin air after the boarding was finished. I've removed all those random crew increases and calculate remaining crew in a more reasonable manner.

First of all, you don't send your entire crew to fight on every deck. You always keep a reserve. Even the enemy keeps a reserve. If everyone gets killed, there are still some crew left to fight on the next deck. If the boarding goes to the last possible deck (the captain's cabin) and you've lost your entire boarding party on each deck, it's possible that both ships will be at or below minimum crew. The actual numbers I used still needed more tweaking. Crew casualties are being calculated properly from the number of boarding characters lost on each deck for both friendly and enemy.

The musket fire perk used before boarding has been recalculated to include the enemy ship defense as stated in the description of the perk, along with other factors. The calculation has also been moved from AIAbordage.c to the boarding code.

PBMM, the Post Boarding Morale Modifier has been rewritten. It currently gives a larger morale boost than I was intending and I'll be tweaking that part of the code before release, based on extensive testing.

Most of the variables cannot be assumed to still have their original meaning, so changing them probably won't have the intended results.

A number of bugs were fixed along the way, including the one that caused weapons to multiply in your weapons locker.

I have not included any of the code that changed crew numbers based on what happened in the boarding cabin dialog. I was waiting for other bugs in that part of the code to be fixed before I tried to make it work. That code is commented out in LAi_Boarding.c at the moment. For testing, I've always stuck the enemy captain in my hold for later disposition.

The last major function I was working on was attacking a fort, which is treated as a boarding and handled in the boarding code. The code *should* work if you have only one ship the way it is now, but if you have a squadron of multiple ships the behavior is currently undefined. I was attempting to defeat the three French ships guarding Oxbay and sack the fort when my computer crashed. One previous attempt did not work because I had attempted to update the boarding code to a newer version based on known changes to the code, which is why I prefer to work from a specific unchanging version of the code.

If anyone makes changes to the current code, I will include them if they are relevant. I have to update the code to work with the newest version anyway, so evaluating changes will not add to my workload. I may also evaluate changes based off my newer boarding code, but this will be the last thing I do before the final tests before release.

It was my intention to understand completely every variable used, every value of those variables, and every calculation. I think I've gotten a handle on how everything works, and why. I will be more than happy to answer questions on my changes, but it will have to wait until I get my computer back from the shop, which should be in a few days.

Hook
 
WOW! Thanks a LOT, Hook! <img src="style_emoticons/<#EMO_DIR#>/bow.gif" style="vertical-align:middle" emoid=":bow" border="0" alt="bow.gif" /> <img src="style_emoticons/<#EMO_DIR#>/icon_wink.gif" style="vertical-align:middle" emoid=";)" border="0" alt="icon_wink.gif" />
 
I'll add to this list as I remember stuff.

I have rewritten the code that calculates the number of boarding characters on each deck. The ratio of your boarding characters to the enemy's will be based on your actual crew numbers at the beginning of each deck, which will incorporate losses from the previous deck, if any.

I've used other parts of the code to determine how many boarders will be on any given deck, and some of those may not be right. For example, there appear to be 30 available locations on the largest upper deck, but when I tried using 30 boarding characters there was at least one enemy who did not appear on deck, probably because he was actually on the water underneath the ship. I set the cap to 20 boarding characters to deal with this.

If any changes are made to the number of locations for boarding characters, this part of the code will need to be changed. And I'd appreciate someone pointing me to where the actual numbers may be found so I can use correct numbers.

Now... if corpsemode is set to anything but zero, meaning corpses hang around after death, there will be some terrible logjams in the choke points on various decks. IncredibleHat has suggested setting corpsemode to zero during boarding and I agree. If this is not done, I'll have to limit the number of boarding characters even more.

Hook
 
Update: boarding appears to work for forts, including boarding with multiple ships, which will use the crew from your entire squadron. Still have some testing to do, and some tweaking.

Currently when you exit from boarding a fort, all your ships are repaired and your companions' crews are set to max. Your own crew is not set to max, however. I'm considering setting your crew to max as well. If anyone has any objections, or wants to go back to not maxing your companions' crews, or even not repairing all your ships, let me know now.

Hook
 
I think everything should be repaired and maxed. <img src="style_emoticons/<#EMO_DIR#>/yes.gif" style="vertical-align:middle" emoid=":yes" border="0" alt="yes.gif" />
 
I found and fixed the source of a number of bugs having to do with the boarding cabin. The player will no longer run back and forth in the small cabin trying to get to the enemy captain.

The way the game is set up, if you get to the ship's cabin, you're not supposed to be fighting. You're supposed to have the surrendered captain dialog instead. The fact that we fought in the cabin was a bug.

Well, I like fighting in the ship's cabin myself, so I put in a variable giving a percentage chance to do so, which the player may tweak to his liking.

If the enemy surrenders during the fight, you always go to the ship's cabin and have the dialog. If you fight through all the decks and get to the ship's cabin without the enemy surrendering, you may or may not fight. If you do fight, you always get the "dead loser" screen at the end. You do not fight if the enemy captain surrenders.

You may specify a chance for the enemy captain to surrender automatically if you get to the ship's cabin. If the chance of the automatic surrender is very low, you get to fight in the cabin and get a lot of "dead loser" screens. <img src="style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />

If people prefer, I can probably set it up so you can fight in the cabin AND get the surrender dialog with the captain afterwards. Let me know.

Hook
 
I would like it that if you got to the captain's cabin and the enemy ship has still not surrendered, that you and the captain will be alone in the captain's cabin to fight each other. So if the ship surrenders, you will talk to the captain in the captain's cabin and if the ship does not surrender, you will fight the captain there and he'll be a Dead Loser afterwards.

I think it would be odd to first fight all the decks AND the captain's cabin, only to talk to the captain in there afterwards. Where was the captain during the fights? In his cabin, surely?

Could you please send your current code to me and Maximus? I want to test it for a bit and Maximus is also looking at some boarding bugs, so your code should help in that. If you don't have Maximus' e-mail address, say so and I'll send it to you. <img src="style_emoticons/<#EMO_DIR#>/yes.gif" style="vertical-align:middle" emoid=":yes" border="0" alt="yes.gif" />
 
I think it would be good to fight the captain himself in the end, but I want to get everything else working first.

The code has passed the smoke test (i.e. it didn't blow up and appears to work at first glance) but hasn't been tested. Let me make sure some of the larger changes I just made work right, then I'll send it to you.

Hook
 
I'll be looking forward to it, Hook! <img src="style_emoticons/<#EMO_DIR#>/danse1.gif" style="vertical-align:middle" emoid=":dance" border="0" alt="danse1.gif" />

You once suggested to make looting during boardings automatic even if the corpsemode IS on. I have now coded this in. Maybe I should add a toggle on it though.

Weird effect: After killing enemies during boarding, they just vanish, instead of falling on the ground and vanishing later.
 
<!--quoteo(post=157923:date=Aug 13 2006, 06:01 PM:name=Pieter Boelen)--><div class='quotetop'>QUOTE(Pieter Boelen @ Aug 13 2006, 06:01 PM) [snapback]157923[/snapback]</div><div class='quotemain'><!--quotec-->
Weird effect: After killing enemies during boarding, they just vanish, instead of falling on the ground and vanishing later.
<!--QuoteEnd--></div><!--QuoteEEnd-->
I have tried to fix this and the result is even better than I had dared hope for! <img src="style_emoticons/<#EMO_DIR#>/w00t.gif" style="vertical-align:middle" emoid=":woot" border="0" alt="w00t.gif" />

During boarding, if you kill an enemy, you loot him automatically. He does not disappear, but instead falls to the ground and remains lying there. However, you can walk through him, so he doesn't obstruct the fighting on the deck at all. And it doesn't prevent you from continuing to the next deck either. In short: It works excellently now! During boarding we now have automatic looting AND corpses! <img src="style_emoticons/<#EMO_DIR#>/danse1.gif" style="vertical-align:middle" emoid=":dance" border="0" alt="danse1.gif" />
 
<!--quoteo(post=157925:date=Aug 13 2006, 12:11 PM:name=Pieter Boelen)--><div class='quotetop'>QUOTE(Pieter Boelen @ Aug 13 2006, 12:11 PM) [snapback]157925[/snapback]</div><div class='quotemain'><!--quotec-->
<!--quoteo(post=157923:date=Aug 13 2006, 06:01 PM:name=Pieter Boelen)--><div class='quotetop'>QUOTE(Pieter Boelen @ Aug 13 2006, 06:01 PM) [snapback]157923[/snapback]</div><div class='quotemain'><!--quotec-->
Weird effect: After killing enemies during boarding, they just vanish, instead of falling on the ground and vanishing later.
<!--QuoteEnd--></div><!--QuoteEEnd-->
I have tried to fix this and the result is even better than I had dared hope for! <img src="style_emoticons/<#EMO_DIR#>/w00t.gif" style="vertical-align:middle" emoid=":woot" border="0" alt="w00t.gif" />

During boarding, if you kill an enemy, you loot him automatically. He does not disappear, but instead falls to the ground and remains lying there. However, you can walk through him, so he doesn't obstruct the fighting on the deck at all. And it doesn't prevent you from continuing to the next deck either. In short: It works excellently now! During boarding we now have automatic looting AND corpses! <img src="style_emoticons/<#EMO_DIR#>/danse1.gif" style="vertical-align:middle" emoid=":dance" border="0" alt="danse1.gif" />
<!--QuoteEnd--></div><!--QuoteEEnd-->

Amazing work, that will certainly help without having bodies blockading your path =)
 
Great, Pieter! Glad you got that one figured out.

As it would happen, the changes I made weren't working right. There are problems with leftover attributes from the previous boarding. I'm working on fixing those now, and trying to get the code back to where I thought it was before.

Hook
 
<!--quoteo(post=157943:date=Aug 13 2006, 07:06 PM:name=Hook)--><div class='quotetop'>QUOTE(Hook @ Aug 13 2006, 07:06 PM) [snapback]157943[/snapback]</div><div class='quotemain'><!--quotec-->
Great, Pieter! Glad you got that one figured out.
<!--QuoteEnd--></div><!--QuoteEEnd-->
Do you want me to send you the modified files? Then you can test my change as well while you're at it. I'm pretty certain it doesn't cause any bugs: I only made some very small adjustments.
 
Yes please. I wasn't looking forward to having to figure that one out. <img src="style_emoticons/<#EMO_DIR#>/smile.gif" style="vertical-align:middle" emoid=":)" border="0" alt="smile.gif" />

Hook
 
See attached. These files are compatible with the latest modpack update. <img src="style_emoticons/<#EMO_DIR#>/doff.gif" style="vertical-align:middle" emoid=":doff" border="0" alt="doff.gif" />
Note: Everybody is free to test this. It should work just fine. And no more obstructing corpses during boardings. <img src="style_emoticons/<#EMO_DIR#>/danse1.gif" style="vertical-align:middle" emoid=":dance" border="0" alt="danse1.gif" />

It wasn't even that hard to figure this one out. I already knew more-or-less how to do it. Luckily I know where the loot code is in the PROGRAM folder. <img src="style_emoticons/<#EMO_DIR#>/icon_mrgreen1.gif" style="vertical-align:middle" emoid=":cheeky" border="0" alt="icon_mrgreen1.gif" />
 
Question to Hook: Could you possibly make a release of your current work on the boarding code? Then some more people can help to test your code. I think that some of the crazy issues that are being reported lately might be caused by the boarding code being messed up and I want to know if your code would fix it... <img src="style_emoticons/<#EMO_DIR#>/unsure.gif" style="vertical-align:middle" emoid=":?" border="0" alt="unsure.gif" />
 
Back
Top