Skip to content

x0_o2_anyuniq Error

I'm trying to use the SOU loot system in the module that I've been working on and have ran into an issue use the Unique item option.

I've created an area and a module-level treasure container using the items from the toolset palette to ensure proper naming and populated those changes. Mod level chests are in an area named _base to avoid player interaction and the area level chest is located in an inaccessible location of the area. Both chests have been populated using different items to test what chest items are being pulled from.

After creating a lootable chest, I've assigned it the x0_o2_anyuniq script on both in OnDeath and OnOpen. However, the chests never populate. After some testing I've narrowed down the issue to just the UNIQ portion of the loot system as the low, med, and high portions of the system still work. I found one obscure reference in my searching that the patch in Dec 2019 may have broken x0_o2_anyuniq but have been unable to find anything other than that one reference.

1) Is this a known issue?
2) If this is a known issue is there a workaround or fix someone could point me to?
3) If this system is known broken with no workaround, does anyone have any suggestions on a loot system similar that would be a good replacement?

Comments

  • ForSeriousForSerious Member Posts: 446
    I have done things to that script a lot. When I get some time I can paste what I got working.
  • ForSeriousForSerious Member Posts: 446
    Humm. I decided to create a new module and check out what you said about some 2019 update... Not seeing it.

    So the portion that handles Unique loot is in x0_i0_treasure
    This is lines 834 to 864:
    // Special case: unique treasure items
        if (nTreasureType == TREASURE_TYPE_UNIQUE) {
            // only give one item and only give it once
            int nRandom = Random(nItemsInBaseCont);
    
            object oItem;
            if (nBaseType1 == BASE_ITEM_INVALID) {
                // we're not checking base types
                oItem = CTG_GetTreasureItem(oBaseCont, nRandom);
            } else {
                oItem = CTG_GetSpecificBaseTypeTreasureItem(oBaseCont,
                                                            nRandom,
                                                            nBaseType1,
                                                            nBaseType2,
                                                            nBaseType3);
            }
    
            if (!GetIsObjectValid(oItem)) {
                CTG_CreateDefaultTreasure(nTreasureType, oAdventurer, oCont);
            } else {
    
                // Copy the item
    //            CreateItemOnObject(GetResRef(oItem), oCont);
                // * do an actual copy BK Feb 2003. Less chance of resref errors
                CopyObject(oItem, GetLocation(oItem), oCont);
                // Destroy the original
                DestroyObject(oItem);
            }
    
            return;
        }
    

    Double check to see if your code matches.
    If it does then maybe it's something else.
    Is the module wide unique container tagged "X0_MOD_TREASURE_UNIQ"?
    Is it set to usable with an inventory?

  • QuilistanQuilistan Member Posts: 177
    I am having the same problem with the Unique chests not working. I Just double checked the script and it seems fine. I am not sure when it stopped working though.
  • ForSeriousForSerious Member Posts: 446
    Sorry guys, I could have looked into this better the first time.
    Something has changed with the way CopyObject works.
    In x0_i0_treasure around line 868
    CopyObject(oItem, GetLocation(oItem), oCont);
    
    It's using the location of the item in the base chest. Now it says that should be ignored, but it's not. Maybe it's throwing an internal error because the item is in an inventory. Not sure.
    Anyway, I was able to get it to work by changing that line to use the location of the chest the user just looked in:
    CopyObject(oItem, GetLocation(oCont), oCont);
    
    It should also work if you change it to the location of the player that open/destroyed the chest.
    CopyObject(oItem, GetLocation(oAdventurer), oCont);
    

    I did a lot of testing, and changing to either of those locations works for opening and destroying chests.
  • QuilistanQuilistan Member Posts: 177
    Thank you!
Sign In or Register to comment.