Author Topic: Magus Loot System  (Read 718 times)

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Magus Loot System
« on: March 02, 2016, 06:12:04 am »


               

Version 1.1


http://neverwinterva...gus-loot-system


 


magus_loot_screen.png


 


It makes use of merchants to enable builders to manage loot lists in the tool set. Local Variables on the lootable object enable you to customize the behavior. Axe's Killer Loot Generation system was an inspiration, but I wanted to avoid his use of 2DAs so that a builder could tweak the loot lists only using the toolset.


 


A couple features that are relatively novel:


- you can specify a maximum number of loot items to spawn


- configure minimum and maximum values for all loot (value is total GP value of all loot) spawned in a container


- minimum and maximum values for loot can optionally scale with PC level


- multiple sources for random loot can be combined in each lootable container (gem merchant + weapon merchant + potion merchant + pile of coins etc...). Builder identifies which sources to use at each loot drop.


- each source of loot has a percentage chance to spawn at a drop. builder configures this on the lootable object


 


 


Downside:


I've noticed that when spawning lots of loot (5 or more items) from large lists (longer than 600 items) the script can time out from too many instructions. I haven't found the actual upper limit because after making some improvements to the code I have not noticed this problem anymore in the demo module, but consider yourself warned. If you plan on stuffing each of your loot merchants with many 100's of items and using them all at once, you could run into TMI problems.


 


TMI issues solved in v1.1



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Magus Loot System
« Reply #1 on: March 02, 2016, 07:09:00 am »


               

 


I've noticed that when spawning lots of loot (5 or more items) from large lists (longer than 600 items) the script can time out from too many instructions. I haven't found the actual upper limit because after making some improvements to the code I have not noticed this problem anymore in the demo module, but consider yourself warned. If you plan on stuffing each of your loot merchants with many 100's of items and using them all at once, you could run into TMI problems.



To fix it, you need to create a "cache". First time an attempt from chest is attempted you need to sort the items inside into pseudoarrays or pseudolist (array is better here as its static and wont change) on the store


 


JUNK_1 int X


JUNK_2 int ....


 


WEAPON_1 int X


 


where value is current position in the loop, then to spawn item, you just get random value from pseudoarray for given category and then just loop all items till counter matches the value from array.


 


Or easier solution though not so efficient is to delay each loot generation by 0.1sec



               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Magus Loot System
« Reply #2 on: March 02, 2016, 07:31:06 am »


               

Shadow... on the merchants there are pseudo arrays. SoU did this so I just took advantage of it.


 


On the containers I maintain a dynamic list (single string with delimiters) which combines all of the valid items from all of the merchants which are combined in the loot. I think this later part is where I need to optimize because this list can get quite long and I have to step through it to find the index of the item in the store.


 


If I changed the functionality, I could generate a number of shorter lists which would reduce the amount of stepping the code would have to do.


 


I need to keep the lists dynamic however so that I can remove items when they are no longer valid (too expensive for loot value, or total spawned from list would exceed the percentage). I also remove categories of items when no more can be taken from that category.


 


If you take a look at the Demo module and script _inc_loot, you can see what I am doing.



               
               

               
            

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Magus Loot System
« Reply #3 on: March 02, 2016, 07:45:11 am »


               

I dont have toolset available atm, so I only guessed from the tmi issue. If you are doing this already and stll get tmi, than thats weird. After I will see the script I might have a better answer.



               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Magus Loot System
« Reply #4 on: March 02, 2016, 08:31:54 am »


               

I tested my updated version and found that when I have more than 1000 items in the list it runs into TMI problems. Under that number and it only rarely runs into TMI problems.


 


So I think for normal use this is fine. It is however clearly possible to overwhelm it if you try to spawn from large lists.


 


If we run into trouble with it on Hill's Edge I'll work on optimizing it. This will require changing the functionality with regards to how percentages function, but I think I can maintain the spirit of this thing.



               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Magus Loot System
« Reply #5 on: March 04, 2016, 03:47:36 am »


               

I could use some help with suggested loot drop values per level.

First, a key component of this system is that the total value of all the loot in a single drop does not exceed the maximum value. So max is not per item, but per loot drop. A single loot drop can be a combined treasure of coins, weapons, gems, art, or whatever else you decide. Mix and match as you want from multiple stores. However the combined value won't exceed the max for the drop.

 

Ok that said, there is a feature where the min and max values for the loot drop can scale with level. The values for that are below. I pulled them from the 3rd ed DM guide, but rather than suggested values, these are the ceiling for treasure. The average is towards the middle of min and max (varies depending on value of items in loot stores). I don't think these work for NWN, but I am not sure what does. I appreciate any scaling advice people can offer. And yes, I think I am going to pull these out to module variables so they are more easily configurable.

level 1:

Min = 10

Max = 300
level 2:

Min = 20

Max = 600
level 3:

Min = 30

Max = 900
level 4:

Min = 50

Max = 1200
level 5:

Min = 70

Max = 1600
level 6:

Min = 90

Max = 2000
level 7:

Min = 110

Max = 2600
level 8:

Min = 150

Max = 3400
level 9:

Min = 200

Max = 4500
level 10:

Min = 250

Max = 5800
level 11:

Min = 300

Max = 7500
level 12:

Min = 350

Max = 9800
level 13:

Min = 400

Max = 13000
level 14:

Min = 450

Max = 17000
level 15:

Min = 500

Max = 22000
level 16:

Min = 600

Max = 28000
level 17:

Min = 800

Max = 36000
level 18:

Min = 1000

Max = 47000
level 19:

Min = 1200

Max = 61000
level 20:

Min = 1400

Max = 80000



               
               

               
            

Legacy_henesua

  • Hero Member
  • *****
  • Posts: 6519
  • Karma: +0/-0
Magus Loot System
« Reply #6 on: March 07, 2016, 12:48:00 am »


               

I updated this to version 1.1.


 


The TMI issue has been solved, and percentage chance for each type of loot to spawn is now working properly.