Author Topic: Script-Modify Item Base Cost?  (Read 1040 times)

Legacy_AndarianTD

  • Hero Member
  • *****
  • Posts: 725
  • Karma: +0/-0
Script-Modify Item Base Cost?
« on: November 02, 2010, 11:11:40 am »


               Does anyone know if there's a way to modify the base cost of an item via script? I can do this statically to some extent on the blueprint using the 'additional cost' field or by modifying the cost 2DAs, but I'd like to be able to do this dynamically in-game.

Thanks in advance for any feedback!
               
               

               
            

Legacy_TSMDude

  • Hero Member
  • *****
  • Posts: 1515
  • Karma: +0/-0
Script-Modify Item Base Cost?
« Reply #1 on: November 02, 2010, 12:24:54 pm »


               There was a script at one time that set the base price for every item by a script but I cannot seem to locate it. I am off to work and will look again but if I remember they basically had it loop through and set the base items to a pre price.....



It seemed unduly heavy to me though.



Does DMFI tools not have a set item cost function?
               
               

               
            

Legacy_AndarianTD

  • Hero Member
  • *****
  • Posts: 725
  • Karma: +0/-0
Script-Modify Item Base Cost?
« Reply #2 on: November 02, 2010, 01:46:33 pm »


               

TSMDude wrote...

There was a script at one time that set the base price for every item by a script but I cannot seem to locate it. I am off to work and will look again but if I remember they basically had it loop through and set the base items to a pre price... It seemed unduly heavy to me though.


Thanks for offering to check! For the record all I really need is an API function or an algorithm that will take an item object reference and alter its base price. I can handle writing any required accessory code with no trouble. '<img'>

Does DMFI tools not have a set item cost function?


I don't use the DMFI tools, so I don't know. This is for an SP module.
               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
Script-Modify Item Base Cost?
« Reply #3 on: November 02, 2010, 03:16:03 pm »


               You can modify the base item 2da and include it as a hak for your module. It'd be a small hak as 2das are essentially text files.
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Script-Modify Item Base Cost?
« Reply #4 on: November 02, 2010, 04:29:17 pm »


               Kind of on the same note as kalbaern suggests. If you want to do something like this via scripting, You could use the item properties such as material and quality. But you need to alter the iprp_qualcost.2da to have specific cost values for each type. Then in game add those item properties and whatever cost amount you put in your 2da will be added.

It's not very precise but it's an option.
               
               

               
            

Legacy_AndarianTD

  • Hero Member
  • *****
  • Posts: 725
  • Karma: +0/-0
Script-Modify Item Base Cost?
« Reply #5 on: November 02, 2010, 04:59:52 pm »


               

kalbaern wrote...

You can modify the base item 2da and include it as a hak for your module. It'd be a small hak as 2das are essentially text files.

I've already heavily customized baseitems and many of the cost-related 2DAs. But that won't accomplish this particular need, which is to be able to dynamically alter the cost, not just statically.

GhostOfGod wrote...

If you want to do something like this via scripting, You could use the item properties such as material and quality. But you need to alter the iprp_qualcost.2da to have specific cost values for each type. Then in game add those item properties and whatever cost amount you put in your 2da will be added. It's not very precise but it's an option.

Now that is a very clever idea that just might work for what I have in mind! Thanks -- I'll take a look at trying that out. '<img'>
               
               

               


                     Modifié par AndarianTD, 02 novembre 2010 - 05:03 .
                     
                  


            

Legacy_AndarianTD

  • Hero Member
  • *****
  • Posts: 725
  • Karma: +0/-0
Script-Modify Item Base Cost?
« Reply #6 on: November 02, 2010, 05:37:39 pm »


               GOG: Yep, that looks like that'll do it quite nicely. From the description here, it looks like all that's needed is to add entries to iprp_addcost.2DA, iprp_additional.2DA, and my custom tlk. Then using ItemPropertyAdditional will add the property associated with the extra cost. Thanks!


               
               

               
            

Legacy_Dagesh

  • Jr. Member
  • **
  • Posts: 55
  • Karma: +0/-0
Script-Modify Item Base Cost?
« Reply #7 on: November 03, 2010, 01:36:13 am »


               If you use NWNX you can set the price as needed.



For windows:

http://nwvault.ign.c....Detail&id=1447



For Linux:

http://data.virusman...tions-1.9.0.rar
               
               

               
            

Legacy_AndarianTD

  • Hero Member
  • *****
  • Posts: 725
  • Karma: +0/-0
Script-Modify Item Base Cost?
« Reply #8 on: November 03, 2010, 12:01:17 pm »


               Dagesh: thanks. I'll keep that in mind, but I prefer not to use executable extensions to NWN. Using ItemPropertyAdditional looks like it'll be an easier and more convenient solution.
               
               

               
            

Legacy_AndarianTD

  • Hero Member
  • *****
  • Posts: 725
  • Karma: +0/-0
Script-Modify Item Base Cost?
« Reply #9 on: November 03, 2010, 12:01:54 pm »


               Deleted duplicate post.
               
               

               


                     Modifié par AndarianTD, 03 novembre 2010 - 12:02 .
                     
                  


            

Legacy_AndarianTD

  • Hero Member
  • *****
  • Posts: 725
  • Karma: +0/-0
Script-Modify Item Base Cost?
« Reply #10 on: November 06, 2010, 05:00:23 pm »


               

AndarianTD wrote...

GOG: Yep, that looks like that'll do it quite nicely. From the description here, it looks like all that's needed is to add entries to iprp_addcost.2DA, iprp_additional.2DA, and my custom tlk. Then using ItemPropertyAdditional will add the property associated with the extra cost. Thanks!


Hmm... well, this doesn't seem to be working as expected. Here's what I'm doing:

1. Modifying iprp_addcost.2da as follows:

[nwscript]2DA V2.0

        Name        Label           Cost
0       111775      Unknown         0
1       111874      Cursed          0
2       111775      Testprop        5.0[/nwscript]

2. Modifying iprp_additional.2da as follows:

[nwscript]2DA V2.0

        Label                       Name
0       Unknown                     111775
1       Cursed                      111874
2       Testprop                    111775[/nwscript]

3. Running this script (as a unique power) from one item on another:

[nwscript]
#include "x2_inc_switches"
#include "nw_i0_spells"
void main()
{
  int nEvent = GetUserDefinedItemEventNumber();
  object oPC;
  object oItem;

  //SendMessageToPC(GetFirstPC(),IntToString(nEvent));

  // * This code runs when the item has the OnHitCastSpell: Unique power property
  // * and it hits a target(weapon) or is being hit (armor)
  // * Note that this event fires for non PC creatures as well.
  if (nEvent == X2_ITEM_EVENT_ONHITCAST)
  {
    // The item casting triggering this spellscript
    oItem  =  GetSpellCastItem();
    object oSpellOrigin = OBJECT_SELF ;
    object oSpellTarget = GetSpellTargetObject();
    oPC = OBJECT_SELF;
  }
  // * This code runs when the Unique Power property of the item is used
  // * Note that this event fires PCs only
  else if (nEvent ==  X2_ITEM_EVENT_ACTIVATE)
  {
    oPC   = GetItemActivator();
    oItem = GetItemActivated();
    object oPT = GetItemActivatedTarget();
    if (oPT != OBJECT_INVALID)
    {
      SendMessageToPC(GetFirstPC(),"Adding Additional Property to "+GetName(oPT));
      AddItemProperty(DURATION_TYPE_PERMANENT,ItemPropertyAdditional(2),oPT);
     }
  }
}
[/nwscript]

Both 2das are in my top (patch) hak. The script is running and displaying the correct message, but nothing seems to be happening to the item it is used on -- either with regard to price (tested in a store) or visible properties on the item. Has anyone confirmed that this does in fact work, and if so know what I may be missing? For example, do I also need to add an entry to itemprops.2da?

Thanks in advance for any feedback -- Andarian
               
               

               
            

Legacy_GhostOfGod

  • Hero Member
  • *****
  • Posts: 1490
  • Karma: +0/-0
Script-Modify Item Base Cost?
« Reply #11 on: November 06, 2010, 05:17:23 pm »


               From what little info I gathered you should modify the iprp_qualcost.2da. I've never actually worked with this. But take a loot there and see if that helps.
               
               

               
            

Legacy_AndarianTD

  • Hero Member
  • *****
  • Posts: 725
  • Karma: +0/-0
Script-Modify Item Base Cost?
« Reply #12 on: November 06, 2010, 07:17:53 pm »


               

GhostOfGod wrote...

From what little info I gathered you should modify the iprp_qualcost.2da. I've never actually worked with this. But take a loot there and see if that helps.


Hmm... That's for use with ItemPropertyQuality, though. ItemPropertyAdditional references iprp_addcost.2da.

However, in double-checking this I think I've found the problem. The links above mention a need to also add entries to iprp_costtable.2da so that the (presumably internal) calls to GetItemPropertyCostTable work correctly. I'm going to add those and see how it goes.
               
               

               


                     Modifié par AndarianTD, 06 novembre 2010 - 07:19 .
                     
                  


            

Legacy_AndarianTD

  • Hero Member
  • *****
  • Posts: 725
  • Karma: +0/-0
Script-Modify Item Base Cost?
« Reply #13 on: November 06, 2010, 10:42:49 pm »


               Hmm... The entries are already there in the file, but there's a "ClientLoad" column with a zero in it. Does anyone know what that's for? Presumably it somehow controls whether the file is loaded on the client or on the server for MP play -- can anyone confirm or explain that?



Thanks -- Andarian
               
               

               
            

Legacy_TSMDude

  • Hero Member
  • *****
  • Posts: 1515
  • Karma: +0/-0
Script-Modify Item Base Cost?
« Reply #14 on: November 06, 2010, 11:25:44 pm »


               

Dagesh wrote...

If you use NWNX you can set the price as needed.

For windows:
http://nwvault.ign.c....Detail&id=1447
 


My bad as this was what I remembered reading...sorry about that...
               
               

               


                     Modifié par TSMDude, 06 novembre 2010 - 11:26 .