Author Topic: Why might GetGoldPieceValue() return varying results?  (Read 325 times)

Legacy_BCH

  • Full Member
  • ***
  • Posts: 160
  • Karma: +0/-0
Why might GetGoldPieceValue() return varying results?
« on: August 15, 2013, 04:52:37 am »


               Two different scripts, same module, same test character, same everything (that I can think of), and both scripts use GetGoldPieceValue() to evaluate an item... but one script comes out consistently higher than the other.

The latter script returns GP values that match what those items buy and sell for in a merchant with Mark Up and Mark Down both set to 100, so I'm pretty sure that latter script is correct.

Here's some examples:
Potion of Bull's Strength (3):  former script returns 210gp, latter script returns 120gp
Potion of Cure Light Wounds (5):  former script returns 58gp, latter script returns 48gp
Potion of Barkskin (6):  former script returns 160gp, latter script returns 120gp

The differences are always in multiples of 10gp, and I wonder if that's meaningful, but I don't know how.

Is this a known problem?  Any help will be appreciated.
               
               

               
            

Legacy_FunkySwerve

  • Hero Member
  • *****
  • Posts: 2325
  • Karma: +0/-0
Why might GetGoldPieceValue() return varying results?
« Reply #1 on: August 15, 2013, 07:33:46 am »


               Post the scripts. Likely issues include identified status and appraise.

Funky
               
               

               
            

Legacy_BCH

  • Full Member
  • ***
  • Posts: 160
  • Karma: +0/-0
Why might GetGoldPieceValue() return varying results?
« Reply #2 on: August 15, 2013, 08:28:22 am »


               I can post the scripts, but you may already have the relevant one (that's producing the confusing numbers).  I'm starting from the base of A Better Craft Magic and trying to make one change: calculating the cost to craft an item based on the merchant value of the item, rather than the D&D formula of caster level x spell level x fixed amount.

(I would ask the author of that system, but he and I have had significant conflict, and I don't want to seem like I'm implying he made a mistake, or that he owes an explanation, or has to support my modification of his code, etc.)

To duplicate what I'm seeing, import his system into a module, then put this line right under line 1077 in his version of x2_inc_craft :


SendMessageToPC(OBJECT_SELF, "The actual GP val of item is " + IntToString(GetGoldPieceValue(oCrafted)) );

That will give you the seemingly incorrect values (when you craft something in game, like a potion).

Then this is the item script I used to double-check the item values, which returns the correct values on the same exact items created by the scripts that return that different value above:


#include "x2_inc_switches"
void main(){
    int nEvent = GetUserDefinedItemEventNumber();
    object oUser = GetItemActivator();
    object oClicked = GetItemActivatedTarget();

    if (nEvent ==  X2_ITEM_EVENT_ACTIVATE){
        SendMessageToPC(oUser, "GP Value of item clicked is " + IntToString(GetGoldPieceValue(oClicked)) );
    }
}

If you prefer, I can actually post the complete code of his functions, but I thought it might be easier this way.
               
               

               


                     Modifié par BCH, 15 août 2013 - 07:45 .