Home > Tutorials > Common Problems and Mistakes Creating Your First Module

Common Problems and Mistakes Creating Your First Module

This article is a followup to “A Start: Creating a Module to Give Your Player an Item

The previous tutorial worked great for most people, but in talking with some of you and helping with a few problems, I noticed that many of the same mistakes were being made.  Now there is nothing wrong with making mistakes, as long as we learn from them, so let’s take a look at some of the more common problems.

Properly Assigning Resources

When you create a new resource (or duplicate an existing one) the Create New Resource window is shown, and in this window we have two settings labeled Module and Owner Module.  Properly setting these two properties isimportant, and in the case of our first tutorial each is a bit different.

When we created the item, we set Module to not our module, but Core Game Resources instead.  This is because we want the item to be physically be placed in with the other game items, so that the Single Player module, and possibly other modules, can access it.  We set Owner Module to our module, because we do own it and control it.

In the case of the script though, we set Module to be our own module.  The reason for this is that the script is ours, and isn’t to be used by anyone else.  If you accidently set the script to be in the Core Game Resources like you did with the item, then the script would not execute.

UT_AddItemToInventory and Resource Filenames

The function we used to actually add the item to the player’s inventory, was UT_AddItemToInventory.  The first parameter in this function, should be the resource filename of our item.  Note that it is the filename, not the tag or resource name.  It shoudl end in “.uti”.  Essentially the resource filename, is the resource name with the “uti” extention.  You can see the actual filename in the tabs near the top of the editor.
38a50fa05f335bc8a5c2b4cc740fd844

Programming in C++ is an Exact Science

It is a bit of a shame that scripting in Dragon Age is done with C++, but we can’t change that.  For people who have never done any programming before, the leap into C++ coding is often very difficult.  Really that first hurdle into coding in any language is often difficult, and C++ isn’t exactly the most “newbie” friendly language out there.

Programming is writing instructions to the computer in a language that hasvery strict rules, and this often trips people up.  Things like the placement of brackets and semi-colons is vital, and the way a function is called is important.  One common thing I noticed is that many of you were trying to add mutliple items, but doing it allin the same one call to UT_AddItemToInventory, somethign like:

UT_AddItemToInventory(R"Item01.uti",1,R"Item02.uti",1");

Unfortunately you can’t do this.  The computer is dumb, and unlike a Human, it can’t process anythign except exactly what it expects.  If you want to give multiple items, you need to make multiple calls to the function, once for each item.  This makes our script a bit more complicated, because we were also counting how many of the item the player already has, so that we only give them one if they have none.  This is what it might look like for giving multiple items:

iItemCount = CountItemsByTag(oPlayer, "Item01");
if (iItemCount == 0)
     UT_AddItemToInventory(R"Item01.uti", 1);
iItemCount = CountItemsByTag(oPlayer, "Item02");
if (iItemCount == 0)
     UT_AddItemToInventory(R"Item02.uti", 1);

Obviously for multiple items that could get a bit long, but its the simplest way to show it, and I don’t want to get complicated at this point.

Advertisements
Categories: Tutorials
  1. Lance
    November 12, 2009 at 6:28 am

    Thank you John for your informative guides. I have made a few items myself and have incorporated them into my save games and so far there has been no issues. (Haven’t completed the game myself) I would just like to ask you, how do I go about deleting a module? There is no option under ‘manage modules’, I am assuming you do so by deleting the module folder in your addons folder? Could you clarify it for me thanks so much.

    • John Vanderbeck
      November 12, 2009 at 10:01 am

      Lance :

      Thank you John for your informative guides. I have made a few items myself and have incorporated them into my save games and so far there has been no issues. (Haven’t completed the game myself) I would just like to ask you, how do I go about deleting a module? There is no option under ‘manage modules’, I am assuming you do so by deleting the module folder in your addons folder? Could you clarify it for me thanks so much.

      Unfortunately at this point you can not delete modules 😦 Its really very annoying, but Bioware has said the process of properly deleting a module is very complex so they left that out of the toolset.

  2. Cly
    November 12, 2009 at 10:42 pm

    Excellent tutorial and followup. I have one question however:

    When I attempt to compile the script I get the error:
    E: 22:38:02 – equip_script.nsc – Unable to get the resource information for “utility” of type “nsc”

    It seems like the compiler is unable to find the header file? I know in C the header files are usually in the format of file.h, but that doesnt seem to work either. Granted, it could be the debugger is misidentifying the real problem.

    Any suggestions?

    • John Vanderbeck
      November 12, 2009 at 11:12 pm

      That error does indeed indicate the compiler can’t find utility_h
      A few others have had this problem and I have no been able to find what was causing it. I really don’t know if its a toolset bug or an install problem, something to do with the module, or what, i’m sorry 😦 If you inline the ability from utility_h and remove that dependancy, then it will just fail to find the next file in turn. Its strange, and an issue that really needs to be brought to Bioware support I think.

      • Cly
        November 12, 2009 at 11:48 pm

        I see, thanks regardless. Typically with header files (such as stdio and the like) you have to source the header in the same directory the script runs in. I can’t seem to find the utility_h file with a search of my drive at all.

        Is there any chance you could search out the utility_h header from your directory and upload it somewhere?

      • John Vanderbeck
        November 13, 2009 at 10:09 am

        It doesn’t really work like that in the toolset. I’m not sure where the files are stored, but they aren’t just there visible on the drive. You DO have the file though. If you look at the tree view in your scripts, up at the top is core includes.

      • John Vanderbeck
        November 13, 2009 at 10:48 am

        Another modder was having this same problem, and they recently fixed it. Turns out they were setting the script incorrectly. Double check that you have assigned your script in the module property labeled “SCRIPT”. If you have it in “Client Script” it will give this error.

    • Yite
      December 19, 2009 at 7:19 pm

      Make sure you are creating a script and not a client script, so use the one without a C in the icon (took me a few hours until I figured out that is what I was doing wrong)

  3. Rufus
    November 13, 2009 at 12:28 am

    I noticed that when I export my .nss file which references placable_h, the Toolset exports a lot of files to Documents\BioWare\Dragon Age\packages\core\override\toolsetexport. The problem is the presence of these files seems to mess up my game, when they exist I can’t switch parties for one thing (may be due to Shale?). Either way… what am I supposed to do here? Do I have to delete all these automatically exported files manually every time? It seems like I must be doing something wrong.

    • John Vanderbeck
      November 13, 2009 at 10:10 am

      You are doing it right, the toolset is whacky. Bioware has admitted this. What you want to do is pay attention to what gets exported, and then go and delete the stuff that you don’t need. I should do a post about this actually.

  4. Daniel
    November 13, 2009 at 5:09 am

    Hello there, thank you for the tutorial! I created an item according to your instructions but at certain point (after i meet leliana) and I’m at the chantry, the game starts to act weird…My character does not respond very well to my control and when I start to talk to my companions, it appears that the dialogs were reseted. With leliana for instance, the dialogs are always as our first encounter (that she wants to join his quest etc). I don’t know if i messed up the scripts ( I tried to attach another script at the same module renaming the item at the module manager.). Now I can’t get around this bug…not even unchecking the module at the download content and reloading the game, my items don’t show but the bug persists. Below you will find the script:
    // All module events
    #include “utility_h”
    #include “wrappers_h”
    #include “events_h”
    void main()
    {
    event ev = GetCurrentEvent();
    int nEvent = GetEventType(ev);
    Log_Events(“”, ev);
    switch (nEvent)
    {
    ////////////////////////////////////////////////////////////////////////
    // Sent by: The engine
    // When: The module loads from a save game, or for the first time. This event can fire more than
    // once for a single module or game instance.
    ////////////////////////////////////////////////////////////////////////
    case EVENT_TYPE_MODULE_LOAD:
    {
    // this event can fire multiple times, and we only want to do this once
    // So we save a flag inside a number variable. We check it here and if its
    // set already then we know we’ve already done this before. The name of the
    // variable in quotes can be whatever you want.
    int iModuleLoaded = GetLocalInt(OBJECT_SELF, “swrd_soulcalibur”);
    if (iModuleLoaded == 1)
    break;

    // get the object which contains the player
    object oPlayer = GetHero();

    // The flag we save won’t persist beyond the game session, so its a good idea to actually
    // look to see if the player already has the item, unless you WANT them to get another one
    // The name in quotes is the TAG of the item. So what we do is see how many of the item
    // the player already has, and if its 0, we know we haven’t given it to them yet (or they sold it :p)
    int iItemCount = CountItemsByTag(oPlayer, “swrd_soulcalibur”);
    // if its 0, then let’s give them the item. Now this first parameter is a RESOURCE identifier. Note
    // how its formatted. R”resource_file_name”
    // The “R” part is important and identifies it as a resource. The filename is just the filename of the
    // resource. You can see this in the toolset on the tabs up top.
    // The number 1 means give 1 item.
    if (iItemCount == 0)
    UT_AddItemToInventory(R”swrd_soulcalibur.uti”,1);

    // lastly we set that number variable we talked about earlier, to save the fact that we’ve
    // done this already.
    SetLocalInt(OBJECT_SELF, “swrd_soulcalibur”, 1);
    break;
    }
    default:
    {
    break;
    }
    }
    }

    Congratulations on your tutorial and your iniciative. And thank you in advance to any help that you can give me.
    best Regards,
    Daniel

    • John Vanderbeck
      November 13, 2009 at 10:13 am

      Most likely it is being caused by the toolset exporting too many files. I really should have mentioned this in the tutorial but it completely slipped my mind. You can do a TOOLS->EXPORT->EMPTY EXPORT DIRECTORIES if you don’t need the mod anymore, and that will fix everything. If you still need your mod to be active, what you can do is go into “packages\core\override\toolsetexport” (This is located both in your game install and in your document\bioware\ folder), and delete the files you find there.

      • Daniel
        November 13, 2009 at 8:18 pm

        Well, it seems that you were right man, thank you! Well i was so desperate that I actually emptied it by chosing the first option you presented =/. The second one however you mentioned that I must delete all files, but in the previous topic you said that one must pick only those unecessary files…which one should I chose. If is not the latter, which should I deem as critical to my modules effectiveness? About the question that ric posted (help please) belo my question, I’m newbie at C++, is he asking how to generate more the 1 item at the module? Ans this command that you posted is how we do it? Once again thank you for you help and patience.
        Regards,
        Daniel

  5. ric
    November 13, 2009 at 3:35 pm

    help please

    // All module events
    #include “utility_h”
    #include “wrappers_h”
    #include “events_h”
    void main()
    {
    event ev = GetCurrentEvent();
    int nEvent = GetEventType(ev);
    Log_Events(“”, ev);
    switch (nEvent)
    {
    case EVENT_TYPE_MODULE_LOAD:
    {
    int iModuleLoaded = GetLocalInt(OBJECT_SELF, “ric_ring”);
    if (iModuleLoaded == 1)
    break;

    object oPlayer = GetHero();

    int iItemCount = CountItemsByTag(oPlayer, “ric_ring_of_wonders”);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ric_ring_of_wonders.uti”,1);
    int iItemCount = CountItemsByTag(oPlayer, “ric_sword”);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ric_sword.uti”,1);

    SetLocalInt(OBJECT_SELF, “ric_ring”, 1);
    break;
    }
    default:
    {
    break;
    }
    }
    }

    error
    E: 15:17:33 – ric_script.nss – ric_script.nss(28): Variable already used within scope (while compiling var_constants_h.nss)

    28 line is int iItemCount = CountItemsByTag(oPlayer, “ric_sword”);

    i can only see my second item in game

    • John Vanderbeck
      November 13, 2009 at 3:48 pm

      This is actually my mistake. Change the line that says:
      int iItemCount = CountItemsByTag(oPlayer,”ric_sword”);
      TO
      iItemCount = CountItemsByTag(oPlayer,”ric_sword”);
      In other words remove the “int” part from the front of it the second time you call it. The “int” part defines the variable, and in this case you’re defining it twice which you can’t do. My mistake though since I did it in the example, so i’ll fix that.

      • ric
        November 13, 2009 at 4:04 pm

        thanks it works now.

        1 more question

        how do you add space for enchantmant?
        i tried the ITEM_RUNE_ENABLED in the Varible colone but no chane in game.

  6. John Vanderbeck
    November 13, 2009 at 4:06 pm

    ric :

    thanks it works now.

    1 more question

    how do you add space for enchantmant?
    i tried the ITEM_RUNE_ENABLED in the Varible colone but no chane in game.

    Haven’t really looked into the Rune’s so at the moment I don’t know.

  7. John Vanderbeck
    November 13, 2009 at 8:34 pm

    Daniel :

    Well, it seems that you were right man, thank you! Well i was so desperate that I actually emptied it by chosing the first option you presented =/. The second one however you mentioned that I must delete all files, but in the previous topic you said that one must pick only those unecessary files…which one should I chose. If is not the latter, which should I deem as critical to my modules effectiveness? About the question that ric posted (help please) belo my question, I’m newbie at C++, is he asking how to generate more the 1 item at the module? Ans this command that you posted is how we do it? Once again thank you for you help and patience.
    Regards,
    Daniel

    I suggest checking out the article I wrote recently, Preventing the Toolset from Breaking Your Game

  8. Pedro Fonseca
    November 14, 2009 at 6:10 pm

    I seem to be having a very weird problem I was able to create my items and add them to the game, thing is every time I load the game I keep getting them again and again and again I tried everything including deleting the script. Nothing seems to work, and if I disable the module I will obviously not be able to use the items. Any thoughts? Btw great job with this tutorial and thanks for your help.

    • John Vanderbeck
      November 14, 2009 at 6:14 pm

      First off, if you disable the module, you can still use the items. Secondly, as for it continuing to give you items — that could be caused by a mistyped tag in the CountItemsByTag() call, or it could be caused by you giving the items to your party members (at which point the script won’t find them so it makes new ones).

      • Pedro Fonseca
        November 15, 2009 at 4:48 am

        Now I find myself confused since when I disable the module the game gives me the whole module is off speech and then when I enter the game the items that I have created have disappeared. Maybe I’ve done something wrong along the way.
        Also my script is basically a copy off of yours so maybe there is a problem with CountItemsByTag() when you have multiple items (and multiple CountItemsByTag() entries).
        Again thank you for all your hard work.

      • Pedro Fonseca
        November 15, 2009 at 6:28 am

        A question would it not be easier to simply call the script maybe using the console? That would certainly bypass the problem with item duplication.

  9. Spoe
    November 15, 2009 at 1:50 pm

    Hello. Thank you for your tutorial. It is quite helpful. My problem is I am able to use the custom sword I made, but that’s the only item that wants to load into the game. I also made armor for the hero, but no matter what I try, it doesn’t want to import into the game. I tried putting it in the same module with the sword, and i tried making a new module (of course, using your tutorial as a guide). I cannot get the armor to show up. It’s possible I have the thing so convoluted that I should clear it all and try again. Is anyone else having the same difficulties? If others ARE able to import more than one item, then the problem is obviously something I am doing incorrectly.

  10. zpeterson1
    November 15, 2009 at 5:20 pm

    I appreciate your guide I got my custom sword in with it, but How do i add multiple copies of the same item?
    I am a complete noob at this so I probably screwed something up, but I would appreciate your help.
    here:

    // All module events
    #include “utility_h”
    #include “wrappers_h”
    #include “events_h”
    void main()
    {
    event ev = GetCurrentEvent();
    int nEvent = GetEventType(ev);
    Log_Events(“”, ev);
    switch (nEvent)
    {
    ////////////////////////////////////////////////////////////////////////
    // Sent by: The engine
    // When: The module loads from a save game, or for the first time. This event can fire more than
    // once for a single module or game instance.
    ////////////////////////////////////////////////////////////////////////
    case EVENT_TYPE_MODULE_LOAD:
    {
    // this event can fire multiple times, and we only want to do this once
    // So we save a flag inside a number variable. We check it here and if its
    // set already then we know we’ve already done this before. The name of the
    // variable in quotes can be whatever you want.
    int iModuleLoaded = GetLocalInt(OBJECT_SELF, “gen_im_qck_book_attribute2.uti”);
    if (iModuleLoaded == 1)
    break;

    // get the object which contains the player
    object oPlayer = GetHero();

    // The flag we save won’t persist beyond the game session, so its a good idea to actually
    // look to see if the player already has the item, unless you WANT them to get another one
    // The name in quotes is the TAG of the item. So what we do is see how many of the item
    // the player already has, and if its 0, we know we haven’t given it to them yet (or they sold it :p)
    int iItemCount = CountItemsByTag(oPlayer, “gen_im_qck_book_attribute2.uti”);
    // if its 0, then let’s give them the item. Now this first parameter is a RESOURCE identifier. Note
    // how its formatted. R”resource_file_name”
    // The “R” part is important and identifies it as a resource. The filename is just the filename of the
    // resource. You can see this in the toolset on the tabs up top.
    // The number 1 means give 1 item.
    if (iItemCount == 0)
    UT_AddItemToInventory(R”gen_im_qck_book_attribute2.uti”,25);

    // lastly we set that number variable we talked about earlier, to save the fact that we’ve
    // done this already.
    SetLocalInt(OBJECT_SELF, “gen_im_qck_book_attribute2.uti”,1);
    break;
    }
    default:
    {
    break;
    }
    }

    • John Vanderbeck
      November 15, 2009 at 5:22 pm

      I don’ tthink you can have multiple books, but the script looks correct for multiple items. Try it with something generic like a basic sword or something.

  11. lqvo
    November 16, 2009 at 6:39 am

    Hey man,
    Thanks for the tutorials. I got everything right. I added the items I created to my char. However, when my char leveled up and i distributed the stats points, my stat is increased by two instead of 1. Im not sure what happened. I emptied the export but the problems linger =( … any help is appreciated

  12. x999
    November 16, 2009 at 6:48 am

    i have this problem all my item can load and i have only 1 active mod but like Daniel after i load my mod, my companions dont recognize me. they keep repeating 1st encounter dialog. this is the script im using for my mod.

    // All module events
    #include “utility_h”
    #include “wrappers_h”
    #include “events_h”
    void main()
    {
    event ev = GetCurrentEvent();
    int nEvent = GetEventType(ev);
    Log_Events(“”, ev);
    switch (nEvent)
    {
    ////////////////////////////////////////////////////////////////////////
    // Sent by: The engine
    // When: The module loads from a save game, or for the first time. This event can fire more than
    // once for a single module or game instance.
    ////////////////////////////////////////////////////////////////////////
    case EVENT_TYPE_MODULE_LOAD:
    {
    // this event can fire multiple times, and we only want to do this once
    // So we save a flag inside a number variable. We check it here and if its
    // set already then we know we’ve already done this before. The name of the
    // variable in quotes can be whatever you want.
    int iModuleLoaded = GetLocalInt(OBJECT_SELF, “ranger_longsword”);
    if (iModuleLoaded == 1)
    break;

    // get the object which contains the player
    object oPlayer = GetHero();

    // The flag we save won’t persist beyond the game session, so its a good idea to actually
    // look to see if the player already has the item, unless you WANT them to get another one
    // The name in quotes is the TAG of the item. So what we do is see how many of the item
    // the player already has, and if its 0, we know we haven’t given it to them yet (or they sold it :p)
    int iItemCount = CountItemsByTag(oPlayer, “ranger_longsword”);
    // if its 0, then let’s give them the item. Now this first parameter is a RESOURCE identifier. Note
    // how its formatted. R”resource_file_name”
    // The “R” part is important and identifies it as a resource. The filename is just the filename of the
    // resource. You can see this in the toolset on the tabs up top.
    // The number 1 means give 1 item.
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_longsword.uti”,99);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_longbow.uti”,99);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_dagger.uti”,99);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_amulet.uti”,99);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_belt.uti”,99);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_ring.uti”,99);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_shield.uti”,99);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_helm.uti”,99);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_heavy_armor.uti”,99);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_heavy_helm.uti”,99);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_heavy_gloves.uti”,99);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_heavy_boots.uti”,99);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_light_armor.uti”,99);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_light_boots.uti”,99);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_light_boots1.uti”,99);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_light_gloves.uti”,99);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_medium_armor.uti”,99);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_medium_gloves.uti”,99);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_ceremonial_gloves.uti”,99);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_ceremonial_armor.uti”,99);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”ranger_ceremonial_helm.uti”,99);
    // lastly we set that number variable we talked about earlier, to save the fact that we’ve
    // done this already.
    SetLocalInt(OBJECT_SELF, “”, 99);
    break;
    }
    default:
    {
    break;
    }
    }
    }

    ive already tried emptying the export directories. oh, the tutorial is great. really helped me a lot. and thanks for for any advice that u can give.

  13. hot'n toth
    November 16, 2009 at 1:00 pm

    Inventory Subgroup is just about where in youre inventory the items are going to show up. If it’s a staff and you got staff subgroup it shows up with staffs, but if you just leave it as it is all custom items will show up at the same spot.

  14. November 17, 2009 at 7:57 pm

    Hi, first off, wonderful walkthrough! just some slight problems..

    I made one module and followed the instructions step by step and eventually it worked fine.

    but I just tried to make a new module (for a different char with different desires in armor) I figured I’d make a new module to be able to seperate the 2, instead of just giving all my chars every piece of armor I make..

    But I can’t seem to get it to work.. it does Not show any errors in the editor, but it also does Not give any items ingame.. my script looks like;

    {
    event ev = GetCurrentEvent();
    int nEvent = GetEventType(ev);
    Log_Events(“”, ev);
    switch (nEvent)
    {
    ////////////////////////////////////////////////////////////////////////
    // Sent by: The engine
    // When: The module loads from a save game, or for the first time. This event can fire more than
    // once for a single module or game instance.
    ////////////////////////////////////////////////////////////////////////
    case EVENT_TYPE_MODULE_LOAD:
    {
    // this event can fire multiple times, and we only want to do this once
    // So we save a flag inside a number variable. We check it here and if its
    // set already then we know we’ve already done this before. The name of the
    // variable in quotes can be whatever you want.
    int iModuleLoaded = GetLocalInt(OBJECT_SELF, “eli_chest_wild”);
    if (iModuleLoaded == 1)
    break;

    // get the object which contains the player
    object oPlayer = GetHero();

    // The flag we save won’t persist beyond the game session, so its a good idea to actually
    // look to see if the player already has the item, unless you WANT them to get another one
    // The name in quotes is the TAG of the item. So what we do is see how many of the item
    // the player already has, and if its 0, we know we haven’t given it to them yet (or they sold it :p)
    int iItemCount = CountItemsByTag(oPlayer, “eli_chest_wild”);
    // if its 0, then let’s give them the item. Now this first parameter is a RESOURCE identifier. Note
    // how its formatted. R”resource_file_name”
    // The “R” part is important and identifies it as a resource. The filename is just the filename of the
    // resource. You can see this in the toolset on the tabs up top.
    // The number 1 means give 1 item.
    if (iItemCount == 0)
    UT_AddItemToInventory(R”eli_amu_wild.uti”,1);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”eli_belt_wild.uti”,1);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”eli_boots2_wild.uti”,1);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”eli_boots_wild.uti”,1);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”eli_chest_wild.uti”,1);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”eli_dag_wild.uti”,1);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”eli_gloves2_wild.uti”,1);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”eli_gloves_wild.uti”,1);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”eli_head_wild.uti”,1);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”eli_ring1_wild.uti”,1);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”eli_ring2_wild.uti”,1);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”eli_shield_wild.uti”,1);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”eli_sword1_wild.uti”,1);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”eli_sword2_wild.uti”,1);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”eli_bow.uti”,1);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”eli_arr_am.uti”,1);
    // lastly we set that number variable we talked about earlier, to save the fact that we’ve
    // done this already.
    SetLocalInt(OBJECT_SELF, “eli_chest_wild”, 1);
    break;
    }
    default:
    {
    break;
    }
    }
    }

    (P.S blog probably messes up formatting, not my fault :P)

    I can’t see anything wrong here.. although I don’t know any C++ 😛

    • John Vanderbeck
      November 17, 2009 at 8:29 pm

      The script looks a bit awkward but shouldn’t be causing the problem as long as all the tags/resource names are type correctly. Did you remember to assign this script to your module in the SCRIPT property? Everything exported?

      • November 17, 2009 at 8:40 pm

        Doh! lol, I didn’t have the module assigned to actually run the script 😛

        Thanks very much.

        One more thing.. Anybody know how to add Rune slots to weapons?

      • John Vanderbeck
        November 17, 2009 at 8:49 pm

        Not something i’ve messed with yet. But have you tried opening the [b]Variables[/b] property and setting the RUNE_ENABLED variable to 1?

      • November 17, 2009 at 8:57 pm

        Yeah, I saw that bit too, but I couldn’t edit the value.

        on another note, Any idea what the item properties;

        Lucky
        Messy Kills
        Morrigan’s Protection
        Telekinetic

        do?

        I’ve already figured out Spellshield (it’s the same as mage spell, 75% chance hostile magic will drain mana instead of health) and I figure Reduce Hostility does just that.. Increase monetary gain is like a bargaining skill, I haven’t tested this, but I’m guessing from reading between lines and such.

        Thank you for the speedy replies.

      • Nasuradin
        November 20, 2009 at 1:51 pm

        I assume Telekinetic adds armor-pierce to weapons just as the weapon enchant spell Telekinetic Weapons does from the line of force spells.
        It was mentioned somewhere above but Messy Kills I assume will increase your chance to do fatalities to enemies you kill.
        I speculate Morrigan’s Protection might be the property that protects you in the story plot, if you agree to let her do so? But then if it is, it is somewhat of a useless item property so I don’t know.

  15. John Y. (Nortuk)
    November 18, 2009 at 6:37 am

    I am pretty sure messy kills increases your chance to fatality.

    Oh, Thanks for all the tutorials.
    Been reading through them all, keep up the good work! 🙂
    Hope I can put some use to them for the Zyyna mod.

  16. Randy
    November 19, 2009 at 11:42 am

    Hey John, great tutorial and I’ve been able to one item modules successfully but hate having 10 modules loading to get all the items I want. Working on two I followed your advice above but I must have missed something. Here’s what I got:

    // All module events
    #include “utility_h”
    #include “wrappers_h”
    #include “events_h”
    void main()
    {
    event ev = GetCurrentEvent();
    int nEvent = GetEventType(ev);
    Log_Events(“”, ev);
    switch (nEvent)
    {
    case EVENT_TYPE_MODULE_LOAD:
    {
    int iModuleLoaded = GetLocalInt(OBJECT_SELF, “daishar_gimme”);
    if (iModuleLoaded == 1)
    break;

    object oPlayer = GetHero();

    int iItemCount = CountItemsByTag(oPlayer, “daishar_boots”);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”daishar_boots.uti”,1);
    iItemCount = CountItemsByTag(oPlayer,”daishar_chest”);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”daishar_chest.uti”,1);

    SetLocalInt(OBJECT_SELF, “daishar_gimme”, 1);
    break;
    }
    default:
    {
    break;
    }
    }
    }

    And this is the error I get:
    E: 08:36:50 – daishar_gimme_script.nss – daishar_gimme_script.nss(2): After compound statement at end

    What am I missing? Any help would be appreciated.

    • John Vanderbeck
      November 19, 2009 at 11:53 am

      The compound statement error typically means a bad quote mark on the line. Usually caused by copying and pasting the code from here. Just re-type your quotes.

  17. hek
    November 22, 2009 at 4:30 am

    Hello, thanks for the guide. Unfortunately for me its been going well until the scripting part; i copied your pregiven script:

    / All module events
    #include “utility_h”
    #include “wrappers_h”
    #include “events_h”
    void main()
    {
    event ev = GetCurrentEvent();
    int nEvent = GetEventType(ev);
    Log_Events(“”, ev);
    switch (nEvent)
    {
    ////////////////////////////////////////////////////////////////////////
    // Sent by: The engine
    // When: The module loads from a save game, or for the first time. This event can fire more than
    // once for a single module or game instance.
    ////////////////////////////////////////////////////////////////////////
    case EVENT_TYPE_MODULE_LOAD:
    {
    // this event can fire multiple times, and we only want to do this once
    // So we save a flag inside a number variable. We check it here and if its
    // set already then we know we’ve already done this before. The name of the
    // variable in quotes can be whatever you want.
    int iModuleLoaded = GetLocalInt(OBJECT_SELF, “hk_raigeki”);
    if (iModuleLoaded == 1)
    break;

    // get the object which contains the player
    object oPlayer = GetHero();

    // The flag we save won’t persist beyond the game session, so its a good idea to actually
    // look to see if the player already has the item, unless you WANT them to get another one
    // The name in quotes is the TAG of the item. So what we do is see how many of the item
    // the player already has, and if its 0, we know we haven’t given it to them yet (or they sold it :p)
    int iItemCount = CountItemsByTag(oPlayer, “hk_raigeki”);
    // if its 0, then let’s give them the item. Now this first parameter is a RESOURCE identifier. Note
    // how its formatted. R”resource_file_name”
    // The “R” part is important and identifies it as a resource. The filename is just the filename of the
    // resource. You can see this in the toolset on the tabs up top.
    // The number 1 means give 1 item.
    if (iItemCount == 0)
    UT_AddItemToInventory(R”hk_raigeki.uti”,1);

    // lastly we set that number variable we talked about earlier, to save the fact that we’ve
    // done this already.
    SetLocalInt(OBJECT_SELF, “hk_raigeki”, 1);
    break;
    }
    default:
    {
    break;
    }
    }
    }

    yet the item does not spawn no matter where i load. is there an error in my script?

    • John Vanderbeck
      November 22, 2009 at 10:36 am

      Hek,
      When you compile the script, check the log for errors. If you simply copy and pasted the script from here, then chances are that your quotes got messed up, so you need to retype the quotes.

      • hek
        November 22, 2009 at 2:14 pm

        the errors that came up are:
        No starting area specified for campaign

        and
        E: 11:13:37 – module_core_raigeki.nss – module_core_raigeki.nss(9): Undefined identifier (Lag_Events)

        the script is now:

        // All module events
        #include “utility_h”
        #include “wrappers_h”
        #include “events_h”
        void main()
        {
        event ev = GetCurrentEvent();
        int nEvent = GetEventType(ev);
        Lag_Events(“”,ev);
        switch (nEvent)
        {
        case EVENT_TYPE_MODULE_LOAD:
        {
        int iModuleLoaded = GetLocalInt(OBJECT_SELF, “hk_raigeki”);
        if (iModuleLoaded == 1)
        break;
        object oPlayer = GetHero();
        int iItemCount = CountItemsByTag
        (oPlayer, “hk_raigeki”);
        int iItemCount = 0
        object [] arParty = GetPartyPoolList();
        int i = 0
        int nSize = GetArraySize(arParty)
        object oFollower;for(i=o;i < nSize; i++)
        {
        oFollower = arParty[i];
        iItemCount = iItemCount + CountItemsByTag(oFollower, "hk_raigeki");
        }
        if (iItemCount == 0)
        UT_AddItemToInventory(R"hk_raigeki.uti",1);
        SetLocalIten(OBJECT_SELF, "hk_raigeki", 1);
        break;
        }
        default:
        {
        break;
        }
        }
        }

  18. John Vanderbeck
    November 22, 2009 at 2:18 pm

    hek :

    the errors that came up are:
    No starting area specified for campaign

    and
    E: 11:13:37 – module_core_raigeki.nss – module_core_raigeki.nss(9): Undefined identifier (Lag_Events)

    the script is now:

    // All module events
    #include “utility_h”
    #include “wrappers_h”
    #include “events_h”
    void main()
    {
    event ev = GetCurrentEvent();
    int nEvent = GetEventType(ev);
    Lag_Events(“”,ev);

    The no starting area is just a warning and can be ignored in this case. As for your error, it is in line 9 here: Lag_Events should be Log_Events — though in truth you could just remove that whole line.

    • hek
      November 22, 2009 at 10:32 pm

      tinkered and tinkered with it, fixed the lag to log.. but still no go 😦
      maybe i was just never meant to script?

      // All module events
      #include "utility_h"
      #include "wrappers_h"
      #include "events_h"
      void main()
      {
          event ev = GetCurrentEvent();
          int nEvent = GetEventType(ev);
          Log_Events("",ev);
          switch (nEvent)
          {
             case EVENT_TYPE_MODULE_LOAD:
             {
              int iModuleLoaded = GetLocalInt(OBJECT_SELF, "hk_raigeki");
              if (iModuleLoaded == 1)
                  break;
              object oPlayer = GetHero();
              int iItemCount = CountItemsByTag(oPlayer, "hk_raigeki");
      int iItemCount = 0
      object [] arParty = GetPartyPoolList();
      int i = 0
      int nSize = GetArraySize(arParty)
      object oFollower;for(i=o;i &lt; nSize; i++)
          {
              oFollower = arParty[i];
          iItemCount = iItemCount + CountItemsByTag(oFollower, &quot;hk_raigeki&quot;);
      }
      if (iItemCount == 0)
          UT_AddItemToInventory(R&quot;hk_raigeki.uti&quot;,1);
          SetLocalIten(OBJECT_SELF, &quot;hk_raigeki.uti&quot;, 1);
          break;
             }
             default:
             {
              break;
             }
          }
      }
      
  19. Ryan G
    November 22, 2009 at 7:45 pm

    Hey, first of all just wanted to say thanks for these tutorials =) Today I went ahead and tried to create an item as per your directions, now when i got to the scripting part i copy and pasted because I don’t know anything about c++

    // All module events
    #include "utility_h"
    #include "wrappers_h"
    #include "events_h"
    void main()
    {
    event ev = GetCurrentEvent();
    int nEvent = GetEventType(ev);
    Log_Events("", ev);
    switch (nEvent)
    {
    case EVENT_TYPE_MODULE_LOAD:
    {
    // get the object which contains the player
    object oPlayer = GetHero();
    
    object oArmor = GetObjectByTag("arc_arcanearmors");
    
    if (!IsObjectValid(oArmor))
    UT_AddItemToInventory(R"arc_arcanearmors.uti",1);
    break;
    }
    default:
    {
    break;
    }
    }
    }

    but when i save the script I get the following errors.
    I: 19:27:58 – module_core_arcanearmor.nss – The resource “module_core_arcanearmor.nss” has been saved.
    I: 19:27:58 – Offers.xml file has been updated successfully.
    I: 19:27:58 – AddIns.xml file has been updated successfully.
    I: 19:27:58 – Generated the campaign file.
    W: 19:27:58 – No starting area specified for campaign.
    I: 19:27:58 – Compile failed
    E: 19:27:58 – module_core_arcanearmor.nss – module_core_arcanearmor.nss(2): After compound statement at end
    I: 19:27:58 – Compiling module_core_arcanearmor.nss…

    • Ryan G
      November 22, 2009 at 7:56 pm

      Sorry new to this site, unsure if I can edit my post or not so I decided to reply to my own post. Just to say that directly AFTER posting I scrolled up a bit and read a comment where you told someone that copy and pasting from this site to the script in the toolset could mess up the quotations that were copied. So I went back to the toolset, changed those and now everything works. Thanks =)

  20. Schoft
    November 27, 2009 at 5:35 am

    OMG!! why does it have to be so complicated, couldnt they just let us create a UTI file, and manually with console type give_item ubersword.UTI something like that faaaawwkk.
    I give up, i cant get it to work, the mod shows up in game menu, but no item whatsoever ;-(

  21. Schoft
    November 27, 2009 at 11:34 pm

    I GOT AN ITEM ! 🙂 just made a small mistake, thank you for the explanations, in my dissapointment forgot that ^^
    Is it possible just to make multiple items, using the same script ? ofc i will change the names in the scripts, just wondering.

    • Schoft
      November 28, 2009 at 3:41 am

      nvm

  22. Mike Smiyj
    December 5, 2009 at 10:30 am

    I think i broke it lol.

    I done somthing to mess up my game prob down to me messing around witrh stuff before finding your tutorials.

    none of my characters auto attack anymore, i have to click each time i want to attack.

    Guess the only way around this is reinstalling.

    HAve tried removing all the item I created but nothing still ahving the same problems.

    • John Vanderbeck
      December 5, 2009 at 10:33 am

      @Mike Smiyj
      Go to My Documents\Bioware\Dragon Age\Modules\Single Player and delete anything you find there
      Then do the same in My Documents\Bioware\Dragon Age\Packages\Core
      Lastly disable any mods you have installed.

  23. weigty
    December 13, 2009 at 2:15 am

    I know this is an older article but you seemed so helpful I thought I would ask here!
    I followed the tutorial you posted and everything seems to be correct it compiled properly and it shows the module in my downloadable content but the Item does not show in game. Not sure if its a problem with my script or what!

    //All module events
    #include "utility_h"
    #include "wrappers_h"
    #include "events_h"
    void main()
    {
        event ev = GetCurrentEvent();
        int nEvent = GetEventType(ev);
        Log_Events("",ev);
        switch (nEvent)
        {
            case EVENT_TYPE_MODULE_LOAD:
            {
                int iModuleLoaded = GetLocalInt(OBJECT_SELF,"klw_deathsfinger");
                    if (iModuleLoaded == 1)
                    break;
    
                    object oPlayer = GetHero();
    
                    int iItemCount = CountItemsByTag(oPlayer, "klw_deathsfinger");
                    if (iItemCount == 0)
                    UT_AddItemToInventory(R"klw_deathsfinger.uti",1);
    
                    SetLocalInt(OBJECT_SELF, "klw_deathsfinger",1);
                    break;
            }
            default:
            {
                break;
            }
        }
    }
    • John Vanderbeck
      December 13, 2009 at 7:54 am

      If it compiles but doesn’t show up then you have something set up wrong. Either you forgot to assign your script to the module, you have the script assigned wrong, or the item isn’t setup properly, or exported properly. Everyone who has had this problem has found they missed a step somewhere. Best advice I can give is to just go back through it all very carefully. In this toolset just one very small minor mistake can make it all not work.

      • weigty
        December 13, 2009 at 3:02 pm

        Hey Thanks for the reply you are right it was a very simple mistake in the item itself. Great tutorial.

  24. rob
    February 14, 2010 at 7:05 pm

    hey er im kinda stuck with the script I kinda under stand it I have look in to c++ before though this script has me puzzled what im doing worng

    heres the script i am useing

    // All module events
    #include “utility_h”
    #include “wrappers_h”
    #include “events_h”
    void main()
    {
    event ev = GetCurrentEvent();
    int nEvent = GetEventType(ev);
    Log_Events(“”, ev);
    switch (nEvent)
    {
    case EVENT_TYPE_MODULE_LOAD:
    {

    // get the object which contains the player
    object oPlayer = GetHero();

    int iItemCount = CountItemsByTag(oPlayer, “newitem”);
    if IsObjectValid(sword)
    UT_AddItemToInventory(R”pee_gold2_sword.uti”,1);

    SetLocalInt(OBJECT_SELF, “newitem”, 1);
    break;
    }
    default:
    {
    break;
    }
    }
    }

    pointing me to the right direction is much presated

    oh yeah please mind the spelling i know i cant spell

  25. abandon
    May 9, 2010 at 10:50 am

    Hi there and thanks for some great tutorials. Ive basically wanted a couple sets of Wades superior dragon armor.. initially i copied the script you posted and checked the item to loaded to the dragonscale looted from the high lord dragon. this reinitiated the quest and i got Wade to craft me a medium armor set ( i have originally picked up the heavy set ). After that success i decided i wanted another heavy set.. so i reloaded, dragonscale reappeared in my inventory and off to Wades i went. However.. no matter what option i chose from him, he kept crafting the medium set for me! gggrr! So… i thought id use your script to directly add a heavy set to my inventory using this script:

    // All module events
    #include “utility_h”
    #include “wrappers_h”
    #include “events_h”
    void main()
    {
    event ev = GetCurrentEvent();
    int nEvent = GetEventType(ev);
    Log_Events(“”, ev);
    switch (nEvent)
    {
    ////////////////////////////////////////////////////////////////////////
    // Sent by: The engine
    // When: The module loads from a save game, or for the first time. This event can fire more than
    // once for a single module or game instance.
    ////////////////////////////////////////////////////////////////////////
    case EVENT_TYPE_MODULE_LOAD:
    {
    // this event can fire multiple times, and we only want to do this once
    // So we save a flag inside a number variable. We check it here and if its
    // set already then we know we’ve already done this before. The name of the
    // variable in quotes can be whatever you want.
    int iModuleLoaded = GetLocalInt(OBJECT_SELF, “gimme_dragonarmor”);
    if (iModuleLoaded == 1)
    break;

    // get the object which contains the player
    object oPlayer = GetHero();

    // The flag we save won’t persist beyond the game session, so its a good idea to actually
    // look to see if the player already has the item, unless you WANT them to get another one
    // The name in quotes is the TAG of the item. So what we do is see how many of the item
    // the player already has, and if its 0, we know we haven’t given it to them yet (or they sold it :p)
    int iItemCount = CountItemsByTag(oPlayer, “gen_im_arm_glv_hvy_drb”);
    // if its 0, then let’s give them the item. Now this first parameter is a RESOURCE identifier. Note
    // how its formatted. R”resource_file_name”
    // The “R” part is important and identifies it as a resource. The filename is just the filename of the
    // resource. You can see this in the toolset on the tabs up top.
    // The number 1 means give 1 item.
    if (iItemCount == 0)
    UT_AddItemToInventory(R”gen_im_arm_glv_hvy_drb.uti”,1);
    iItemCount = CountItemsByTag(oPlayer, “gen_im_arm_cht_hvy_drb”);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”gen_im_arm_cht_hvy_drb.uti”,1);
    iItemCount = CountItemsByTag(oPlayer, “gen_im_arm_bot_hvy_drb”);
    if (iItemCount == 0)
    UT_AddItemToInventory(R”gen_im_arm_bot_hvy_drb.uti”,1);

    // lastly we set that number variable we talked about earlier, to save the fact that we’ve
    // done this already.
    SetLocalInt(OBJECT_SELF, “gimme_dragonarmor”, 1);
    break;
    }
    default:
    {
    break;
    }
    }
    }

    It compiles and exports with no problems, shows up in my downloaded content however.. i dont get any items! Ive tried selling my original heavy set and reloading, destroying it and reloading, changing the: if (iItemCount == 0) to: if (iItemCount == 1). In the script properties the module and owner module are both the module i created (Custom Items), in the manage modules section the single player is selected. Kind of at a loss…is it something to do with the module properties maybe? Should i change the script in the module properties from module_core to the name of the script above? Thanks a lot for all your help!

    • abandon
      May 9, 2010 at 10:57 am

      nevermind, im a dummy and answered my own question… :S

      thanks!

  26. Titan
    August 4, 2010 at 7:20 am

    Good work on the tutorial! My problem is that whenever I put “#include “utility_h”” into a script and try to save, the toolset hangs. I have tested several times; I can save with every other lines but not with this one.

    I also tried to insert this line(UT_AddItemToInventory) into the script; but it makes the script unable to export because of “Parsing variable list”.
    object UT_AddItemToInventory(resource rItem, int nNumToAdd = 1, object oInvOwner = OBJECT_INVALID, string sTag = “”, int bSuppressNote = FALSE, int bDroppable = TRUE);

    Thanks!

  27. Diana Ochoa
    October 1, 2010 at 12:50 am

    hey i keep getting this error
    E: 22:45:48 – module_core_femalemage.nss – module_core_femalemage.nss(2): After compound statement at end

    what does that mean and how do i fix it?
    when the script compiles it always fails. what am i doing wrong 😦

  28. Elizabeth
    August 6, 2013 at 12:08 pm

    Thank You, Thank You, Thank You! Yes, it’s 2013 and some of us are just learning the DAO Toolset! 🙂

    Hope you still read these comments because I’m so grateful for your tutorials and the kind, patent and thorough way you answer questions. Your work here is fantastic and must’ve taken a great amount of time to accomplish.

    Again, my many, many thanks!
    Elizabeth

    • John Vanderbeck
      August 6, 2013 at 3:23 pm

      Thank you for the kind words Elizabeth. This is why I made this resource to being with, and why I keep it online for everyone to learn from. I wish I had the time to still play an active role, but alas I do not. I’m happy that this archive here can still be useful though.

      Take care!

  1. April 6, 2011 at 2:09 pm

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: