This code donated by LordROM:
ok here is what you need to have aff2 working properly on a ROM2.4 mud:
merc.h:
------
add this to char_data and also to mob_index_data:
long affected2_by;
add this after the same thing but IS_AFFECTED (will look simular):
#define IS_AFFECTED2(ch, sn) (IS_SET((ch)->affected2_by, (sn)))
right after affect_bit_name add:
char * affect2_bit_name args( ( int vector ) );
then add the following after your AFF_ flags:
/*
* Bits for 'affected2_by'.
* Used in #MOBILES.
*/
your flags go here... you can use #define AFF_.. no need for AFF2
and finally add #define TO_AFFECTS2 6
to the where definitions..
handler.c:
----------
in void affect_check right after the case TO_AFFECTS check add:
case TO_AFFECTS2:
SET_BIT(ch->affected2_by, vector);
break;
keep checking all function that has TO_AFFECTS and add a check for
TO_AFFECTS2.
right after the function affect_bit_name add:
/*
* Return ascii name of an affect bit vector.
*/
char *affect2_bit_name( int vector )
{
static char buf[512];
buf[0] = '\0';
/* your flag declarations here */
/* if (vector & AFF_TEST_FLAG) strcat(buf, " test_flag"); */
return ( buf[0] != '\0' ) ? buf+1 : "none";
}
after doing and modifying all the affect checks we finally move to act_wiz.c:
act_wiz.c:
----------
in do_mstat right after if (affected_by) check add:
if (affected2_by)
{
sprintf(buf, "Also affected by %s\n\r",
affect2_bit_name(victim->affected2_by) );
add_buf(buffer,buf);
}
that is it, whenever u wanna add a new aff2 flag add it to merc.h then
make sure your magic2.c calls IS_AFFECTED2 example:
void spell_test_spell( int sn, int level, CHAR_DATA *ch, void *vo, int target)
{
CHAR_DATA *victim = (CHAR_DATA *) vo;
AFFECT_DATA af;
if (IS_AFFECTED2(victim, AFF_TEST_FLAG) )
{
if (victim == ch)
send_to_char("You can already sense a test flag in you.\n\r",ch);
else
act("$N can already sense a test flag.",ch, NULL, victim, TO_CHAR);
return;
}
af.where = TO_AFFECTS2;
af.type = sn;
af.level = level;
af.duration = level;
af.modifier = 0;
af.location = APPLY_NONE;
af.bitvector = AFF_TEST_FLAG;
affect_to_char( victim, &af );
send_to_char( "Your eyes flickers.\n\r", victim );
if ( ch != victim )
send_to_char( "Ok.\n\r", ch );
return;
}
That is all you need, if there is a problem, feel free to email me back..
Lordrom
------
new-world.mclv.net 4000
Nevermore Mud