1. 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
  2. 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
  3. New Horizons logo

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

  4. 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.

new-horizons-Adding-Items-During-Game

Aug 9, 2015
new-horizons-Adding-Items-During-Game
  • Adding New Items During Game
    Go back to modding

    Since BETA 3.3 there is an option to add a new item in the game while the game has already started.
    This can be done with the following function:

    Code:

    int itemindex = findemptyItem();
    string id = "nameoftheitem"
    AddItem(itemindex,id, "", 13, 7, 0.05, 3, 0000, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1);
    All the numbers after the first 3 arguments are the same as in the iteminit for InitItem.
    The function findemtyItem() will return a id of an unused slot where the item can go in.
    The item ID can be anything you want as long as it isn't used yet.
    When the ID already exist a error message will be posted in the compile.log saying:
    Code:

    ITEM ADDING ERROR: id already exist
    else it will post something like this:
    Code:

    ITEM ADDED at 806 total items now: 807
    As you see it gives the total number of items and the Index at which it was added.

    You can use variables in the Item Name and description.
    To do that you first need to get the Item after you made it.
    You can do this with the following command:
    Code:

    ref genitm;
    makeref(genitm,Items[itemindex]);
    The itemindex in here is the one we found and added the item to in the code snipped above.
    Now you can assign more properties to the item.
    Like this:
    Code:

    genitm.name = "Patrol Schedule #sisland# version #dversion#";
    genitm.describe = "Patrolling schedule for #sisland#.";
    genitm.island = sisland.name;
    genitm.version = sisland.Smuggling.patrolversion;
    Now when the item shows up somewhere it will use the island and version which are set to the item in the name and description.
    You can add other variables to by just adding them like this.

Share This Page