Jump to content

adding items to Bodahns store


amycus

Recommended Posts

Hi!

I have been trying to add some of my custom items to Bodhans store, but of course, I can't get it to work. I followed this thread and came up with the following script:

 

#include "wrappers_h"
#include "utility_h"
#include "events_h"

void main()
{
object oMerc = GetObjectByTag("store_camp_bodahn");
//Bodahn's tag
int iAmtToAdd = (4 - CountItemsByTag(oMerc, "champ_mage"));
//4 is total amount in store wanted
CreateItemOnObject(R"champ_mage.uti", oMerc, iAmtToAdd, "champ_mage", FALSE);

object oMerc = GetObjectByTag("store_camp_bodahn");
//Bodahn's tag
int iAmtToAdd = (4 - CountItemsByTag(oMerc, "champ_m_hoo"));
//4 is total amount in store wanted
CreateItemOnObject(R"champ_m_hoo.uti", oMerc, iAmtToAdd, "champ_m_hoo", FALSE);
}
    event ev = GetCurrentEvent();
    int nEvent = GetEventType(ev);
    Log_Events("", ev);
    switch (nEvent)
    {
       case EVENT_TYPE_MODULE_LOAD:
       {




           break;
       }
       default:
       {
           break;
       }
    }
}


Does anyone happen to know what I'm doing wrong? I have tried to get a better understanding of scripts, but I have a hard time finding any useful tutorials.

Edited by amycus
Link to comment
Share on other sites

OK, there were a few issues in your version, here's a script you can use. Just add your items as a separate line under the variables. I've commented it heavily so you can see what is going on. Also, you do NOT need the includes either, however you will need to patch in the DA2 LDFs into the Origins patch folder. Grab them from the DA2 install, erf them in a folder called scripts999 , place the erf in \(My )Documents\BioWare\Dragon Age\packages\core\patch, then load up the toolset.

 

void main()
{
//defined objects
object hero =
   	GetMainControlled();

//You must define the merchant UTI for the current act you are in, they change from act to act. In this case is Bodahns act 1 merch bag.
object oMerc = 
   	GetObjectByTag("store_dae100_bodahn");

//define amount variable, dont add multiple lines defining the same variable.
int iAmtToAdd = 
   	(4 - CountItemsByTag(oMerc, "champ"));

//create the items in the merchant store. replace the item refs with your own item refs.
CreateItemOnObject(R"gen_im_cns_arn_celestial.uti", oMerc, iAmtToAdd, "champ", FALSE);

CreateItemOnObject(R"gen_im_cns_arn_torpor.uti", oMerc, iAmtToAdd, "champ", FALSE);

//Display a nice floaty message saying what happened    	
DisplayFloatyMessage(hero,"Added stuff to Bodahns Act 1 store!", FLOATY_MESSAGE,0xff0000,5.0);
}

Link to comment
Share on other sites

lol! I think you're right, Ish! :tongue:

Ah well, there's a lesson in DA2 scripting for anyone interested at any rate :laugh:

 

 

However, the issues I detailed are also the same for Origins. Can't have multiple entries defining the same object or multiple entries of the same int variable.

Edited by Sunnie
Link to comment
Share on other sites

thanks for the replies, and sorry for not writing it out clearly but yes, I am modding for origins :P

 

I did find something in the toolset wiki now though that will hopefully work better (not sure how I managed to miss that before): http://social.bioware.com/wiki/datoolset/index.php/PRCSCR_Script_Templates#Adding_an_Item_to_an_existing_Vendor_or_Container

 

Not completely sure what they mean by "Replace "$plot_file_name$" and "$check_flag_name$" with the custom plot and plot flags you create for your module.", though.

 

EDIT: Sigh, couldn't figure out what they meant on the page I linked above, and instead tried to check other uploaded mods that added items to bodahns store. Got this:

 

#include "wrappers_h"
#include "utility_h"

void main()
{

   event   ev = GetCurrentEvent();
   int     nEventType = GetEventType(ev);

   switch(nEventType)
   {
       case EVENT_TYPE_MODULE_LOAD:
       {
           object oArea = GetObjectByTag("cam100ar_camp_plains");

           if (IsObjectValid(oArea))
           {
               object oMerchant = GetObjectByTag("store_camp_bodahn");

               if (IsObjectValid(oMerchant))
               {

                   if (UT_CountItemInInventory(R"champ_mage.uti",oMerchant) == 0 && UT_CountItemInInventory(R"champ_mage.uti",GetHero()) == 0)
                       CreateItemOnObject(R"champ_mage.uti",oMerchant,1,"",TRUE);
                   if (UT_CountItemInInventory(R"champ_m_hoo.uti",oMerchant) == 0 && UT_CountItemInInventory(R"champ_m_hoo.uti",GetHero()) == 0)
                       CreateItemOnObject(R"champ_m_hoo.uti",oMerchant,1,"",TRUE);
                   if (UT_CountItemInInventory(R"stf_prl.uti",oMerchant) == 0 && UT_CountItemInInventory(R"stf_prl.uti",GetHero()) == 0)
                       CreateItemOnObject(R"stf_prl.uti",oMerchant,1,"",TRUE);
                   if (UT_CountItemInInventory(R"gsw_prl.uti",oMerchant) == 0 && UT_CountItemInInventory(R"gsw_prl.uti",GetHero()) == 0)
                       CreateItemOnObject(R"gsw_prl.uti",oMerchant,1,"",TRUE);
                   if (UT_CountItemInInventory(R"champ_w.uti",oMerchant) == 0 && UT_CountItemInInventory(R"champ_w.uti",GetHero()) == 0)
                       CreateItemOnObject(R"champ_w.uti",oMerchant,1,"",TRUE);
                   

                   int itemCount = 0;

               }
           }

           break;
       }
   }
}

and... it still doesn't work. Judging from the amount of armor mods who manage this, and the few topics on the subject, it feels like I'm missing something really simple here, but I still cant figure it out.

Edited by amycus
Link to comment
Share on other sites

No idea how I miss things like this, but midnightgeek has apparently already written a short tutorial on it. Hopefully that will work for me...

 

I assume you already have your module created with your custom items. If not there are plenty of tutorials around which can get you to that point. Once you have your module and items created you can come back here.

 

This may seem overly complicated at first, but doing it this way ensures that it will be compatible with any DLC or fan made modules.

 

Step 1: Create the plot file

File -> New -> Plot. I named mine "tmg_bodahn_plot".

Right click -> Insert -> Main flag. Give it a name, I called it "TMG_ITEMS_GIVEN". Default value=Not set

The purpose of the plot flag is to limit the code execution to only the first time the player enters the area.

 

Step 2: Write the script

File -> New -> Script. I named mine "tmg_bodahn".

I used the one from here:

http://social.bioware.com/wiki/datoolset/index.php/PRCSCR_Script_Templates#Adding_an_Item_to_an_existing_Vendor

 

Below is the script using my resource names from step 1:

 

#include "wrappers_h"

#include "plt_tmg_bodahn_plot" // include your custom plot

 

void main()

{

if ( WR_GetPlotFlag( PLT_TMG_BODAHN_PLOT, TMG_ITEMS_GIVEN ) == TRUE ) return;

 

object oStore = GetObjectByTag("store_camp_bodahn"); // use this one for Bodahn/Origins

 

if (IsObjectValid(oStore))

{

CreateItemOnObject(R"magus_staff.uti", oStore, 1, "", TRUE); // repeat this for each item

 

WR_SetPlotFlag( PLT_TMG_BODAHN_PLOT, TMG_ITEMS_GIVEN, TRUE );

}

}

 

Step 3: Create the custom PRCSCR file

Open Excel and create a new file like the one shown here:

http://social.bioware.com/wiki/datoolset/index.php/PRCSCR.xls

 

The value in the "script name" should be the name of the script you created in step 2 in my case "tmg_bodahn"

 

Complile the 2da by using the ExcelProcessor as illustrated here:

http://social.bioware.com/wiki/datoolset/index.php/Compiling_2DAs

 

Name it "PRCSCR_whatever.2DA" and drop it into your module's override directory

(Documents/BioWare/Dragon Age/AddIns/yourModuleName/core/override)

 

Load the game, go to party camp and Bodahn should have your item(s) for sale.

 

Note that there are more than one party camp (some are used for cutscenes) so if your items are not there, travel somewhere and then go back to camp and they should be there.

 

EDIT: No, still doesn't work, even though I have followed the tutorial completely. Script now looks like this:

#include "wrappers_h"
#include "plt_ki_bodahn_plot"  // include your custom plot

void main()
{
 if ( WR_GetPlotFlag( PLT_KI_BODAHN_PLOT, KI_ITEMS_GIVEN ) == TRUE ) return;

 object oContainer = GetObjectByTag("store_camp_bodahn");

 if (IsObjectValid(oStore))
 {
   CreateItemOnObject(R"champ_mage.uti", oContainer, 1, "", TRUE);
   CreateItemOnObject(R"champ_m_hoo.uti", oContainer, 1, "", TRUE);
   CreateItemOnObject(R"stf_prl.uti", oContainer, 1, "", TRUE);
   CreateItemOnObject(R"gsw_prl.uti", oContainer, 1, "", TRUE);

   WR_SetPlotFlag( PLT_KI_BODAHN_PLOT, KI_ITEMS_GIVEN, TRUE );
 }
}

 

Only thing I'm uncertain of, is the 2DA really done by making a .GDA and then just rename the ending to 2DA?

Edited by amycus
Link to comment
Share on other sites

  • 4 weeks later...

The method from the most recent post (and associated tutorial) is the best and most compatible way to add items to store inventories, so you are on the right track.

 

There are some problems in step 3. The PRCSCR override you are creating should be PRCSCR_whatever.gda, not .2da. Just FYI, 2DA is a general type for the file, not a specific format. Just like an "image file" can be .jpg or .gif or some other format, a "2DA" is usually found in either spreadsheet format (.xls) for easy editing or in a compiled binary format (.gda) that the game can actually read.

 

Step 3 also does not tell you to set the AreaListName of the custom PRCSCR 2DA you are creating. The entry for your script in your PRCSCR 2DA must have an AreaListName that matches the area list with the container you are trying to modify. In this case, "cam100ar_camp_plains"; other common containers and their corresponding AreaListName's are shown on the wiki page you linked.

 

If it's still not working after those changes, start debugging by commenting out the plot flag stuff (WR_GetPlotFlag/WR_SetPlotFlag). If it works, the problem is in your plot setup. If it doesn't, the problem is likely in your PRCSCR/arealist setup. That will help narrow down where you need to keep looking.

 

For educational purposes, the PRCSCR stuff is how the game knows to run your script. It will run it any time the player enters an area in that AreaList. The plot flag stuff is to prevent your script from doing the same thing over and over; otherwise it would add inventory to the store every single time the script ran (which would be every single time the player entered an area in that AreaList).

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...