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