Author Topic: Just a little knowhow I want to share  (Read 339 times)

Legacy_Shadooow

  • Hero Member
  • *****
  • Posts: 7698
  • Karma: +0/-0
Just a little knowhow I want to share
« on: August 18, 2015, 01:53:19 am »


               

So, we always had issue on Arkhalia PW with loot system. The loot system Ive made allows to dynamically change content of the loot in each area using a 3 template chests for each real chest in area. The problem we had was that if DM added into chest 2 items of the same type that can stack, but with intent to simply increase a drop chance for that item, after restart when these persistent loot chests are loaded these items stacked into heap of 2 pieces and was dropping in loot as 2pieces.


 


Now I figured out a solution for this.


 


SetPlotFlag allows to set other values than 1 while it still behaves as plot.


 


As you know items with same tag a baseitem will stack with each almost everytime, they can have different name, different resref, different image, even different itemproperties (as long as the number of itemproperties match), they can be stolen or even undroppable but still stack with non stolen droppable version and merge into one stack that has previous properties. This is a huge issue, but the remark on the SetPlotFlag allows to avoid this.


 


So, what I did is this.


When loading items from database into chest, after each item is created I do:


SetLocalInt(oItem,"OriginalPlotValue",GetPlotFlag(oItem));


SetPlotFlag(oItem,2);


 


after all items are loaded i loop through all items and restore original plot value like this:


 


SetPlotFlag(oItem,GetLocalInt(oItem,"OriginalPlotValue));


DeleteLocalInt(oItem,"OriginalPlotValue");


 


This allows me to load items from database and even if they are of the same type they wont stack.


 


It also helped me to fix issues in player store I made recently where stackable and plot items that was sold tend to stack with same items in players inventory which resulted in losing all variables and failed miserably. So now Im setting all items to be plot = 2 instead and all issues are solved.


 


 


Both stolen and cursed flags can be also set with higher values via scripting, but I havent really tested if they behave as they should and I cant see many way how to take any use of this information.


 


Feel free to add this information into lexicon, I would myself but my grammar isnt good enough and someone would have to correct me anyway '<img'>