perm.txt
snippets · 2.3 KB · 2010-03-30
perm: permanent affects on items (post from Nov 1995).
Download « Back to the snippets list
From avoid@fyionline.comWed Nov 22 15:06:39 1995
This code gives permanent affects on items.
void do_perm( CHAR_DATA *ch, char *argument )
{
char item[MAX_INPUT_LENGTH], affect[MAX_INPUT_LENGTH], mod[MAX_INPUT_LENGTH];
OBJ_DATA *obj;
AFFECT_DATA *aff;
argument = one_argument( argument, item );
argument = one_argument( argument, affect );
argument = one_argument( argument, mod );
if (item[0] == '\0' || affect[0] == '\0')
{
send_to_char( "Perm <item> <affect> [modifier]\n\r", ch );
return;
}
if( ( obj = get_obj_carry( ch, item )) == NULL )
{
send_to_char( "You don't have that item.\n\r", ch );
return;
}
aff = malloc( sizeof( *aff ) );
aff->level = ch->level;
aff->duration = -1;
aff->bitvector = 0;
aff->type = aff->location = get_item_apply_val (affect);
if (mod [0] != '\0')
aff->modifier = atoi (mod);
else
aff->modifier = ch-> level;
affect_to_obj( obj, aff );
return;
}
-----------[ End 'perm' code ]----------
If have an interest in a perm'd Sanc item, you'll have to add that
code to affect_modify() in handler.c if it isn't there now.
-----[ Begin... handler.c affect_modify() addition ]-----------
case APPLY_SANCTUARY:
{
af.type = skill_lookup( "sanctuary" );
if( fAdd )
{
if( is_affected( ch, af.type ) )
{
send_to_char( "You are already in sanctuary.\n\r", ch );
break;
}
af.level = mod;
af.duration = -1;
af.location = APPLY_NONE;
af.modifier = 0;
af.bitvector = AFF_SANCTUARY;
affect_to_char( ch, &af );
send_to_char( "You are surrounded by a white aura.\n\r", ch );
act( "$n is surrounded by a white aura.", ch, NULL, NULL, TO_ROOM );
break;
}
else
{
affect_strip( ch, af.type );
send_to_char( "The white aura around your body vanishes.\n\r", ch );
act( "The white aura around $n's body vanishes.", ch,
NULL, NULL, TO_ROOM);
break;
}
}
------[ End... handler.c addition ]-----------
The only other thing I think you need to do is:
A). Setup the command/skill to suit.
B). Add the apply types to merc.h for any new perm'd object flags.
C). Compile, and have fun...
I hope that gets you going.... The players love it.
-Reble avoid@erzulie.fyionline.com