Aller au contenu

Photo

Random treasure script problem


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

#1
Grani

Grani
  • Members
  • 559 messages
Hello all,
I've been using this script: http://nwn.wikia.com...Random_treasure
to generate random treasure in various chests in my module all this time. Everything worked perfectly fine.

However, when I tried doing another chest today and, out of my habit, tested it, I was surprised to find out that only items from the "trash" chest spawned and none from the "source chest", which contained the main items that could be found.

After testing it a bit more, I found out that actually items from source chest DO spawn but really rarely, which I don't understand, given that at least one item from the source chest always used to spawn when I used this system. I've also tested it on other chests that had already been placed before in the module and it's the same thing - sometimes the item will spawn, but pretty rarely, most often only items from trash chest will appear.

Could anyone tell me what's going on? I didn't change anything in the script. I tried building the module again, but it doesn't make a difference. No errors occur, either, when I build it.

Help is appreciated. :)

#2
_Guile

_Guile
  • Members
  • 685 messages
Can't help without a script, sorry :/

#3
Grani

Grani
  • Members
  • 559 messages
But I've provided the link to this script at the beginning of the post...

http://nwn.wikia.com...Random_treasure

#4
WhiZard

WhiZard
  • Members
  • 1 204 messages
This line:
if(d3() > 1 ) MakeTreasure(sSourceChest,oThisChest);

states that treasure from the source chest has a 2/3 chance of appearing in a chest. Junk loot appears in every chest with a 1/2 chance of two junk items appearing. If your source chest contains things you might regard as junk, you could get rid of them or move them to the junk chest. To ensure that the source chest always is used, simply remove the "if(d3() > 1)" condition from the above line.

EDIT: had accidentally typed 1/3 instead of 2/3

Modifié par WhiZard, 12 juin 2013 - 02:10 .


#5
meaglyn

meaglyn
  • Members
  • 817 messages
That script will only spawn something from the source chest 2/3 of the time. It won't do it all the time. So I think you may be misremembering the results from before. Or you were getting consistently lucky before.

Maybe you are getting unlucky now. If I recall, the pseudo-random number generation is based the state of the area. Try changing something in the area or doing some things which use random numbers before you open the chest to get different pseudo-randomness.

#6
WhiZard

WhiZard
  • Members
  • 1 204 messages

meaglyn wrote...

That script will only spawn something from the source chest 2/3 of the time. It won't do it all the time. So I think you may be misremembering the results from before. Or you were getting consistently lucky before.

Maybe you are getting unlucky now. If I recall, the pseudo-random number generation is based the state of the area. Try changing something in the area or doing some things which use random numbers before you open the chest to get different pseudo-randomness.


The state of the area no longer matters.  A long time ago, it used to matter and one could anticipate the initial and latter calculations by area properties, but this was changed in an early patch.

#7
Grani

Grani
  • Members
  • 559 messages
Thanks a lot! :)
It seems I really was just lucky before, good to know nothing was broken somehow. :D

#8
_Guile

_Guile
  • Members
  • 685 messages
That's a rather poorly written script, as it will loop through all of the items in the chest two times per use, which could cause some issues if it's ran frequently by multiple PCs, definitely...

I might suggest on first use run the inventory count of oChest, set the total count in a variable on the module, telling the counting function that it's been stored, so it doesn't have to loop again, it just pulls the variable from the module (at run time)...

Anyway, glad to see you are happy with the script, even though it's a 50/50 shot on one pull and a 2/3 shot on the other pull, seems like it's not really going to load much very often... The junk pull should be 2/3 and the other pull should be catered to a specific %, e.g. 20% chance etc...

Also, it's a single shot chest, it will only ever spawn treasure one time, which is bad, so it should check two things, how long ago it was opened and who opened it, that way it reload the chest to a new user every X minutes apart, though a user may only spawn the treasure one time / module restart...

Anyway, if you are looking for a system with far more customization, then you can check out my 1.69 treasure system in the link below...

nwvault.ign.com/View.php

Modifié par _Guile, 12 juin 2013 - 05:18 .


#9
Grani

Grani
  • Members
  • 559 messages

_Guile wrote...

That's a rather poorly written script, as it will loop through all of the items in the chest two times per use, which could cause some issues if it's ran frequently by multiple PCs, definitely...

I might suggest on first use run the inventory count of oChest, set the total count in a variable on the module, telling the counting function that it's been stored, so it doesn't have to loop again, it just pulls the variable from the module (at run time)...

Anyway, glad to see you are happy with the script, even though it's a 50/50 shot on one pull and a 2/3 shot on the other pull, seems like it's not really going to load much very often... The junk pull should be 2/3 and the other pull should be catered to a specific %, e.g. 20% chance etc...

Also, it's a single shot chest, it will only ever spawn treasure one time, which is bad, so it should check two things, how long ago it was opened and who opened it, that way it reload the chest to a new user every X minutes apart, though a user may only spawn the treasure one time / module restart...

Anyway, if you are looking for a system with far more customization, then you can check out my 1.69 treasure system in the link below...

nwvault.ign.com/View.php


Thanks for the suggestion! Still, my module is not a PW, so there's no need to respawn items in the chest after X minutes and the script won't be run that often, either. I've already made too many chests to change the treasure system now, but I'll keep yours in mind if I ever start a new module. :)
I'll just make it so that an item from source chest is spawned always instead of only 2/3 of the time.

Modifié par Grani, 12 juin 2013 - 05:23 .