Games Support Forums BioWare Info My Account Login Community Sign Up Store
Neverwinter Nights 2 Forums

NWN2: Builders - NWN2 Scripting

New Topic    Post Reply


    Add this To My Topics

   Go To Bottom

Author GetGoldPieceValue() Does it work correctly?
cdaulepp
Game Owner
Profile: cdauleppNWN
NWN: SoU
NWN: HotU
NWN 2
NWN 2: MotB


Joined: 10 Aug 2003
Posted: Monday, 07 April 2008 10:48PM
I am dynamically creating a "lens of detection" item on a monster. When I use the function GetGoldPieceValue to check the item's value, it is returning "1" instead of the 12K gold piece value that the item actually has.

Anyone have any idea why this is? Does it have anything to do with the item being dynamically created? Does it have anything to do with the lens of detection being a miscellaneous small category of item? I can't figure out why, but when I get the value it definitely returns 1 GP. The function GetGoldPieceValue seems to be working properly. Other item values are returned properly. But it seems that miscellaneous musical instruments seem to have problems. I have no clue why.

cdaulepp
_________________
Download my random loot generator:

VERSION 2.0 BETA Click Here
  Profile: cdaulepp   Send Message To: cdaulepp
loudent2
Game Owner
Profile: loudent2NWN
NWN: SoU
SW: KotOR Xbox
Jade Empire
NWN 2
NWN 2: MotB
NWN 2: SoZ


Joined: 11 Feb 2003
Posted: Monday, 07 April 2008 11:07PM
I suppose the first question is whether or not the item is identified and if that makes a difference.
_________________
Lost Dungeons of Adventure - NWN2 Action PW
  Profile: loudent2   Send Message To: loudent2
cdaulepp
Game Owner
Profile: cdauleppNWN
NWN: SoU
NWN: HotU
NWN 2
NWN 2: MotB


Joined: 10 Aug 2003
Posted: Tuesday, 08 April 2008 01:29AM
Quote: Posted 04/07/08 23:07 (GMT) by loudent2

I suppose the first question is whether or not the item is identified and if that makes a difference.

Thank you. You were exactly right and I appreciate the diplomatic way you handled that. I totally wasn't thinking about whether the item is identified or not.

That solved a logical error in my programming I have missed for the better part of a year.

Thanks,

cdaulepp
_________________
Download my random loot generator:

VERSION 2.0 BETA Click Here
  Profile: cdaulepp   Send Message To: cdaulepp
cdaulepp
Game Owner
Profile: cdauleppNWN
NWN: SoU
NWN: HotU
NWN 2
NWN 2: MotB


Joined: 10 Aug 2003
Posted: Tuesday, 08 April 2008 04:53PM
Here is something that will help (this post is off topic a little)

In the file "fw_random_loot" you will want to add some code to the function "FW_CreateLootOnObject". The part you want to add is near the bottom of that function.

I had DestroyObject in the "if" clause, but I needed to have the same in the "else" clause and it is not currently there. In the "else" clause I added the line: DestroyObject (strStruct.oItem); to fix the problem.

This is necessary to make sure the overly expensive item is destroyed before creating gold on the spawning monster. Another piece of code is required to make the correction complete. Explained below.

NWScript:

View Post/Code in separate window



After you have added the DestroyObject line of code above you will need to open the script "fw_inc_item_value_restrictions" and navigate to the function implementation of the function "FW_IsItemRolledTooExpensive". That is the very last function in that script file. You will need to add a line that sets the item to identified, as shown below. You must place the line identifying the object before you get the gold piece value, so order is important.

NWScript:

View Post/Code in separate window



This will fix the problem of miscellaneous (or any other item for that matter) of appearing on a monster that is over the GP limit you set.

P.S. Don't worry, the main program currently sets all spawning items to UN-identified right before exiting. So identifying the item here won't leave it identified. It gets changed back to unidentified later in another section of the code.

For anyone else reading this, you are probably wondering what I am talking about. Don't worry about it. I am posting a quickfix for a friend so he/she can do a hotfix until I release the next version of my random loot generator.

cdaulepp
_________________
Download my random loot generator:

VERSION 2.0 BETA Click Here

Edited By cdaulepp on 04/08/08 16:57

  Profile: cdaulepp   Send Message To: cdaulepp
Wyvern76
Game Owner
Profile: Wyvern76NWN
NWN: SoU
NWN: HotU
NWN 2
NWN 2: MotB
NWN 2: SoZ
Mass Effect PC


Joined: 10 Aug 2002
Posted: Tuesday, 08 April 2008 07:55PM
Thanks a bunch! I will try to paste this in tonight or tomorrow. Damn work......wish I had time right now.

The Staff was really flipping out about the 20k items being dropped from Kobolds in our low wealth PW. Thanks again for the quick solution.
_________________
Staff: Obsidian Shore a welcoming RP persistant World
Click Here
  Profile: Wyvern76   Send Message To: Wyvern76
Vendalus
Game Owner
Profile: VendalusNWN
NWN: SoU
NWN: HotU
NWN 2
NWN 2: MotB


Joined: 30 Jun 2002
Posted: Wednesday, 09 April 2008 01:26PM
cdaulepp, can you post your final code for getting values? I'm curious to see the logic you used to handle the identification issue.

Thanks!
_________________
Vendalus' Corner
Wendersnaven.com
Vault Submissions
  Profile: Vendalus   Send Message To: Vendalus
cdaulepp
Game Owner
Profile: cdauleppNWN
NWN: SoU
NWN: HotU
NWN 2
NWN 2: MotB


Joined: 10 Aug 2003
Posted: Wednesday, 09 April 2008 05:39PM
Quote: Posted 04/09/08 13:26 (GMT) by Vendalus

cdaulepp, can you post your final code for getting values? I'm curious to see the logic you used to handle the identification issue.

Thanks!

I guess so. Here is what I have now. But this may change as I continue updating the random loot generator. The first code is from the script file "fw_random_loot" and the posted function picks a loot category for the treasure. Then a gold piece value check is performed to make sure the item is not too expensive. If it is too expensive, I reroll (up to 10 times). If, after 10 rolls, the item chosen is still too expensive, I default back to creating gold on the monster instead of an item.

NWScript:

View Post/Code in separate window



The next posted section of code is the function "FW_IsItemRolledTooExpensive" in the script file "fw_inc_item_value_restrictions." This function does a simple check to see if the item is too high value or not. I identify the item first because unidentified items return a value = 1GP, even if they are really worth a lot more than that. (Later on in my system, I change the item back to unidentified)

NWScript:

View Post/Code in separate window



Basically, to fix the error of unidentified items showing up as loot I had to add two lines of code. In the first section above, I added a "DestroyObject" line of code to the "else" statment towards the very end of that section of code. The second line I added was the "SetIdentified" line in the second section of code I posted. That takes care of the problems.

Of course, this code relies on a bunch of datatypes and variables that are defined elsewhere throughout my system, but the basic logic is there so you can examine it.

cdaulepp
_________________
Download my random loot generator:

VERSION 2.0 BETA Click Here
  Profile: cdaulepp   Send Message To: cdaulepp
cdaulepp
Game Owner
Profile: cdauleppNWN
NWN: SoU
NWN: HotU
NWN 2
NWN 2: MotB


Joined: 10 Aug 2003
Posted: Wednesday, 09 April 2008 05:42PM
The actual final code may look different for the version 2.0 update. I don't anticipate finishing that until after my finals for second semester of law school are done.

cdaulepp
_________________
Download my random loot generator:

VERSION 2.0 BETA Click Here
  Profile: cdaulepp   Send Message To: cdaulepp
CID-78
Game Owner
Profile: CID-78NWN
NWN: SoU
NWN: HotU
SW: KotOR PC
Jade Empire:SE
NWN 2
NWN 2: MotB
NWN 2: SoZ


Joined: 01 Oct 2002
From: Landskrona, Sweden
Posted: Thursday, 10 April 2008 10:35AM
why don't you calculate the itemcost before applying the on the fly enchantments. and the basecost can be excluded from the random roll, if they cost more then max amount.

that would be how i would do it, haven't bothered to check your code. but rerolling is a waste of resources.
_________________
Community Representant - NWN2 Toolset Forum
  Profile: CID-78   Send Message To: CID-78
Wyvern76
Game Owner
Profile: Wyvern76NWN
NWN: SoU
NWN: HotU
NWN 2
NWN 2: MotB
NWN 2: SoZ
Mass Effect PC


Joined: 10 Aug 2002
Posted: Sunday, 20 April 2008 07:57PM
Finally found time to put this fix in. Thank you again! And I look forward to the next version of your loot generator. Keep up the good work!
_________________
Staff: Obsidian Shore a welcoming RP persistant World
Click Here
  Profile: Wyvern76   Send Message To: Wyvern76

New Topic    Post Reply

What do these icons mean?
Where can I learn how to use the forums?

Jump To:

Search Forums | Forums FAQ | Forum Archives

 

 

  Visit the Official Site | Technical Support
Neverwinter Nights 2 Official Support
Hide/Show

English
Deutsch
Français
Español
Italiano

Hide/Show

6,251,297 Users
170 Online
11 Logged In

9,046,484 posts in forums

Newest Forum Topics:
1. These forums are now closed (NWN 1: Scripting)

2. These forums are now closed (NWN2: Guilds and Registry)

3. These forums are now closed (BioWare News Discussion)

4. Can you level items? (NWN 1: Scripting)

5. Thank you! (NWN 1: Scripting)


Current time is: (set time)
Fri, 03 September 2010 12:57AM