
Editing the EXE
| View previous topic :: View next topic |
| Author |
Message |
AdamMil

Cutthroat 
Posts: 279 

 
4759 Gold -

|
Posted: Thu Feb 04, 2016 3:50 am Post subject: |
|
|
| Mandiuscreel wrote: | | I'll have to mess around with the tutorial to get the hang of it, but then I'm good to go. | I hope it's useful, but the tutorial is more intended for cheating (e.g. increasing your health, etc.) and thus it focuses on finding values in memory. In your case, you already know where the values are and you just want to see what's accessing them. I don't think that's covered by the tutorial. But it can't hurt to go through it!
| Mandiuscreel wrote: | | I have a question, though. I run Pirates! in a windowed mode, so I can skip over to the Trainer and other programs while I'm not doing something in the game. This of course stops the game. Does the Cheat Engine enable the game to run while the focus is elsewhere? | Whether the game pauses while it's not the active window is up to the game, not any other programs. But you can certainly run the cheat engine side by side with the game and keep the game as the "active window". And it's usually useful for the game to pause while switching to the cheat engine anyway, because you may not want things changing while you're browsing through memory trying to understand what's going on. |
|
| Back to top |
|
 |
Mandiuscreel

Seaman 
Posts: 171 

 
3189 Gold -

|
Posted: Thu Feb 04, 2016 4:03 am Post subject: |
|
|
Good point. Based on what I've seen in the tutorial, the ability to detect changing values would be VERY useful, since my focus right now is understanding how the ship's speed is determined.
There are five different Points of Sail and nine different classes of ships, if we include the canoes (which by what you've said about them might be something we can never have any control over, aside from the basic ship values).
With the five different points of sail, and each ship class with it's own selection of them, there has to be some kind of data block that includes that information. Otherwise, they'd have to write the code to apply points of sail versus the wind nine different times.
Of course, there could be only one Dword for each class of ships that gives the system the information on which POSs it uses. But the saving in memory isn't really worth the extra coding it would require. They showed us they can store information in blocks. I'm pretty sure this is stored somewhere, too.
I'll have to locate the subroutine that controls simple navigation. I wish they had used real labels for things... |
|
| Back to top |
|
 |
AdamMil

Cutthroat 
Posts: 279 

 
4759 Gold -

|
Posted: Thu Feb 04, 2016 4:43 am Post subject: |
|
|
| Mandiuscreel wrote: | | With the five different points of sail, and each ship class with it's own selection of them, there has to be some kind of data block that includes that information. Otherwise, they'd have to write the code to apply points of sail versus the wind nine different times. | For all we know, that's one of the mystery values...
| Mandiuscreel wrote: | | Of course, there could be only one Dword for each class of ships that gives the system the information on which POSs it uses. But the saving in memory isn't really worth the extra coding it would require. | Maybe, but don't take too much for granted with these developers. :-)
| Mandiuscreel wrote: | | I'll have to locate the subroutine that controls simple navigation. | The best thing to do, in my opinion, is to find the memory-watching feature of Cheat Engine, calculate the addresses of the mystery values in the ship type table for the particular ship you're sailing, and see what parts of the program access those addresses. That'll give you pointers to code that you/we can investigate. Assuming you're still trying to decipher the ship type table...
| Mandiuscreel wrote: | | I wish they had used real labels for things... | I'm sure they did, in their source code, but all those labels would have been discarded in the compilation process. (They're only for human consumption. The computer doesn't need them.) |
|
| Back to top |
|
 |
Mandiuscreel

Seaman 
Posts: 171 

 
3189 Gold -

|
Posted: Thu Feb 04, 2016 4:56 am Post subject: |
|
|
| AdamMil wrote: | | The best thing to do, in my opinion, is to find the memory-watching feature of Cheat Engine, calculate the addresses of the mystery values in the ship type table for the particular ship you're sailing, and see what parts of the program access those addresses. That'll give you pointers to code that you/we can investigate. Assuming you're still trying to decipher the ship type table... |
Your opinion is sound, as usual. It would certainly save me a lot of headache in pulling apart code I only partly understand. And you may have given me a clue with the snippet of code with the Scantlings. I imagine the Cotton Sails work in much the same way, giving a 25% or 50% increase in the calculation of speed.
On the other hand, the Bronze Cannon and Fine-grain Powder each had a whole set of values of their own. So it's time to explore. AFTER I get that Flag Galleon I just captured to a port with Triple Hammocks! |
|
| Back to top |
|
 |
AdamMil

Cutthroat 
Posts: 279 

 
4759 Gold -

|
Posted: Thu Feb 04, 2016 5:14 am Post subject: |
|
|
| Mandiuscreel wrote: | And you may have given me a clue with the snippet of code with the Scantlings. I imagine the Cotton Sails work in much the same way, giving a 25% or 50% increase in the calculation of speed.
On the other hand, the Bronze Cannon and Fine-grain Powder each had a whole set of values of their own. | All of the upgrades are stored within a single number. At memory address 8162F8 you'll find the start of the ship table, which tracks the stats of all ships in the game (outside of battle). Each ship entry is 1,116 bytes long, and there's space for 256 of them. The upgrade field is at offset 2C (decimal 44) from the start of each ship entry. It packs all of the upgrades into a bit field: copper plating is bit 0 (LSB), cotton sails is bit 1, then triple hammocks, iron scantlings, chain shot, grape shot, fine powder, and finally bronze cannon. I think the player flagship is the first ship in the table. (It might not stay that way if you lose the flagship... Or maybe the first 8 entries are reserved for player ships... I used to know but I don't remember exactly.) If so, the player ship data starts at address 8162F8, and the player upgrades are at 8162F8 + 2C.
The ship table contains other interesting things, such as position, speed, hull & sail damage, crew & cannon count, cargo, nation, current mission, rotation, rudder position, etc. |
|
| Back to top |
|
 |
Mandiuscreel

Seaman 
Posts: 171 

 
3189 Gold -

|
Posted: Thu Feb 04, 2016 6:12 am Post subject: |
|
|
Thanks! I'll check it out.  |
|
| Back to top |
|
 |
Roland

Helmsman 
Posts: 4190 

 
23929 Gold -

|
Posted: Thu Feb 04, 2016 10:07 am Post subject: |
|
|
There might not be nine different sets of point-of-sail characteristics. Looking at the list of best points of sailing, it appears that sloops are like barques, fluyts are like merchant galleons, and frigates are like war galleons. So there might only be six. |
|
| Back to top |
|
 |
Mandiuscreel

Seaman 
Posts: 171 

 
3189 Gold -

|
Posted: Thu Feb 04, 2016 3:31 pm Post subject: |
|
|
| Roland wrote: | | There might not be nine different sets of point-of-sail characteristics. Looking at the list of best points of sailing, it appears that sloops are like barques, fluyts are like merchant galleons, and frigates are like war galleons. So there might only be six. |
That's possible, but base speeds affect the different points of sail. There'd be more than six, if not nine. |
|
| Back to top |
|
 |
Mandiuscreel

Seaman 
Posts: 171 

 
3189 Gold -

|
Posted: Mon Feb 08, 2016 8:34 pm Post subject: Points of Sail |
|
|
I was right about the points of sail. There are nine sets of 16 one-byte values beginning at Offset 326238 in the EXE (Thanks to AdamMil for his annotated EXE IDA database).
The sets are for each class of ship in the order given previously in this thread, ranging from Canoes to Merchant Galleons:
Offset - Class of Ship - Irons - RIW - CH - CHB - BmR - BBR - BR - RBR - RBW - RBR - BR - BBR - BmR - CHB - CH - RIW
326238 - Canoes - 255 - 2 - 4 - 5 - 7 - 8 - 7 - 6 - 4 - 6 - 7 - 8 - 7 - 5 - 4 - 2
326248 - Sloops - 255 - 255 - 3 - 4 - 6 - 7 - 7 - 6 - 5 - 6 - 7 - 7 - 6 - 4 - 3 - 255
326258 - Brigantines - 255 - 255 - 2 - 4 - 5 - 6 - 6 - 6 - 6 - 6 - 6 - 6 - 5 - 4 - 2 - 255
326268 - Barques - 255 - 255 - 2 - 3 - 4 - 6 - 6 - 5 - 5 - 5 - 6 - 6 - 4 - 3 - 2 - 255
326278 - Fluyts - 254 - 255 - 255 - 2 - 3 - 4 - 5 - 6 - 6 - 6 - 5 - 4 - 3 - 2 - 255 - 255
326288 - Merchantmen - 255 - 255 - 2 - 3 - 4 - 5 - 6 - 6 - 6 - 6 - 6 - 5 - 4 - 3 - 2 - 255
326298 - Frigates - 255 - 255 - 2 - 3 - 5 - 6 - 7 - 7 - 7 - 7 - 7 - 7 - 5 - 3 - 2 - 255
3262a8 - C Galleons - 255 - 255 - 1 - 2 - 4 - 5 - 6 - 6 - 6 - 6 - 6 - 5 - 4 - 2 - 1 - 255
3262b8 - M Galleons - 254 - 255 - 255 - 2 - 3 - 4 - 5 - 6 - 6 - 6 - 5 - 4 - 3 - 2 - 255 - 255
Note that the values are mirrored; The initial value of 255 (or 254 for a couple of oddballs) represents the bow of the ship pointing directly into the wind. This is called "going into Irons", and is a very dangerous thing to do to a sailing ship, especially in combat. You can lose rigging and masts, though this isn't represented in the game. It merely causes the ship to "stall" and stop moving altogether.
The values proceed through eight positions around the compass until the ship is "running Before the Wind (RBW)".
The values then proceed through the remaining compass positions to complete the circle. This puzzled me at first, because I couldn't see the need to repeat the previously established POSs, but then I realized that this saves math. The ship's "Rose" can be imposed over the wind's "Rose" and the values added or multiplied or whatever together to give the ship's current speed.
The values 255 (and, for some reason, 254), indicate the game treats these POSs as "Irons".
There was one other thing that puzzled me and kept me from realizing I was looking at a complete Rose and not half of one for several hours; there was a mistake in the code.
I realize this is heresy, speaking of the development team as if they are fallible, but...
It is in the frigates listing, at Offset 3262A3. That's why it's red in the text above. the value should be 6, not 7. The difference isn't really noticeable unless you're using a protractor and are extremely precise in your observations, but turning to the right of the direction of the wind is marginally faster in the Broad Beam Reach (BBR) position than on the left (or it could be the other way around, left instead of right. I haven't used a protractor). In my EXE, I've corrected this.
EDIT I neglected to define the terms on the table:
Irons - Directly into the wind, ship cannot move
RIW - Running Into the Wind, one position (1 to 2 points) off the Direction of the wind
CH - Close Hauled, two positions (3 to 4 points) off the direction of the wind
CHB - Close-Hauled Beam, three positions (5 to 6 points) off the direction of the wind
BmR - Beam Reach, four positions (7 to 8 points) off the direction of the wind; this is technically "Hove to", a position in which the wind is parallel to the surface of the sail. The ship technically cannot make headway in this position, as it will cause square sails to luff, that is, to flutter in the wind like a flag. This is how ships stop moving at sea. The game counts this position as slightly less efficient than Broad Beam Reach.
BBR - Broad Beam Reach, five positions (9-10 points) off the direction of the wind
BR - Broad Reach, six positions (11-12 points) off the direction of the wind
RBR - Running Broad Reach, seven positions (13-14 points) off the direction of the wind; for square-sailed ships, this is the fastest point of sail, because all sails are getting the optimum amount of wind.
RBW - Running before the wind, directly opposite (15-16 points) the direction of the wind. This is actually not the fastest position for a square-sailed ship, because not all the sails are getting wind, but the game doesn't go into such detail; it treats the position as RBR for all square sailed ships.
NOTE: The "points" mentioned above are from the standard 32-point compass rose used for navigating in the age of sail.
EDIT EDIT: A "point" is 11.25 degrees, so a position on the above chart represents a change of 22.5 degrees (Half of 45 degrees) This is quite noticeable, if you watch the wind direction arrow. Optimizing your angle to the wind can mean the difference between a hard-won fight and a loss.
Last edited by Mandiuscreel on Tue Feb 09, 2016 2:40 am; edited 1 time in total |
|
| Back to top |
|
 |
AdamMil

Cutthroat 
Posts: 279 

 
4759 Gold -

|
Posted: Tue Feb 09, 2016 12:27 am Post subject: Re: Points of Sail |
|
|
| Mandiuscreel wrote: | | I was right about the points of sail... | Hah, here you spent all that time trying to find the points of sail and I had it in my notes already. Sorry, it's been so long I can't remember what I've done with this game... :-P
| Quote: | | I realize this is heresy, speaking of the development team as if they are fallible, but... | They are totally fallible. :-P
| Quote: | | It is in the frigates listing... the value should be 6, not 7. | Hmm, it seems you're correct, unless they're meant to perform slightly better turning to the right than the left... I'd check the in-game pirate-pedia or whatever it's called, but it probably doesn't say anything about it being intentional.
| Quote: | | The values 255 (and, for some reason, 254)... | These are negative numbers - -1 and -2 respectively. So some of them go -1, -1, 2, 3, ... and others go -2, -1, -1, 2, 3, ... I guess representing even worse performance against the wind. |
|
| Back to top |
|
 |
Mandiuscreel

Seaman 
Posts: 171 

 
3189 Gold -

|
Posted: Tue Feb 09, 2016 1:59 am Post subject: Re: Points of Sail |
|
|
| AdamMil wrote: | | These are negative numbers - -1 and -2 respectively. So some of them go -1, -1, 2, 3, ... and others go -2, -1, -1, 2, 3, ... I guess representing even worse performance against the wind. |
It may create a situation where the ship simply can't go forward; I've had my ship go into Irons while engaged in a fight in a truly low wind (1 or 2 kts), and there just wasn't enough of a breeze to help me turn. Of course, in the real world, a ship in Irons can actually go backwards. because the wind is pushing so hard. |
|
| Back to top |
|
 |
Mandiuscreel

Seaman 
Posts: 171 

 
3189 Gold -

|
Posted: Tue Feb 09, 2016 5:12 am Post subject: Points of Sail and Ship's Rigging |
|
|
Finding the Points of Sail table is a mixed blessing. It means that now I can make adjustments not just to the physical characteristics of the ships, but also to their performance characteristics.
And it gives me no excuse for not doing that...
There are, fortunately, not nine types of rigging involved here. The largest group is the square-sailed ships, consisting of Fluyts, Merchantmen, Frigates, and both kinds of galleons.
There are two strictly fore-and-aft vessels, the Tartane (canoes) and the Barque.
There are two mixed vessels, the sloop and the brigantines, both with large gaffsails rigged fore-and-aft, the addition of which gives both vessels a high degree of maneuverability and a much wider choice of POSs.
All of this is reflected in the POS chart, but I disagree with the designers in a number of ways;
The Barques should be much faster; the ratio of square footage of canvas to depth of keel is greater than any other vessel save the Tartane; the mainsail compares in proportion to the tartane's sail, and there are two other sails that add 75% more canvas, all designed to catch the slightest breeze.
The frigates should be less maneuverable. There is a small gaffsail rigged fore-and-aft for headway into the wind, but the performance of such small square footage of canvas is drastically overestimated by the designers; frigates were fast and maneuverable, but these fabled characteristics were in comparison to higher rated ships-of-the-line, not to sloops and brigantines.
All the square-rigged ships should have a dip in sailing speed when running directly before the wind; there is no reason to leave this out, since there is a 16-point compass in use.
The performance of the Merchant Galleon should not be as restricted as indicated on the table. The design of galleons was subject to heavy regulation by the Spanish, but rigging and fine-tuning was a sailmaster's prerogative, and a good master could smarten up a hooker considerably.
The same could be applied to the Fluyt. Specifically designed to avoid quick conversion to war use, the Fluyt was simplified, a well-designed vessel of reliable consistency. Over time, sailmasters developed ways to eke out a knot here and there. The heavy restrictions given these vessels on the table aren't entirely justified.
And, though this may well be a personal bias since I am a big-ship fan (and a tartane-hater), it seems to me that the Canoes sail a bit too fast.
So a-tweaking I will go... |
|
| Back to top |
|
 |
AdamMil

Cutthroat 
Posts: 279 

 
4759 Gold -

|
Posted: Tue Feb 09, 2016 6:50 am Post subject: Re: Points of Sail and Ship's Rigging |
|
|
| Mandiuscreel wrote: | | So a-tweaking I will go... | Sounds like fun. :-) But I guess it'll be tricky to keep the game balanced... |
|
| Back to top |
|
 |
Mandiuscreel

Seaman 
Posts: 171 

 
3189 Gold -

|
Posted: Tue Feb 09, 2016 2:48 pm Post subject: |
|
|
| AdamMil wrote: | Sounds like fun. But I guess it'll be tricky to keep the game balanced... |
Part of the fun is when the game's unbalanced. I just spent a happy couple of hours in an Ocean Barque, tracking down every War Canoe I could find. It's so gratifying when they discover they can't "shoot and run"...
But the Barque shouldn't be quite that fast.
And a Flag Galleon with a War Canoe's stats is truly terrifying.
But enough playing around. To work, I guess... |
|
| Back to top |
|
 |
parksbanyon

Gunner 
Posts: 564 

 
13127 Gold -

|
Posted: Mon Mar 21, 2016 10:01 pm Post subject: another mystery solved |
|
|
I had always wanted to change the sailing characteristics as I have 3 different versions of the war canoe/pinnace/mail runner class. 1 Fultons Nautilus (which) should move/sail similar to the canoe, 2 a swordfish design semi sub based on the hunley, and 3 a crab claw sail pacific proa which was what was the war canoe. |
|
| Back to top |
|
 |
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|
|