Aller au contenu

Photo

Script-Modify Item Base Cost?


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

#1
AndarianTD

AndarianTD
  • Members
  • 704 messages
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!

#2
TSMDude

TSMDude
  • Members
  • 865 messages
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?

#3
AndarianTD

AndarianTD
  • Members
  • 704 messages

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. :)

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.

#4
kalbaern

kalbaern
  • Members
  • 824 messages
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.

#5
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
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.

#6
AndarianTD

AndarianTD
  • Members
  • 704 messages

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. :)

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


#7
AndarianTD

AndarianTD
  • Members
  • 704 messages
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!


#8
Dagesh

Dagesh
  • Members
  • 30 messages
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

#9
AndarianTD

AndarianTD
  • Members
  • 704 messages
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.

#10
AndarianTD

AndarianTD
  • Members
  • 704 messages
Deleted duplicate post.

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


#11
AndarianTD

AndarianTD
  • Members
  • 704 messages

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

#12
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
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.

#13
AndarianTD

AndarianTD
  • Members
  • 704 messages

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 .


#14
AndarianTD

AndarianTD
  • Members
  • 704 messages
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

#15
TSMDude

TSMDude
  • Members
  • 865 messages

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 .


#16
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages

AndarianTD wrote...

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


I believe that the client load collumn is for refferance only.  It may have been used in compiling the original code for the game as an external resource.  Now I believe it to be hard coded into the game.  I could be wrong, This is just my thoughts when i first seen the collumn.   

#17
GhostOfGod

GhostOfGod
  • Members
  • 863 messages
I found this thread. Might help.

nwn.bioware.com/forums/viewtopic.html

Pretty good info in there.

EDIT: Just checked the ItemPropDef.2da. The last 3 lines are for the Material, Quality, and Additional_Property. The cost colums are all currently set to "****". So adding a cost multiplier to the last might be what ya need. Hopefully.

Good luck.

Modifié par GhostOfGod, 07 novembre 2010 - 07:50 .


#18
Lightfoot8

Lightfoot8
  • Members
  • 2 535 messages
Also if you need the full equation for the Item cost, It can be found in section 4.4 of the PDF link below.
http://nwn.bioware.c...Item_Format.pdf

#19
AndarianTD

AndarianTD
  • Members
  • 704 messages
Lightfoot: Thanks, I've got that. I've already modded item costing extensively in the modules, including changes in the cost of various effects and a complete rewrite of the appraise system. So I know how all of that works. What I need is very specific: a method to add and remove an increase in the base cost of items, selectively and dynamically, in-game via scripting.

I tried GOG's suggestion and it's still not working. Based on all the references, I think I must be missing something very simple and obvious. I'm going to try it again from scratch on a plain module with no other modifications and see how that goes. Since this is veering a lot into CC, I'll probably try cross-posting the question to the CC forums as well.

#20
AndarianTD

AndarianTD
  • Members
  • 704 messages
OK, I tried this on a plain vanilla mod with no other cc and it works like a charm. The 2da changes needed were to itempropdef, iprp_additional, and iprp_addcost. The item property shows up on the item, whether added in toolset or via script, and increases the cost of the item as expected and desired. My current module is merging haks from both CEP 2.2 and Project Q, so it's possible that I just missed something that's in one of them that's interfering with this (although I'm surprised by that, since was putting these in my top hak). In any event the issue seems to be on my end at this point, so I'm sure I'll eventually figure out where I went wrong. Thanks again to everyone for their help!

Modifié par AndarianTD, 07 novembre 2010 - 03:40 .


#21
AndarianTD

AndarianTD
  • Members
  • 704 messages
For anyone interested, I finally tracked this down. The list of available item properties in the game is controlled overall by itemprops.2da, and I'd forgotten that I'd put a modified version of it in my module-specific hak in 2006. That was mainly to make more item properties available to offhand equippable rods and wands when I implemented that feature back in Sanctum v2.0. That modification was based on the CEP 2.0 version of the 2da available at the time and missing valid entries for anything added to NWN or CEP since then, including the new 1.69 properties. I merged my edits with the current CEP version of itemprops.2da and now it's working fine. :)

Thanks again for all the help! - Andarian

Modifié par AndarianTD, 07 novembre 2010 - 05:46 .