Author Topic: SOU Treasure system - Vars on treasure?  (Read 262 times)

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
SOU Treasure system - Vars on treasure?
« on: December 17, 2010, 08:12:22 pm »


               Question, its my first time making a treasure system, or implimenting one from scratch.
Im noticing that my treasure, dispite having variables/int's stored on them in toolset, are spawning of monsters, without the int's attached.

Suggestions?
               
               

               
            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
SOU Treasure system - Vars on treasure?
« Reply #1 on: December 20, 2010, 02:16:55 am »


               wow you mean the one set by discription tab Variables? intresting you ever get any info on that im curious now LOL
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
SOU Treasure system - Vars on treasure?
« Reply #2 on: December 20, 2010, 02:24:52 am »


               Question:

Are you useing a store {object type merchant} to store the Tresure for the tresure system?



If you are there is a known bug where items placed in a store with the infinite flag set lose there local vars.
               
               

               
            

Legacy_Greyfort

  • Sr. Member
  • ****
  • Posts: 442
  • Karma: +0/-0
SOU Treasure system - Vars on treasure?
« Reply #3 on: December 20, 2010, 03:10:10 am »


               Lightfoot8 :If you are there is a known bug where items placed in a store with the infinite flag set lose there local vars.

so then the fix to that would be to limit the infonate in merchant? am I reading that right.



I tested some things and...If item placed in area or created in area variables remain.  I have yet to try to create them on a creature that dies, or in a chest.  I had never ran into that issue before the merchant bug is good to know.
               
               

               
            

Legacy_Lightfoot8

  • Hero Member
  • *****
  • Posts: 4797
  • Karma: +0/-0
SOU Treasure system - Vars on treasure?
« Reply #4 on: December 20, 2010, 06:19:28 am »


               The Store bug is the only one I know of where items lose there vars.  



To trouble shoot the problem any farther then that we will need to know more about his system.



               
               

               
            

Legacy_kalbaern

  • Hero Member
  • *****
  • Posts: 1531
  • Karma: +0/-0
SOU Treasure system - Vars on treasure?
« Reply #5 on: December 20, 2010, 04:16:11 pm »


               Are you using a variation of the Bioware Treasure system wherein you place the items into a chest and when a creature either spawns in or dies that chest is being used to find and create treasure on it? If so, this is similar to the merchants issue where variables are lost when an item is set to infinate. In both cases, the original item is copied and this does not transfer the variables to the new version. So with merchants, you need to add multiple copies and put up with a finite inventory (IE they can sell out of the items) or use a conversation to buy the items with variables instead ("Yes ... I'll take that +2 longsword" and the action taken script would deduct the coinage and create it from the pallette). You've two option for a loot system. Adopt a variant of the "unique" treasure chests used and treat them as a finite store as when something is pulled from those, its not copied, its transfered the same as the merchants with a limited stock. You could also just create treasure tables and create the items in the creature's inventories from a script. Hope this made sense.
               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
SOU Treasure system - Vars on treasure?
« Reply #6 on: December 21, 2010, 03:47:45 pm »


               The version I am using is the one where you spawn a

Low_Module Treasure chest etc, and fill it with treasure, and then the creatures spawn, and they have the treasure.



From what I have seen of the bioware scripts in the inc file,

the Treasure UNIQUE chest, uses  CopyItem  and uses the flag for copyvars = true.



However, the other treasure chests appear to be copied to the creature via

CopyObject or CreateItem (cant rememeber which)

Which does not copy the vars to the item being created.





The issue is more of an annoyance, than a hinderence. I was planning on creating my own custom dynamic loot system anyway, but the problem just arose that this issue prevented me from having specific variables which were important on items.

eg - Variables that made the players immune to Acid Rain etc

   -  Variables that reduced cooldown times of skills by % etc





Note - The Function that creates the treasure, I think its CopyObject or CreateItem, it accepts a location variable.... is this important?



If it is not important, I may be able to swap the function with the CopyItem, which has the flag for 'copyvars'.
               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
SOU Treasure system - Vars on treasure?
« Reply #7 on: December 21, 2010, 08:57:40 pm »


               Best I can tell, this is the function causing the pain

// Get the specified item out of the given base container's inventory
object CTG_GetTreasureItem(object oBaseCont, int nItemNum)
{
    if (!GetIsObjectValid(oBaseCont)) {return OBJECT_INVALID;}

    // initialize the container -- this will automatically
    // only happen once.
    CTG_InitContainer(oBaseCont);

    // Refs to the items are stored on the container itself
    string sVar = sTreasureItemVarname + IntToString(nItemNum);
    return GetLocalObject(oBaseCont, sVar);
}

               
               

               
            

Baaleos

  • Administrator
  • Hero Member
  • *****
  • Posts: 1916
  • Karma: +0/-0
SOU Treasure system - Vars on treasure?
« Reply #8 on: December 21, 2010, 10:15:29 pm »


               Note - I just resolved this.



The Following function I changed CopyObject, to CopyItem.



CTG_CreateSpecificBaseTypeTreasure(int nTreasureType,

                                       object oAdventurer,

                                       object oCont,

                                       int nBaseType1=BASE_ITEM_INVALID,

                                       int nBaseType2=BASE_ITEM_INVALID,

                                       int nBaseType3=BASE_ITEM_INVALID);





But also, I had CRP_s hak being used by this module, so when I compiled, this script did not get compiled fresh, because one of its dependancies came from the hak.



To resolve, I removed the script from crp, and saved fresh so it became a module resource, and then compiled