Skip to content

Clearing Junk Accumulated At Merchants

ColinKColinK Member Posts: 6
edited June 2019 in Builders - Scripting
I'm looking at the ClearMerchant() proc in the Rhun persistent world.

It appears to me to delete only non-infinite objects worth more than 4000 gold.

Either that or it fails to delete objects at all, because my merchants' collections of urchin rags, daggers, leather armor and empty wine bottles only continue to grow.

Before I begin committing codicide it seems reasonable to ask if anybody can recommend a relatively safe way to cause this procedure to delete objects with values as little as 1 gold?

Better yet, maybe there is a different, well-tested script somewhere that does the job?

I suspect I can simply change the 4000 to a 1, but then I look at that GetInfiniteFlag(oItem)==FALSE clause and wonder. I'm really tempted to archive a backup copy of ClearMerchant() and in my own copy entirely eliminate the Infinite Flag condition.

void main()
{
//Remove all sold items in merchant's inventory after 1 hour.
DelayCommand(HoursToSeconds(1), ClearMerchant());
}


void ClearMerchant()
{
object oItem=OBJECT_INVALID;
// Clear the merchants inventory
oItem = GetFirstItemInInventory();
while(oItem!=OBJECT_INVALID)
{
//Make sure people don't stuff <span class="highlight">chest</span> with plot items and break it
if(GetInfiniteFlag(oItem)==FALSE && !GetGoldPieceValue(oItem)>=4000)
{SetPlotFlag(oItem, FALSE);
DestroyObject(oItem, 0.0);}
oItem = GetNextItemInInventory();
}
}

Comments

  • EzRemakeEzRemake Member Posts: 15
    You could just change that 4000 to 1, or you could remove it entirely giving you
    if(GetInfiniteFlag(oItem)==FALSE)
    

    I would keep the infinite flag checking, as there needs to be some way to differentiate the items normally sold by the vendor vs everything else. If you remove the infinite flag check, it will just delete every item in the shop over 1 gold.

  • ColinKColinK Member Posts: 6
    Yeah, I thought it might do that. Unfortunately, there might be store items that are NOT infinite. I've done that in previous games to limit the availability of over-powered items. I think I will test by creating my own version of ClearMerchant() and only apply it to a few obvious merchants I have researched to make sure I know their base items are all infinite.
  • ColinKColinK Member Posts: 6
    So far so good. I used the EzRemake suggestion if(GetInfiniteFlag(oItem)==FALSE) and it appears to work well. Infinite items the merchant already sells are not affected. I can still sell them and they don't start new instances of those items. Items the merchant did not already sell vanish after the hour delay. Seems to be doing what I want. Thanks!
Sign In or Register to comment.