Aller au contenu

Photo

Altering an existing merchant's inventory.


  • Veuillez vous connecter pour répondre
15 réponses à ce sujet

#1
AstralFire

AstralFire
  • Members
  • 28 messages
How would I go about doing that? I'd like to make it so that the dwarf merchant in camp offers unlimited of the special arrows, plus a new arrow or two I'm working on making; it is certainly possible to just make the game spawn items endlessly at my behest, but if I'm going to make the mod public, I want it to be a little more polished.

On a similar note - having trouble adding new crafting recipes. I extended the 2DA as outlined in a tutorial, compiled it into GDA, then dropped the new GDA into the override folder; the toolset refuses to read it, so I can't make a new, purchaseable item which would actually teach how to make these new recipes. I'd be fine letting players automatically know the recipe, but I don't know how to do that, either. This was my original plan for obtaining the arrows, until I realized nothing besides liferoot and deathroot was really cheap enough...

#2
AND04

AND04
  • Members
  • 154 messages
I am lil tired atm (up 40+hs now /o\\ sp i'll just say that i could help if needed but need some sleep first - in the meantime you could ask DangerousFat , i helped him out on his Stamina Potion  Mod and it does nearly excactly what you want to do (create recipies and add items to Bodhan).

#3
ITSSEXYTIME

ITSSEXYTIME
  • Members
  • 1 201 messages
I'm also curious on how to do this. I figured I could just look at how you guys did it in your Stam potion mod script file but I'm assuming .ncs means it's compiled and the Toolset won't let me open it to see how you did it.



Not that I intend to rip off your work or anything, I'm just at a loss on what I need to do script wise.

#4
AND04

AND04
  • Members
  • 154 messages
ok, well let me outline what we did:



basicaly you figure out the tag of the merchant-object (either by browsing through the game-files with the toolset looking for a .utm file) or by just getting all in the area with GetAllObjectsInArea of type Merchant and print the tags to your screen using a Floaty.



then use GetObjectByTag to get the spezific Merchant you want.



After that ist quite simple - CreateItemOnObject - only thing we can't do this way is setting something to an infinite stack-size - at last i don't know of any way.

#5
ITSSEXYTIME

ITSSEXYTIME
  • Members
  • 1 201 messages
Seems simple enough.




#6
Karimloo

Karimloo
  • Members
  • 1 197 messages
We need to make a Ultimate Trader, selling everyone weapon and armour and general good piece in the game at 100 units per piece sold for... FREE!

#7
ITSSEXYTIME

ITSSEXYTIME
  • Members
  • 1 201 messages
Wouldn't be that difficult, hell you could just make a new area on the map and have a custom merchant there much easier than editing an existing one.



Although tbh, it seems they included that merchant in Warden's Keep >:)

#8
SuperD-710

SuperD-710
  • Members
  • 130 messages

AND04 wrote...

ok, well let me outline what we did:

basicaly you figure out the tag of the merchant-object (either by browsing through the game-files with the toolset looking for a .utm file) or by just getting all in the area with GetAllObjectsInArea of type Merchant and print the tags to your screen using a Floaty.

then use GetObjectByTag to get the spezific Merchant you want.

After that ist quite simple - CreateItemOnObject - only thing we can't do this way is setting something to an infinite stack-size - at last i don't know of any way.


Sorry to dig up an old thread, but I have questions.

How did you make sure that you only run the script once? Wouldn't the script run everytime it's loaded and therefore add items everytime you load the game?

Also the merchant would only be loaded (Object valid) while in the area right? Does that mean script is loaded at all times, but only does something when in the correct area? If that's the case, the script will have to fire everytime we get to a new area?

Lastly, what else can you do with a merchant object besides adding an item? Possible to change attributes like markup and markdown?

Thanks in advance.

#9
SuperD-710

SuperD-710
  • Members
  • 130 messages
Looking through more codes I found out you can set those merchant variables with SetLocalInt(oObject, sVarname, nValue). Perhaps that can also be used to set items to infinity? Grab the item objects and use the same funtion to set the infinity flag?

My question remain as to how to make sure it only runs once, and at the right time :|

Modifié par SuperD-710, 14 décembre 2009 - 07:02 .


#10
sillyrobot

sillyrobot
  • Members
  • 171 messages
I can think of two ways off the top of my head:



1) Use a plot flag like everything else you want the game to have a persistent memory about.



2) Add the items during an event that only runs once per area load and only adds the items if they do not exist on the merchant already. This method has the feature/bug of restocking items that have been purchased previously.

#11
SuperD-710

SuperD-710
  • Members
  • 130 messages

sillyrobot wrote...

I can think of two ways off the top of my head:

1) Use a plot flag like everything else you want the game to have a persistent memory about.

2) Add the items during an event that only runs once per area load and only adds the items if they do not exist on the merchant already. This method has the feature/bug of restocking items that have been purchased previously.


Thanks for your response, I will look into both ways.

A question on triggering script on area load: If I use a PRCSCR file, there would be no need for using events right? That script will only run while loading the particular area. Or am I misunderstanding something wrong?

#12
Stacycmc

Stacycmc
  • Members
  • 122 messages
Ok, I'm slow and completely inexperienced when it comes to this. Could you please show an example of the exact script, as I don't know how to set up the GetObjectbyTag function to get Bodhan and then give him the item.... I mean, does this need to be in a case statement or what....



I have this script below, and I'm wanting to add to it, so that the items I'm placing in my inventory I can also purchase from Bodhan (say if I want an additional copy or something)...please help to show me how I should do that....



Thank you in advance!!



// 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 oRobe = GetObjectByTag("scm_resduskrobes");

if (!IsObjectValid(oRobe))

UT_AddItemToInventory(R"scm_resduskrobes.uti",1);

object oStaff = GetObjectByTag("scm_duskstaff");

if (!IsObjectValid(oStaff))

UT_AddItemToInventory(R"scm_duskstaff.uti",1);

object oGlove = GetObjectByTag("scm_duskgloves");

if (!IsObjectValid(oGlove))

UT_AddItemToInventory(R"scm_duskgloves.uti",1);

object oBoot = GetObjectByTag("scm_duskboots");

if (!IsObjectValid(oBoot))

UT_AddItemToInventory(R"scm_duskboots.uti",1);

object oHelm = GetObjectByTag("scm_duskhelm");

if (!IsObjectValid(oHelm))

UT_AddItemToInventory(R"scm_duskhelm.uti",1);



GetObjectByTag("store_camp_bodhan.utm")

CreateItemOnObject(R"scm_duskrobes.uti",3,"scm_resduskrobes")

break;

}



default:

{

break;

}

}

}



Right before the break, where the "GetObjectByTag("store_camp_bodhan.utm")" is....I don't know what to do there....I don't know the syntax or proper way to go about doing this portion...I added those last two lines, but I do not think they are right. Could someone please just show me how to add the robe to the merchant, like what I need to type there exactly, and I can copy that for the rest of my items.



Sorry I'm just not a coder and this is the first toolset I've ever messed with...



Thanks again!!

#13
Stacycmc

Stacycmc
  • Members
  • 122 messages
Bumpity.... :)

#14
Baracuda6977

Baracuda6977
  • Members
  • 353 messages
i would also like help with this problem, although i need work on more basic concepts first apparently...

edit:
http://social.biowar...ateItemOnObject
i believe this will give you your syntax

i pulled this script out of my ass, and am afraid to implement it of fear of breaking my DA, does this look like it would work? :

edit 2:
scratch that, here is a slightly more debugged version:
#include "wrappers_h"
#include "utility_h"
#include "events_h"

void main()
{
     event ev = GetCurrentEvent();
     int nEvent = GetEventType(ev);
     Log_Events("", ev);
     switch (nEvent)
     {
        case EVENT_TYPE_MODULE_LOAD:
        {


            object oMerc = GetObjectByTag("store_ntb100cr_varathorn",1);
            int iAmtToAdd = (40 - CountItemsByTag(oMerc, "My_Item"));
            CreateItemOnObject(R"My_Item.uti", oMerc, iAmtToAdd, "My_Item", FALSE);
            break;
        }
        default:
        {
            break;
        }
     }
}

this works for adding my item to varathorns inventory

Modifié par Baracuda6977, 29 janvier 2010 - 02:57 .


#15
scott2978

scott2978
  • Members
  • 4 messages
So, what would your script say if all you wanted to do was add some items to your inventory? And, if you wanted to be able to run it from the command line like cheat codes so you could easily produce your new items in inventory for testing, etc?

#16
Baracuda6977

Baracuda6977
  • Members
  • 353 messages
for your inventory ... i think :



object oPlayer = GetHero();

iAmtToAdd...

UT_AddItemToInventory(R"my_item.uti",iAmtToAdd);

break;





not 100% sure though, for a cheat just leave those lines in the void?