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.

Need Help Create an object in a location

Discussion in 'Storm Coding' started by Southsider, Dec 6, 2016.

  1. Southsider

    Southsider Landlubber

    Joined:
    Jun 23, 2015
    Messages:
    11
    Gender:
    Male
    Occupation:
    C# programmer
    Location:
    Estados Unidos Mexicanos
    Good day vatos. I was trying to figure out how to create an object in a location. My code:

    Code:
    object LoadObjectInLoc;
    
    void LoadTestModel()
    {
        int     n;
        aref    randItem;
        aref al;
       
        FindLocator("Havana_town", "patrol7", &al, true); // Find locator coordinates
               
        n = Items_FindItem("blade7", &randItem); // Load object model and directory
               
        Items_LoadModel(&LoadObjectInLoc,  randItem); // Create an object
    
        SendMessage(&LoadObjectInLoc, "lffffffffffff", MSG_MODEL_SET_POSITION, makeFloat(al.x), makeFloat(al.y), makeFloat(al.z), makeFloat(al.vx.x), makeFloat(al.vx.y), -makeFloat(al.vx.z), makeFloat(al.vy.x), makeFloat(al.vy.y), -makeFloat(al.vy.z), makeFloat(al.vz.x), makeFloat(al.vz.y), -makeFloat(al.vz.z)); // Set object position
    
        Log_Info("Test loaded, Coords: " + makeInt(al.x) + " " + makeInt(al.y) + " " + makeInt(al.z) + ", Model: " + randItem.model);
       
    }
    
    Then I call "LoadTestModel()" function and... nothing. Engine establish correct coordinates and correct object model, but the object is not visible on these coordinates. What could be the problem? Or am I doing something wrong?
     
  2. Jack Rackham

    Jack Rackham HoO Team Member Quest Writer Storm Modder

    Joined:
    Jul 5, 2004
    Messages:
    3,288
    Gender:
    Male
    Occupation:
    math teacher
    Location:
    Sund, Ramsjö, Sweden
    I use 2 ways of adding an object.

    1 place a randitem locator in the location by using the TOOL. (Add it to the locator.gm file)
    In the locations file something like:

    Locations[n].locators_radius.randitem.randitem1 = 0.01; (small radius only if it shouldn't be picked up)
    Locations[n].items.randitem1 = "door_M11";

    2 place the 3D-model in the locations folder.
    In the locations file something like:
    Locations[n].models.always.l5 = "lever1_down";

    Method 2 require COL-files to look good. Method 1 can sometimes work without them.
     
  3. Pieter Boelen

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

    Joined:
    Nov 11, 2004
    Messages:
    66,593
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
  4. Southsider

    Southsider Landlubber

    Joined:
    Jun 23, 2015
    Messages:
    11
    Gender:
    Male
    Occupation:
    C# programmer
    Location:
    Estados Unidos Mexicanos
    Yeah. It's working ways, but I would like to make a universal function that puts objects in the coordinates.

    AoP2
     
  5. Pieter Boelen

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

    Joined:
    Nov 11, 2004
    Messages:
    66,593
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
    What exactly do you want to accomplish in the end?
    If we know your end goal, it would be easier to make suggestions.

    Most our suggestions are based on PotC, though most likely the majority of the related tricks apply to AoP2 as well.
     
  6. Southsider

    Southsider Landlubber

    Joined:
    Jun 23, 2015
    Messages:
    11
    Gender:
    Male
    Occupation:
    C# programmer
    Location:
    Estados Unidos Mexicanos
    I want to make a function that will put the object on the specified coordinates. In my code, something is missing.
     
  7. Pieter Boelen

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

    Joined:
    Nov 11, 2004
    Messages:
    66,593
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
    But why do you want to do that? Do you want to fill in x,y,z coordinates in code and then have an object generated there (such as a treasure chest)?
    Or do you want something to be permanently part of the location (not a box or an item that can be picked up)?

    PotC has the convenient feature that "locators" can be generated through code so you can indeed use whatever x,y,z coordinates you want without editing the GM file.
    But I'm pretty sure that is exclusively a feature in the PotC Build Mod, so chances are that you won't be able to use that.
     
  8. Southsider

    Southsider Landlubber

    Joined:
    Jun 23, 2015
    Messages:
    11
    Gender:
    Male
    Occupation:
    C# programmer
    Location:
    Estados Unidos Mexicanos
    Because this is a very handy function to place the object at any time (quest or something else)

    Yeah, you understood me correctly. This should be a static model (like a barrels, planks or some another scenery objects). Making this through the TOOL - isn't very practical, cause it should be possible to add or delete an object, when it's needed.

    As I understand it, can use the following functions:

    Code:
    Items_LoadModel(&LoadObjectInLoc, randItem);
    This function loads the model to add.

    Code:
    SendMessage(&LoadObjectInLoc, "lffffffffffff", MSG_MODEL_SET_POSITION, makeFloat(al.x), makeFloat(al.y), makeFloat(al.z), makeFloat(al.vx.x), makeFloat(al.vx.y), -makeFloat(al.vx.z), makeFloat(al.vy.x), makeFloat(al.vy.y), -makeFloat(al.vy.z), makeFloat(al.vz.x), makeFloat(al.vz.y), -makeFloat(al.vz.z));
    And this function sets the coordinates and rotation angles for loaded model.

    The problem is that the model doesn't appear in the game, though it's loaded correctly and it got the desired coordinates. I opened this topic to find out the reason of this problem. I have a lot alternative ways, but I would like to solve this particular question.
     
  9. Pieter Boelen

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

    Joined:
    Nov 11, 2004
    Messages:
    66,593
    Gender:
    Male
    Occupation:
    Maritime Research: Project Engineer (Analysis)
    Location:
    Wageningen, The Netherlands
    Using @Jack Rackham's suggestion does allow you to remove/add such items "on the fly".
    The only disadvantage is that it requires a reload of the current scene, but I don't think anyone ever found a good way around that.

    There is some PotC main quest code from the unmodded game that does somehow manage to place an item on a locator while remaining in the same scene.
    So in theory I do believe it must be possible to do it, but somebody would need to investigate how to make that work.

    Does it remain in place after you leave the location? If so, does it show when you re-enter the location?
    That is often the issue: That such models only show up after a reload of the location.
    The simplest solution is always to ensure the model is already there before the player actually enters the relevant location.
     
  10. Southsider

    Southsider Landlubber

    Joined:
    Jun 23, 2015
    Messages:
    11
    Gender:
    Male
    Occupation:
    C# programmer
    Location:
    Estados Unidos Mexicanos
    I take a close look the code and understand this: The function, which uses the engine, is responsible for the placement of objects in a scene. It's spelled out in the Modules folder and compilated in one of several file *.dll. If realize my idea, using the PROGRAM folder - will not work.

    So I came to the conclusion - add objects to the location, can only using "randitem" locators, as Jack Rackham have described.
     

Share This Page