Re: Installing Item and Level Limits (question)

From: Pandion-Knight (s337239@student.uq.edu.au)
Date: 05/07/96


On Tue, 7 May 1996, Brian Christopher Guilbault wrote:

> On Mon, 6 May 1996, Hades wrote:
> 
> > > 
> > > I would like to add level limits to items, as I get very tired of watching
> > > newbies run around with my suposed 'high-level' weapons and armor. My
> > > question is: has anyone done this and does it require a pfile wipe or
> > > plrobj file deletion?
> 
> Disregarding the arguments about this and answering your question, we do 
> this in a simpler way than the first solution posted. In our method you 
> don't have to add another variable to the entire object structure, rather 
> just add a few flags.
> 
> In structs.h and constants.c, define your new ITEM flags. We call them 
> LVL10, LVL20., LVL30, etc. Then in handler.c you will find a piece of 
> code called invalid_class. This is the function that checks to see if a 
> character can't use an item because it is not usable by his/her class. At 
> the end of these checks, just add your new checks for the equipment like 
> below. Granted it uses up some flags, but in exchange, adding a limit is 
> as simple as adding another bit to the item in the object file.
> 
> 
> int invalid_class(struct char_data *ch, struct obj_data *obj) {
>   if ((IS_OBJ_STAT(obj, ITEM_ANTI_MAGIC_USER) && IS_MAGIC_USER(ch)) ||
>       (IS_OBJ_STAT(obj, ITEM_ANTI_CLERIC) && IS_CLERIC(ch)) ||
>       (IS_OBJ_STAT(obj, ITEM_ANTI_WARRIOR) && IS_WARRIOR(ch)) ||
>       (IS_OBJ_STAT(obj, ITEM_ANTI_THIEF) && IS_THIEF(ch)) ||
>       (IS_OBJ_STAT(obj, ITEM_LVL10) && (GET_LEVEL(ch) <= 9)) ||
>       (IS_OBJ_STAT(obj, ITEM_LVL20) && (GET_LEVEL(ch) <= 19)) ||
>       (IS_OBJ_STAT(obj, ITEM_LVL30) && (GET_LEVEL(ch) <= 29)) ||
>       (IS_OBJ_STAT(obj, ITEM_LVL40) && (GET_LEVEL(ch) <= 39)) ||
>       (IS_OBJ_STAT(obj, ITEM_LVL50) && (GET_LEVEL(ch) <= 49))) 
> 	return 1;
>  /* else*/
> 	return 0;
> }
> 
> 
> We have 60 mortal levels, so the 5 flags are enough for us. Also, we have 
> another way to add more flags if we run out. We do it for PRF_FLAGS by 
> adding a new set called PRF2_FLAGS. Works out nicely since we added new 
> communication channels and you can now be !MUSIC, !IMMNET, etc. I know 
> lots of people were looking for ways to add more flags and this is a 
> simple way. It didn't even require a p-file wipe. When you sdsstat a 
> player, they now have another field under "PRF" that says "PRF2: None" or 
> whatever. I will dig around for all the pieces of code today and post it 
> later if you guysd want it.
> 
> 
> Hope that helps,
> 
>   -Brian
> 
> 

No offense but what about a mud that has 300 levels.. like the one i'm 
on.  Thats 30 flags?  Lets just clog the structs file up.  I wrote a way 
to do it using integer variables - that way you dont HAVE to have 
increments of ten anyways, which is stupid if you want something 
restricted to level 45 or so, what do you do ?  Everyone's gonna be 
warring to get to the next 10 levels, not the next one, or whatever.
I saw a mud where they had LVL_10 LVL_20 etc and I just laughed, because 
they had a similar thing for mob attacks ATTACK_2 etc etc., making it 
very clumsy to work out.  Besides I really go for elegance. :)  Anyways I 
have a complete way on how to do it floating around the list somewhere, 
feel free to hack the idea up and use it, its not skin off my back.. :)

If you want to see how I parsed the new variables into the obj_proto drop 
me a line and I'll show you how I did it.  Its a peice of cake, and imo 
if you're not afraid to fiddle db.c you'll find it makes things much more 
free in the end than a bunch of flags.  Sorry but thats how I feel.

Code well..

Christopher Voutsis
Email: s337239@student.uq.edu.au



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