Re: Level restrictions

From: Daniel A. Koepke (
Date: 07/21/99

Today, Tony Maro spake to the list:

> Here's a logistical question then.  Say you only want 5 of a
> particular sword in the game.  Total.  Joe has one and logs out with
> it.  Now, it's not an active item...  Joe never comes back and is
> automatically deleted in a few months.  Without putting special code
> to look for that ONE item, how do we know we can respawn the item?

A quick and dirty implementation,

    * This file contains unique items in the format:
    *     <vnum> <max quantity> <current quantity>
    * and is saved over reboots.



Load this into an appropriate array.  When you delete a player, scan his
inventory to see if he has any of the items in the unique items list.  If
you're worried about players with a lot of inventory in combination to a
large number of unique items, you can add, "int num_specials;" and,
"struct obj_data ** special_pointers;" to keep track of special items a
person has on them (you would fill in this data at boot time).  But, it
really shouldn't be a concern, since how often are you deleting players?

If you don't want to add an ITEM_SPECIAL flag, then you'll have to search
the array each time an object is removed from the world or added to the
world.  Better to add the flag to save some wasted time, but if you're
completely deadset against it, you don't have to.  Alternatively, you can
just add an, "int special_item : 1;" variable to the item and
automatically set it on boot time so you don't waste an ITEM_xxx flag.
The specifics of implementation are up to you and how scalable you want
the code.

We use the above mentioned file for storing the unique item array for two
reasons: first, it's much more convenient for editing purposes, and with a
highly dynamic world, that can be a major boon; second, we don't have to
recount items on start-up (which, of course, would be the other way we
could do this to avoid recounting items every respawn).  Despite these
advantages, you may still want to count items at boot time, although it
will undoubtedly add a fair amount of load time.  The sole advantage of
this latter form is that it'd be safe to delete someone's rent file
without having to adjust the text file to match the adjusted count.  As I
said, however, the specifics of implementation are up to you.


     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     |  |

This archive was generated by hypermail 2b30 : 12/15/00 PST