1. Dismiss Notice
  2. GOG.com logo

    Thanks to YOUR votes, GOG.com now sells:
    - Sea Dogs - Sea Dogs: Caribbean Tales
    - Sea Dogs: City of Abandoned Ships

    Vote now to add Pirates of the Caribbean to the list!

    Dismiss Notice
  3. Under the Crossbones Podcast

    A Pirate Podcast with Interviews
    Music, Comedy and all things Pirate!

    - Episode Guide - About - Subscribe -
    - Twitter - Facebook - iTunes - Android -
    - Youtube - Fill the Coffers -

    Dismiss Notice
  4. New Horizons logo

    Quick links for PotC: New Horizons
    - Download latest version
    - Wiki - FAQ - Report bugs here
    - ModDB profile

  5. GOF logo

    Quick links for AoP2: Gentlemen of Fortune 2
    - Downloads and info
    - Historical Immersion Supermod
    - ModDB Profile

Dismiss Notice
New to the forum?
Please take a moment to read our Welcome Message and Forum Rules.

Tutorial Modding Tips & Tricks

Discussion in 'Tutorials' started by Pieter Boelen, Apr 8, 2015.

  1. Pieter Boelen

    Pieter Boelen (Not So) Old Seadog Staff Member Administrator Storm Modder Hearts of Oak Donator

    Joined:
    Nov 11, 2004
    Messages:
    66,575
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
    Here's a bunch of tricks that REALLY help me doing any sort of work with the PotC code:

    1. Don't use Windows Notepad as text editor; I use Notepad++ which is much better, free and can be found here: http://notepad-plus-plus.org/download/v6.7.5.html

    2. Another complete and utter lifesaver that I use is WinMerge: http://winmerge.org/downloads/
    This allows you to compare code files and folders with each other and find all differences.

    3. Add your PotC folder to the Windows Search Index: http://windows.microsoft.com/en-us/windows/improve-windows-searches-using-index-faq#1TC=windows-7
    That way, when using the regular Windows search functionality, it won't just search in the filename, but also in the file CONTENTS! And it is QUICK!

    You can now use Windows Search to find all files that contain reference to certain function or variable names.
    Then open all in Notepad++ and use "search in all files" and you'll have a list of all uses. And all that within a minute or so.

    This is all based on free programs and built-in Windows functionality, but unlocks some really quite powerful options.

    4. The wonderful world of CONSOLE!
    - Open PROGRAM\console.c
    - Find:
    Code:
    void ExecuteConsole()
    {
       ref pchar = GetMainCharacter();
       ref ch;
       int i;
       int limit;
    - Immediately below the last line shown here, add whatever code you want to execute
    - Press F12 while ingame to execute

    If you use windowed mode, this allows you to execute any code "on the fly" while you're still in the game.
    There are a whole bunch of pre-defined sections of code available in the switch statement below. Change switch(0) to whichever one you want.
    Outcomment whatever code you want to use.

    The default "0" case does the following things:
    - If in boarding, enable reload (for if you get stuck during boardings)
    - If ashore or in boarding, set player to player type (returns control if you are stuck and unable to move)

    5. DumpAttributes allows you to to see all the data for any "reference" in the game, which could be a character or a location or a ship or anything else.
    Easiest is to run this through console (see above). The results are put into compile.log; delete that file prior to running this line to get a "clean" one containing only the data you want.

    Examples:
    Code:
    DumpAttributes(pchar);
    DumpAttributes(characterFromID(character_id));
    DumpAttributes(GetShipByID(id));
    DumpAttributes(Locations[FindLocation(pchar.location)]);
    6. TraceAndLog combines the LogIt/Log_SetStringToLog and Trace commands.
    In other words, this logs something to the screen so you can see it while in the game, but also writes it to compile.log so that you can find it later.
     
    Last edited: Dec 12, 2015
  2. Pieter Boelen

    Pieter Boelen (Not So) Old Seadog Staff Member Administrator Storm Modder Hearts of Oak Donator

    Joined:
    Nov 11, 2004
    Messages:
    66,575
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
    I'm responding here to some questions asked in private because the answers may be interesting to others as well.

    It seems one of the main questions is "where is such and such code located?" Often I do not know the answer to that myself, so I use the tricks from the opening post to find out.
    That is always what I find a more relevant skill: You don't need to know all the answers by the top of your head, as long as you know how to get the answers when you need them.
    Of course I do admit to having a bit of a headstart since the past 10 years playing around with the PotC code have at least taught me in what direction to search.

    Generally speaking, the trick is to find some code that you DO know to find, then use the opening post tricks to find the other references to it and repeat that until you find what you look for.
    Good places to start are often InternalSettings.h and BuildSettings.h as those contain toggles and definitions for a wide range of things that are used all over the PROGRAM folder.
    Another good place is seadogs.c because that is the first file that is loaded when you start the game.

    At the moment I am not near my game, so I'm writing the below from memory. Hopefully it can point you in the right direction, though.

    @Levis would be the expert here, since he wrote that mod. If I recall, most Fetch Quest code is found in PROGRAM\QUESTS\quests_common.c (search for "fetch"), with some being in PROGRAM\DIALOGS (search for the generic files for blacksmiths, tailors and shipyards as those contain pretty much ONLY fetch quest code).

    That is probably somewhere in the PROGRAM\SEA_AI folder. My first suggestion would be AIFantom.c because that is where all random sea encounter charactersa are created.

    @Levis recently moved all smuggling related code into PROGRAM\smuggling.c so that is where I would start looking.
    The prices are of course displayed through PROGRAM\INTERFACE\TradeBook.c so that might be another starting point.

    There are indeed some. The main ones that spring to mind are the cargo carrying quests early in the Bartolomeu and Assassin storylines.
    Those require you to carry a certain amount of cargo in order to continue. Therefore that amount of cargo must be able to fit in the hold of the ship you are given, otherwise you're stuck.
    @Bartolomeu o Portugues and @Talisman, do you happen to know any other examples?

    While we have had a fair few coders here who have a proper programming background, I am not one of them.
    In fact, my education prepared me for ship navigation, ship stability, engineering, electrics but not for programming. So I am pretty much completely self-taught.
    I started with some simple programs on my graphical calculator in secondary school and some playing with VBA from a CD-course and made a higher/lower game that way.
    But when I started here at PA! I had very little programming knowledge. I started out by manually merging other people's mods together for my own use.
    Then eventually I (semi-)officially took over the merging job from the great @Nathan Kell (who was a proper programmer). This community was a great help to me to get started.

    When I went to do an internship at a research institute five years ago as part of my education, suddenly I had to do programming for real.
    But while I had never heard of this "MATLAB" thing before, when I started to work with it, it was like "hey, this is just like PotC code!" :cheeky
    And now I no longer work at sea and find myself back at the research institute, pretty much doing programming for a living and still, as I always did, figuring it out as I go along.... ;)

    There are many ways and many places. A proper programmer might be able to give you proper advice here.
    As mentioned above though, I never learned at school and never learned from a book so I can't really give you any references I've actually used.
    One website that has been a great help to me though (in addition to Google) is http://www.matlabtips.com/ .
    That is specifically about MATLAB but a lot of the logic applies to other languages as well and, as I mentioned, the PotC code is at least close enough to MATLAB that my familiarity with the one helped quite a bit with the other.

    Other than that, the best way is to "learn by doing" and ask on the forum if you're not sure about anything so that we can point you in the right direction.

    I'll definitely advise you in whatever way I can. But when it comes to testing, I am not the right person for that one.
    @Hylie Pistof would be the best for that and maybe @ANSEL and @Grey Roger too.
    I myself haven't played the game properly in many, many years but am hoping to get to that again soon once I have sorted out my current main projects.

    What I will probably do is to include your work in the Beta 3.5 WIP once you have something you'd like to get tested so that everybody can play with it and comment.
    Then you can tweak it based on the feedback you get. And if the worst comes to the worst and it doesn't work out, we can always remove it later.
    But while we're still in WIP stage, we can easily put stuff in there just to "see what happens". :wp
     
    J Norrington likes this.
  3. Pieter Boelen

    Pieter Boelen (Not So) Old Seadog Staff Member Administrator Storm Modder Hearts of Oak Donator

    Joined:
    Nov 11, 2004
    Messages:
    66,575
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
    It might also be worth mentioning the Documentation\Build History & Tutorials.pdf file in your game folder that @Thagarr wrote. That contains quite a lot of old, but potentially useful information.
    And there is also the PotC Tutorials forum with all sorts of stuff: http://www.piratesahoy.net/forums/tutorials.86/
     
    Thagarr and J Norrington like this.
  4. Jack Rackham

    Jack Rackham HoO Team Member Quest Writer Storm Modder

    Joined:
    Jul 5, 2004
    Messages:
    3,287
    Gender:
    Male
    Occupation:
    math teacher
    Location:
    Sund, Ramsjö, Sweden
    If you're working with windows 8 maybe you want your most used folders to keep their
    proportions and positions on the desktop. This really speeds up modding for me. And avoids
    a lot of mistakes too.

    @Levis showed me the link to this Shellfolderfix program.
    The picture is just an example of my desktop.
     

    Attached Files:

    Pieter Boelen likes this.
  5. Bartolomeu o Portugues

    Bartolomeu o Portugues Buccaneer Storm Modeller Storm Modder

    Joined:
    Oct 7, 2006
    Messages:
    2,621
    Gender:
    Male
    Occupation:
    web developer
    Location:
    Viana do Castelo - Portugal
    No, I don't remember any other examples.
     
    Pieter Boelen likes this.
  6. Pieter Boelen

    Pieter Boelen (Not So) Old Seadog Staff Member Administrator Storm Modder Hearts of Oak Donator

    Joined:
    Nov 11, 2004
    Messages:
    66,575
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
    Some more amazing modding tricks:

    4. The wonderful world of CONSOLE!
    - Open PROGRAM\console.c
    - Find:
    Code:
    void ExecuteConsole()
    {
       ref pchar = GetMainCharacter();
       ref ch;
       int i;
       int limit;
    - Below this, add whatever code you want to execute
    - Press F12 while ingame to execute

    If you use windowed mode, this allows you to execute any code "on the fly" while you're still in the game.
    There are a whole bunch of pre-defined sections of code available in the switch statement below. Change switch(0) to whichever one you want.
    Outcomment whatever code you want to use.

    The default "0" case does the following things:
    - If in boarding, enable reload (for if you get stuck during boardings)
    - If ashore or in boarding, set player to player type (returns control if you are stuck and unable to move)
    - If you are not in danger, but the location is locked, unlock the location (safeguard for the Soldier Reinforcements and Merchant Guild changes)

    5. DumpAttributes allows you to to see all the data for any "reference" in the game, which could be a character or a location or a ship or anything else.
    Easiest is to run this through console (see above). The results are put into compile.log; delete that file prior to running this line to get a "clean" one containing only the data you want.

    Examples:
    Code:
    DumpAttributes(pchar);
    DumpAttributes(characterFromID(character_id));
    DumpAttributes(GetShipByID(id));
    DumpAttributes(Locations[FindLocation(pchar.location)]);
    6. TraceAndLog combined the LogIt/Log_SetStringToLog and Trace commands.
    In other words, this logs something to the screen so you can see it while in the game, but also writes it to compile.log so that you can find it later.

    All three are definite life-savers for any sort of vaguely advanced modding efforts.

    Edit: This is now added to the opening post as well.
     
    Last edited: Apr 15, 2015
    Armada likes this.
  7. Pieter Boelen

    Pieter Boelen (Not So) Old Seadog Staff Member Administrator Storm Modder Hearts of Oak Donator

    Joined:
    Nov 11, 2004
    Messages:
    66,575
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
    This thread moved to the "Tutorials" forum.

    I noticed we don't seem to have an easy-to-find "HEX editing" guide. Could someone write up a comprehensive one for future reference?
    @Jack Rackham or @Hylie Pistof perhaps?

    A general "adding locators to GM files" might be welcome too as that is quite a common thing to do, but newly joined modders may not be very familiar with that.
     
  8. Jack Rackham

    Jack Rackham HoO Team Member Quest Writer Storm Modder

    Joined:
    Jul 5, 2004
    Messages:
    3,287
    Gender:
    Male
    Occupation:
    math teacher
    Location:
    Sund, Ramsjö, Sweden
    I volunteer then as I already have started on both. If you don't mind Hylie?
     
    Hylie Pistof and Pieter Boelen like this.
  9. Armada

    Armada Sea Dog Staff Member Administrator Project Manager 3D Artist Storm Modder

    Joined:
    Jun 11, 2010
    Messages:
    8,078
    Gender:
    Male
    Occupation:
    Game Developer
    Location:
    Somerset, England
    There's still my Locators Tutorial from ages ago which goes through what each locator is for, how they are formatted and how to change them using Excel.
    It doesn't cover normal editing via TOOL though, so a tutorial on that would be welcome.
     
    Pieter Boelen likes this.
  10. Hylie Pistof

    Hylie Pistof Curmudgeon Staff Member QA Tester Storm Modder

    Joined:
    Jan 15, 2010
    Messages:
    13,754
    Gender:
    Male
    I don't know enough to write a guide. I used to know more but the tutorial I worked off of then is now long gone. Now all I can do is rename what is already there.
     

Share This Page