Anti-flags not working properly...

Posted by USER007 on Thu 07 Apr 2005 11:08 PM — 3 posts, 14,773 views.

#0

Build.c:

char *	const	o_flags	[] =
{
"glow", "hum", "dark", "loyal", "evil", "invis", "magic", "nodrop", "bless",
"antigood", "antievil", "antineutral", "noremove", "inventory",
"antihuman", "antifighter", "antifircedemon", "antifiredemon", "organic", "metal",
"donation", "clanobject", "clancorpse", "antifoxdemon", "antispiritdet", 
"hidden", "poisoned", "covering", "deathrot", "buried", "prototype", 
"nolocate", "groundrot", "lootable", "antispirithm", "antiwarrior"
};

mud.h:

typedef enum
{
  ITEM_GLOW, ITEM_HUM, ITEM_DARK, ITEM_LOYAL, ITEM_EVIL, ITEM_INVIS, ITEM_MAGIC, 
  ITEM_NODROP, ITEM_BLESS, ITEM_ANTI_GOOD, ITEM_ANTI_EVIL, ITEM_ANTI_NEUTRAL, 
  ITEM_NOREMOVE, ITEM_INVENTORY, ITEM_ANTI_HUMAN, ITEM_ANTI_FIGHTER, 
  ITEM_ANTI_FIRCE_DEMON, ITEM_ANTI_FIRE_DEMON, ITEM_ORGANIC, ITEM_METAL, ITEM_DONATION, 
  ITEM_CLANOBJECT, ITEM_CLANCORPSE, ITEM_ANTI_FOX_DEMON, ITEM_ANTI_SPIRIT_DET, 
  ITEM_HIDDEN, ITEM_POISONED, ITEM_COVERING, ITEM_DEATHROT, ITEM_BURIED, 
  ITEM_PROTOTYPE, ITEM_NOLOCATE, ITEM_GROUNDROT, ITEM_LOOTABLE, ITEM_ANTI_SPIRIT_HM,
  ITEM_ANTI_WARRIOR,
  MAX_ITEM_FLAG
} item_extra_flags;

act_obj.c:
    if ( !IS_IMMORTAL(ch)
    &&  (( IS_OBJ_STAT(obj, ITEM_ANTI_HUMAN)
        && ch->class == CLASS_HUMAN					)
    ||   ( IS_OBJ_STAT(obj, ITEM_ANTI_FIGHTER)
        && ch->class == CLASS_FIGHTER					)
    ||   ( IS_OBJ_STAT(obj, ITEM_ANTI_FIRCE_DEMON)
	&& ch->class == CLASS_FIRCE_DEMON					)
    ||   ( IS_OBJ_STAT(obj, ITEM_ANTI_FIRE_DEMON)
	&& ch->class == CLASS_FIRE_DEMON					)
    ||   ( IS_OBJ_STAT(obj, ITEM_ANTI_FOX_DEMON)
	&& ch->class == CLASS_FOX_DEMON					)
    ||   ( IS_OBJ_STAT(obj, ITEM_ANTI_SPIRIT_DET)
	&& ch->class == CLASS_SPIRIT_DET					)
    ||   ( IS_OBJ_STAT(obj, ITEM_ANTI_SPIRIT_HM)
	&& ch->class == CLASS_SPIRIT_HM					)
    ||	 ( IS_OBJ_STAT(obj, ITEM_ANTI_WARRIOR)
	&& ch->class == CLASS_WARRIOR					)) )
    {
	act( AT_MAGIC, "You are forbidden to use that item.", ch, NULL, NULL, TO_CHAR );
	act( AT_ACTION, "$n tries to use $p, but is forbidden to do so.",
	    ch, obj, NULL, TO_ROOM );
	return;
    }

handler.c:

    if ( xIS_SET(*extra_flags, ITEM_ANTI_HUMAN)	) strcat( buf, " anti-human"    );
    if ( xIS_SET(*extra_flags, ITEM_ANTI_FIGHTER) ) strcat( buf, " anti-fighter"   );
    if ( xIS_SET(*extra_flags, ITEM_ANTI_FIRCE_DEMON) ) strcat( buf, " anti-firce-demon" );
    if ( xIS_SET(*extra_flags, ITEM_ANTI_FIRE_DEMON) ) strcat( buf, " anti-fire-demon"  );
    if ( xIS_SET(*extra_flags, ITEM_ANTI_FOX_DEMON)	) strcat( buf, " anti-fox-demon"   );
    if ( xIS_SET(*extra_flags, ITEM_ANTI_SPIRIT_DET)) strcat( buf, " anti-spirit-det" );
    if ( xIS_SET(*extra_flags, ITEM_ANTI_SPIRIT_HM) ) strcat( buf, " anti-spirit-hm"  );
    if ( xIS_SET(*extra_flags, ITEM_ANTI_WARRIOR) ) strcat( buf, " anti-warrior"   );



Heres the object:

Name: Some battle armor
Vnum: 10320 Type: armor Count: 3 Gcount: 1
Serial#: 67 TopIdxSerial#: 67 TopSerial#: 67
Short description: Some battle armor
Long description : Some battle armor is here.
Wear flags : take body
Extra flags: glow antiwarrior
Magic flags: none
Number: 1/1 Weight: 1/1 Layers: 0 Wear_loc: -1
Cost: 0 Rent: 0 Timer: 0 Level: 0
In room: 0 In object: (none) Carried by: Anavel
Index Values : 0 0 0 0 5600 5600.
Object Values: 0 0 0 0 5600 5600.


Mortal:
class : 00/Warrior

Problem is that my mortal can still wear the object with the anti flag.

Obed gets Some battle armor.
Obed fits Some battle armor on his body.

Did I miss something?

[EDIT] I downloaded the recent SmaugFUSS and examed the code with mine and I realized something in the newer FUSS, it had "class" capitalized: ch->Class. Anyways I changed it to how it was in the newer FUSS and the anti flags seem to be working now. Seems that their was a fix for this, but I never saw it on any of Samson's message boards.

[EDIT 2] I also noticed that most "sh_int's" were replaced with "short". Is their a reason for this?
Amended on Fri 08 Apr 2005 12:37 AM by USER007
USA #1
Class was changed because you cannot use "class" in C++ and I assume Samson did that to make it easier in the conversion to C++ if one is done. I did a quick look over your posted code and saw nothing wrong.
USA #2
Quote:

I also noticed that most "sh_int's" were replaced with "short". Is their a reason for this?


Because sh_int was a needless typedef for the proper type "short". Honestly didn't see any reason to continue using it even though other Merc bases have just left it in place since it was first added. I did an extensive Google search for it and it never shows up in anything outside of MUD code.