.-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-. 
 |                                                                       | 
 |                                                                       | 
 |                                                                       | 
 |                             DOOM SPELL                                | 
 |                                                                       | 
 !                                                                       ! 
 :                         A Snippet written by                          : 
 :                              Valcados                                 : 
 .                           for SMAUG MUDs                              . 
 .                                                                       . 
 :                                                                       : 
 :                                                                       : 
 !                                                                       ! 
 |                                                                       | 
 |                                                                       | 
 |                                                                       | 
 |                                                                       | 
 |                                                                       | 
 `-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-'
 
 DESCRIPTION:
 	"Doom" is like "curse", except much nastier.
 	This code snippet just creates the affect_type, the
 	spell itself can be created using SMAUGSPELLS once
 	the affect_type is in.  See the in-game mechanics
 	section for a more specific discussion of all the
 	effects doom has.

  
 TESTING:
  	This code has been in use on the Lands of Aethar MUD
  	(www.aethar.com) for about a year now and is somewhat
  	assimilated into that MUD.  However, it hasn't been
  	used as much as most the other code snippets, so there
  	could still remain little kinks.
 
 
IN-GAME MECHANICS:
 	Doom can be cured with the remove curse spell.
 	
 	Here are the specific things doom does to its unfortunate
 	victim:
 	
 	- If you're doomed, your foes get a chance at an extra
 		attack against you per round.  The chance is
 		negligible when you're healthy but goes up
 		as your health drops, peaking at a 20% chance
 		if you are below 5% health.
 	- While doomed, you are worse at learning from your
 		opponent in battle, and your opponent is
 		better at learning from you.
 	- Doomed people take 2% more damage and deal 2% less
 		damage in general.
 	- If you're doomed and also lagged, mobs are more
 		likely to disarm you.
 	- If you're doomed and NOT too lagged, mobs are more
 		likely to trip you.
 	- If you're doomed, about 10% of the time the fates
 		which be will actively try to choose the most
 		harmful equipment to damage when you're hit.
 	- If you're doomed, and close to levelling up, you start
 		getting less exp.  The closer to levelling,
 		the less exp.
 	- A doomed vampire will have to successfully save vs.
 		death in order to "howl with rage as the
 		beast within stirs".
 	- Doomed victims more likely to suffer mentalstate
 		side effects when wounds are BLEEDING so much.
 	- Sometimes when a doomed victim flees, fate will draw
 		them towards the worst possible room around them.
 	- If doomed and <= 10% health, you suffer an extra 5%
 		chance of dropping pills/potions in battle.
 	- Doomed players generally have a slightly harder time
 		adepting skills.
 	- Doomed characters are slightly easier to gouge, and the
 		resulting blindness lasts longer (very slightly)
 	- While digging with a shovel while doomed, there's
 		a possibility the shovel will break.
 	- Steal will steal 20% more coins from a doomed victim,
 		20% fewer coins if the thief is doomed.
 	- It's harder to rescue someone when they're doomed.
 	- Stun works better if the victim is doomed, worse if
 		the attacker is doomed.
 	- Doomed vamps who fail a feed suffer a tiny mentalstate penalty
 		(from frustrated blood hunger)
 	- If a doomed player, gaining a level, is about to gain 19hp
 		or more, theres a 1/8 chance that gain will be reduced
 		by 1.
 	- Doomed players, when knocked below 1 hp, will die sooner.
 	- Doomed players cannot recall.
 	
 	
 	
 
 KNOWN PROBLEMS/BUGS:
 	The "xaffected" modifier for affects on weapons and armor
 	is unfortunately broken in stock SMAUG.  This means only
 	the first 32 affects can actually be put on equipment.
 	So if doom is the 33rd or later affect in your MUD, it
 	can't be put on equipment.  This problem is fixed on
 	the Lands of Aethar and I might make a snippet out of it.
 	Anyway, you can still make spells which doom their
 	victims by using the "bitvector" in SMAUGSPELLS.
 	Anyway this bug is present in stock SMAUG whether or not
 	you install doom.
 	
 	Overall problem/bug assessment:  negligible.

        *UPDATE*  Since writing this, I've posted a snippet to fix
        this by fixing the "xaffected" apply type.  You can find it
        at:
            http://forums.smaugfuss.org/index.php?a=topic&t=846
 
 
 HOW TO INSTALL:
 
 1.  In build.c find where the a_flags array is defined.  Add "doomed"
 	at the end of the array.
 
 
 2.  In db.c, find where the gsn's are declared (for example search for
 	gsn_curse) and declare a new one,
 
 	int	gsn_doom;
 
 
 3.  In db.c, find where the gsn's are initialized, for example search
 	for    "ASSIGN_GSN(gsn_curse"    and initialize gsn_doom:
 	
 	ASSIGN_GSN(gsn_doom,           "doom");
 
 
 4.  In fight.c, in multi_hit, find something like this:
 
     if ( ch->move < 10 )
      dual_bonus = -20;
      
     below it, add this:
     
         /*
          * Chance to get an extra hit on doomed victims--
          *   and the closer they are to dying, the greater the chance!
          */
         if ( IS_DOOMED( victim ) && !IS_DOOMED( ch ) )
         {
           int failchance;
           if ( victim->hit*20 <= victim->max_hit )
             failchance = 80;
           else if ( victim->hit*10 <= victim->max_hit )
             failchance = 85;
           else if ( victim->hit*5 <= victim->max_hit )
             failchance = 95;
           else
             failchance = 98;
     
           if ( failchance < number_percent() )
           {
             retcode = one_hit( ch, victim, dt );
             if ( retcode != rNONE || who_fighting( ch ) != victim )
               return retcode;
           }
    	}
    	

5.  In fight.c, in one_hit, find something like this:

	sh_int intdiff = get_curr_int(ch) - get_curr_int(victim);
	
    Below it, add this:
    
            if (IS_DOOMED(victim))
             intdiff += 3;
            if (IS_DOOMED(ch))
             intdiff -= 3;
             

6.  In fight.c, in one_hit, find something like this:

	if ( !IS_NPC(ch) && ch->pcdata->learned[gsn_enhanced_damage] > 0 )

    Above it, add this:

    /*
     * Doomed characters take 2% more damage and do 2% less damage in general
     */
    if ( IS_DOOMED( ch ) )
       dam = .98 * dam;
    if ( IS_DOOMED( victim ) )
       dam = 1.02 * dam;


7.  In fight.c, in the damage function (or the specific_damage function
	if you've installed the elemental items snippet), find something like this:
	
	    if (IS_NPC(ch)
		&& xIS_SET(ch->defenses, DFND_DISARM)
		&& ch->level > 9
		&& number_percent() < ch->level / 3) /* Was 2 try this --Shaddai*/

    Replace it with this:

	    if (IS_NPC(ch)
		&& xIS_SET(ch->defenses, DFND_DISARM)
		&& ch->level > 9			/* While doomed and highly lagged, */
                &&(number_percent() < ch->level / 3	/*  probability of being disarmed  */
                ||(IS_DOOMED(victim)			/*  goes up */
                && !IS_NPC(victim)
                && victim->wait >= PULSE_VIOLENCE
                && number_percent() < ch->level)) )


8.  In fight.c, in the damage function (or the specific_damage function
	if you've installed the elemental items snippet), find something like this:

	    if (IS_NPC(ch)
		&& xIS_SET(ch->attacks, ATCK_TRIP)
		&& ch->level > 5
		&& number_percent() < ch->level / 2)
		trip(ch, victim);

    Replace it with this:

            if (IS_NPC(ch)
                && xIS_SET(ch->attacks, ATCK_TRIP)
                && ch->level > 5
                &&(number_percent() < ch->level / 2	/* While doomed and NOT very	*/
                ||(IS_DOOMED(victim)			/*  lagged, probability of	*/
                && !IS_NPC(victim)			/*  being tripped goes up	*/
                && victim->wait < PULSE_VIOLENCE/4
                && number_percent() < 25)) )


9.  In fight.c, in the damage function (or the specific_damage function
	if you've installed the elemental items snippet), find something like this:

	damobj = get_eq_char(victim, dameq);

    Below it, add this:

	/*
	 *  Ocassionally practice evil bias
	 *    against doomed people, and
	 *    try to specifically target
	 *    the most hurtful eq to damage
	 */
        if ( IS_DOOMED(victim)
        &&   number_percent() < 10 )
          damobj = get_eq_doomed(victim);


10. In fight.c, in the damage function (or the specific_damage function
	if you've installed the elemental items snippet), find the block of
	code starting with something like this:

    /*
     * Get experience based on % of damage done                 -Thoric
     */
    if ( dam && ch != victim
    &&  !IS_NPC(ch) && ch->fighting && ch->fighting->xp )
    {

    At the top of this block  (just below the "{" shown above), declare new variable:
    
        int xp_need;


11. In the same block from step 10, a little further down, find something
	like this:

	if ( dt == gsn_backstab || dt == gsn_circle )
	    xp_gain = 0;

	Below it, add this:

	/*
	 *  For doomed players, exp slows down as a level draws near
	 */
        if ( IS_DOOMED( ch )
        &&   !IS_NPC(ch) )
        {
          xp_need = exp_level(ch, ch->level) - ch->exp;
          if ( xp_gain > xp_need / 2 )
            xp_gain /= 16;
          else if ( xp_gain > xp_need / 4 )
            xp_gain /= 8;
          else if ( xp_gain > xp_need / 8 )
            xp_gain /= 4;
          else if ( xp_gain > xp_need / 16 )
            xp_gain /= 2;
        }


12. In fight.c, in the damage function (or the specific_damage function if you've
	installed the elemental items snippet), find this or something similar:

    /*
     * Vampire self preservation				-Thoric
     */
    if ( IS_VAMPIRE(victim) )
    
    Replace it with this:

    /*
     * Vampire self preservation				-Thoric
     *
     * If doomed, vampire must successfully
     *   save vs. death to get this bonus			-Valcados
     */
    if ( IS_VAMPIRE(victim)
    && ( !IS_DOOMED(victim) || saves_poison_death( ch->level, victim ) ) )


13. In fight.c, in the damage function (or the specific_damage function if you've
	installed the elemental items snippet), find something like this:
	
	   act( AT_DANGER, "You wish that your wounds would stop BLEEDING so much!",
		victim, 0, 0, TO_CHAR );
	   if ( number_bits(2) == 0 )
		worsen_mental_state( victim, 1 );

    Replace it with this:

           act( AT_DANGER, "You wish that your wounds would stop BLEEDING so much!",
                victim, 0, 0, TO_CHAR );
           if ( number_bits(2) == 0
           || ( IS_DOOMED(victim) && number_bits(2) == 0 ) )  /* Doomed victims more susceptible to anguish */
		worsen_mental_state( victim, 1 );


14. In fight.c, in the do_flee function, where the variables are declared,
	declare new variable:

    	bool tried_doom = FALSE;


15. In fight.c, in do_flee, find something like this:

    for ( attempt = 0; attempt < 8; attempt++ )
    {
	door = number_door( );
	if (( pexit = get_exit( was_in, door ) ) == NULL
	||    !pexit->to_room
	||   IS_SET( pexit->exit_info, EX_NOFLEE )
	|| ( IS_SET( pexit->exit_info, EX_CLOSED )
	&&  !IS_AFFECTED( ch, AFF_PASS_DOOR ) )
	|| ( IS_NPC( ch )
	&&   IS_SET( pexit->to_room->room_flags, ROOM_NO_MOB ) ) )
	    continue;
	    
    Replace it with this:
    
        if ( IS_DOOMED(ch)		/* Doomed?  Then flee into */
        &&   !tried_doom		/*  the nastiest possible  */
        &&   number_percent()<20 )	/*  room! */
        {
          pexit = get_door_doom( ch );
          tried_doom = TRUE;
        }
        else
          pexit = get_exit( was_in, door );

        if ( !pexit
        ||   !pexit->to_room
        ||   IS_SET( pexit->exit_info, EX_NOFLEE )
        || ( IS_SET( pexit->exit_info, EX_CLOSED )
        &&  !IS_AFFECTED( ch, AFF_PASS_DOOR ) )
        || ( IS_NPC( ch )
        &&   IS_SET( pexit->to_room->room_flags, ROOM_NO_MOB ) ) )
            continue;


16. Add the following function to fight.c (for example you could add it
	at the very bottom):

EXIT_DATA * get_door_doom( CHAR_DATA *ch )
{
  ROOM_INDEX_DATA *in, *out;
  EXIT_DATA *x, *best = NULL;
  int record = 0, current;
  CHAR_DATA *aggro;
  int ties = 1;

  if ( !(in = ch->in_room) )
    return NULL;

  /*
   * For doomed players, find the most evil exit, based on a point
   *  system (DT is 30 points, drowning is 5 points, etc...)
   */

  for ( x = in->first_exit; x; x = x->next )
  {
    if ( !(out = x->to_room)
    ||   IS_SET( x->exit_info, EX_WINDOW )
    || ((IS_SET( x->exit_info, EX_SECRET ) || IS_SET(x->exit_info, EX_HIDDEN) )
    &&   IS_SET( x->exit_info, EX_CLOSED ) )
    || ( IS_NPC( ch )
    && ( IS_SET( x->exit_info, EX_NOMOB ) || IS_SET(out->room_flags, ROOM_NO_MOB ) ) )
    ||   IS_SET( out->room_flags, ROOM_DND )
    ||   IS_SET( x->exit_info, EX_NOFLEE ) )
      continue;
    current = 0;
    if ( IS_SET( out->room_flags, ROOM_DEATH ) )
      current += 30;
    if ((out->sector_type == SECT_UNDERWATER || out->sector_type == SECT_OCEANFLOOR)
    &&   !IS_NPC(ch)
    &&   !IS_AFFECTED(ch, AFF_AQUA_BREATH) )
      current += 5;
    if ( !IS_AFFECTED(ch, AFF_FLYING)
    && ( !ch->mount || !IS_AFFECTED(ch->mount, AFF_FLYING) ) )
    {
      if ( IS_SET( x->exit_info, EX_CLIMB ) )
        current += 2;
      if ( IS_SET( x->exit_info, EX_FLY ) )
        current += 5;
      if ( IS_SET( out->room_flags, ROOM_NOFLOOR ) )
        current += 8;
     }
     if ( IS_SET( out->room_flags, ROOM_NO_MAGIC ) )
       current += 6;
     if ( IS_SET( out->room_flags, ROOM_NO_RECALL ) )
       current += 2;
     if ( IS_SET( out->room_flags, ROOM_SILENCE ) )
       current += 1;
     if ( IS_SET( out->room_flags, ROOM_NOSUPPLICATE ) )
       current += 7;
     if ( current < record
     &&   current + 10 >= record
     &&   !IS_SET( out->room_flags, ROOM_SAFE ) )
     {
       for ( aggro = out->first_person; aggro; aggro = aggro->next_in_room )
       {
         if ( !IS_NPC( aggro )
         ||   !xIS_SET( aggro->act, ACT_AGGRESSIVE )
         || ( IS_AFFECTED( aggro, AFF_BLIND )
         &&   !IS_AFFECTED( aggro, AFF_TRUESIGHT ) )
         ||   IS_AFFECTED( aggro, AFF_CHARM )
         ||   aggro->level < ch->level / 5 )
           continue;

         current += 3;
         break;
       }
     }

     current += number_bits(3);
     if ( current > record )
     {
       ties = 1;
       record = current;
       best = x;
     }
     else if ( current == record )
     {
       ties++;
       if (number_percent() < 100/ties)
         best = x;
     }
   }
  return best;
}


17. In fight.c, add the following function (for instance you could
	add it at the very bottom):

OBJ_DATA *get_eq_doomed(CHAR_DATA *ch)
{
  /* Doomed characters get the worst item damage */
  OBJ_DATA *x, *best = NULL;
  int ties=1;
  int ac, low_ac=10000;

  for ( x=ch->first_carrying; x; x= x->next_content )
  {
    if ( x->wear_loc == WEAR_NONE )
      continue;
    ac = x->value[0] * 10;
    if ( IS_OBJ_STAT( x, ITEM_ORGANIC ) )
      ac = ac * .9;
    if ( IS_OBJ_STAT( x, ITEM_METAL ) )
      ac = ac * 1.1;
    if ( IS_OBJ_STAT( x, ITEM_BLESS ) )
      ac = ac * 1.3;
    if ( IS_OBJ_STAT( x, ITEM_MAGIC ) )
      ac = ac * 1.2;
    if ( IS_OBJ_STAT( x, ITEM_NOREMOVE ) )
      ac = ac * .9;
    if ( IS_OBJ_STAT( x, ITEM_DEATHROT ) )
      ac = ac * .8;

    ac *= number_range( 80, 120 ) / 100.0;
    if ( ac < low_ac )
    {
      best = x;
      ties = 1;
      low_ac = ac;
    }
    else if ( ac == low_ac )
    {
      ties++;
      if (number_percent() < 100/ties)
        best = x;
    }
  }

  return best;
}


18. In handler.c, in affect_bit_name, pick whichever slot you like and
	add the line

    if ( xIS_SET(*vector, AFF_DOOMED       )) strcat( buf, " doomed"        );


19. In magic.c, in spell_remove_curse, find this block or something similar:

    if ( is_affected( victim, gsn_curse ) )
    {
        affect_strip( victim, gsn_curse );
        set_char_color( AT_MAGIC, victim );
        send_to_char( "The weight of your curse is lifted.\n\r", victim );
        if ( ch != victim )
        {
            act( AT_MAGIC, "You dispel the curses afflicting $N.", ch, NULL, victim, TO_CHAR );
            act( AT_MAGIC, "$n's dispels the curses afflicting $N.", ch, NULL, victim, TO_NOTVICT );
        }
    }

    Right below it, add this:

    else if ( is_affected( victim, gsn_doom ) )
    {
      affect_strip( victim, gsn_doom );
 
      if ( victim != ch )
      {
        act( AT_MAGIC, "You save $N from suffering a dire fate.", ch, NULL, victim, TO_CHAR );
        act( AT_MAGIC, "$n saves $N from suffering a dire fate.", ch, NULL, victim, TO_NOTVICT );
	act( AT_MAGIC, "Defying the powers of fate, $n lifts a horrible doom from your shoulders!", ch, NULL, victim, TO_VICT );
      }
      else
      {
        set_char_color( AT_MAGIC, ch );
        send_to_char( "Defying the powers of fate, you cast aside your doom!\n\r", victim );
      }
    }


20. In misc.c, in do_eat, find something like this:

    if ( ch->fighting && number_percent( ) > (get_curr_dex(ch) * 2 + 47) )
    {
	sprintf( buf, "%s",
	( ch->in_room->sector_type == SECT_UNDERWATER ||
	  ch->in_room->sector_type == SECT_WATER_SWIM ||
	  ch->in_room->sector_type == SECT_WATER_NOSWIM )   ? "dissolves in the water" :
	( ch->in_room->sector_type == SECT_AIR        ||
	  IS_SET( ch->in_room->room_flags, ROOM_NOFLOOR ) ) ? "falls far below" :
							      "is trampled underfoot" );

    Replace that first line (the "if" line) with this:

    /*
     *  Doomed players with 10% health or less are more likely to drop food
     */
    if ( ch->fighting
    &&   number_percent() > (get_curr_dex(ch) * 2 + 47) - ((IS_DOOMED(ch) && ch->hit*10 <= ch->max_hit) ? 5 : 0) )


21. In misc.c, in do_quaff, find something like this:

    if ( ch->fighting && number_percent( ) > (get_curr_dex(ch) * 2 + 48) )
    {
	act( AT_MAGIC, "$n fumbles $p and shatters it into fragments.", ch, obj, NULL, TO_ROOM );

    Replace that first line (the "if" line) with this:
    
    /*
     *  Doomed players with 10% health or less are more likely to drop potions
     */
    if ( ch->fighting
    &&   number_percent() > (get_curr_dex(ch) * 2 + 48) - ((IS_DOOMED(ch) && ch->hit*10 <= ch->max_hit) ? 5 : 0) )


22. In mud.h, find the affected_by_types enum (search for "affected_by_types").
	Insert the new entry "AFF_DOOMED" just before "MAX_AFFECTED_BY".
	It is CRITICAL that you make sure the order of the affects in this enum
	is the same as the order of the affect names from step 1.


23. In mud.h, find a line something like

	extern        sh_int        gsn_curse;
	
    Just after it, add the line

	extern	      sh_int        gsn_doom;


24. In mud.h, find a line something like

	#define IS_AFFECTED(ch, sn)        (xIS_SET((ch)->affected_by, (sn)))

    Just after it, add the line

	#define IS_DOOMED(ch)    (IS_AFFECTED(ch,AFF_DOOMED))


25. In mud.h, in the list of global function declarations for fight.c (search for "fight.c"),
	add the global function declarations:

	EXIT_DATA *get_door_doom args( ( CHAR_DATA *ch ) );
	OBJ_DATA *get_eq_doomed args( ( CHAR_DATA *ch ) );
	

26. In mud.h, in the list of global function declarations for skills.c (search for "skills.c"),
	add the global function declaration:

	OBJ_DATA *get_disarm_doom args(( CHAR_DATA *ch, OBJ_DATA *o1, OBJ_DATA *o2 ));
	

27. In skills.c, in learn_from_failure, find a line like

	if ( chance - number_percent() > 25 )
	
    Right above it, add this:

    if ( IS_DOOMED( ch ) )
      chance += 10;
      

28. In skills.c, in do_gouge, find a line like this:

    chance = (( get_curr_dex(victim) - get_curr_dex(ch)) * 10) + 10;
    
    Below it, add this:

    if ( IS_DOOMED( victim ) )
      chance -= 10;
      

29. In skills.c, in do_gouge, find something like this:

                  af.bitvector = meb(AFF_BLIND);
                  affect_to_char( victim, &af );
                  act( AT_SKILL, "You can't see a thing!", victim, NULL, NULL, TO_CHAR );

    Right above it, add this:

                  if ( IS_DOOMED( victim )
                  &&   !number_bits(2) )
                    af.duration += 1;


30. In skills.c, in do_dig, find something like this:

      if ( obj->item_type == ITEM_SHOVEL )
      {
	  shovel = TRUE;
	  break;
      }

    Change it to this:
    
      if ( obj->item_type == ITEM_SHOVEL )
      {
          /* If digger is doomed, shovels might break */
          if ( IS_DOOMED( ch )
          &&   !number_bits( 3 ) )
          {
            separate_obj( obj );
            act( AT_OBJECT, "Suddenly, $p breaks!", ch, obj, NULL, TO_CHAR );
            act( AT_OBJECT, "$n's dig is interrupted when $p breaks!", ch, obj, NULL, TO_CHAR );
            extract_obj( obj );
            return;
          }
          shovel = TRUE;
          break;
      }
      

31. In skills.c, in do_steal, find something like this:

        if ( amount <= 0 )
        {
            send_to_char( "You couldn't get any gold.\n\r", ch );
            learn_from_failure( ch, gsn_steal );
            return;
        }

    Right above it, add this:

        if ( IS_DOOMED( ch ) )
          amount *= .8;
        if ( IS_DOOMED( victim ) )
          amount *= 1.2;


32. In skills.c, in do_rescue, find something like this:

    if (!can_use_skill( ch, percent, gsn_rescue ) )
    
    Replace it with this:
    
    if ((IS_DOOMED(victim) && !number_bits(2))
    ||   !can_use_skill( ch, percent, gsn_rescue ) )
    

33. In skills.c, in do_stun, find something like this:

      chance += sysdata.stun_regular;
      
    Below it, add this:
    
    if ( IS_DOOMED( victim ) )
      chance -= 10;
    if ( IS_DOOMED( ch ) )
      chance += 10;
      

34. In skills.c, in do_feed, find something like this:

	act( AT_BLOOD, "$n is lusting after your blood!", ch, NULL, victim, TO_VICT );

    Below it, add this:

            if ( IS_DOOMED( ch ) )
              worsen_mental_state( ch, 1 );


35. In skills.c, in the disarm function, find something like this:

    if ( ( tmpobj = get_eq_char( victim, WEAR_DUAL_WIELD ) ) != NULL
    &&     number_bits( 1 ) == 0 )
	obj = tmpobj;

    Replace it with this:
    
    /*
     *   doomed characters are more likely to get the weapon
     *    disarmed that hurts them the most
     */
    if ( ( tmpobj = get_eq_char( victim, WEAR_DUAL_WIELD ) ) != NULL )
       obj = get_disarm_doom( victim, obj, tmpobj );


36. Somewhere in skills.c, add the following function (for instance
	you could add it at the very bottom):

/*
 *  For doomed people, try to disarm the weapon
 *    which will harm them the most by having it
 *    disarmed.  Do this based on a point system.
 */
OBJ_DATA *get_disarm_doom( CHAR_DATA *ch, OBJ_DATA *o1, OBJ_DATA *o2 )
{
  int points[2], i;
  OBJ_DATA *o[2];
  int hp, dr, mana;
  AFFECT_DATA *paf, *paf_next;

  if ( !IS_DOOMED( ch ) )
    return number_bits(1) ? o2 : o1;

  points[0]=points[1]=0;
  o[0] = o1, o[1] = o2;

  for ( i = 0; i <= 1; i++ )
  {
    if ( o[i]->item_type != ITEM_WEAPON )
      points[i] -= 20;
    if ( o[i]->value[0] <= 2 )
      points[i] -= 15;
    if ( IS_OBJ_STAT( o[i], ITEM_LOYAL ) )
      points[i] -= 15;
    if ( IS_OBJ_STAT( o[i], ITEM_NOREMOVE )
    ||   IS_OBJ_STAT( o[i], ITEM_NODROP ) )
      points[i] -= 5;
    if ( !can_see_obj( ch, o[i] ) )
      points[i] += 15;
    if ( (o[i]->value[1]+o[i]->value[2])/2 > (o[1-i]->value[1]+o[1-i]->value[2])/2 )
      points[i] += (12.5*(o[i]->value[1]+o[i]->value[2]-o[1-i]->value[1]-o[1-i]->value[2]))/ch->level;
    if ( !IS_OBJ_STAT( o[i], ITEM_MAGIC )
    &&   ch->in_room
    &&   IS_SET( ch->in_room->room_flags, ROOM_NOFLOOR ) )
      points[i] += 10;
    if ( IS_OBJ_STAT( o[i], ITEM_GROUNDROT ) )
      points[i] += 10;
    if ( IS_OBJ_STAT( o[i], ITEM_DEATHROT ) )
      points[i] -= 5;

    hp = mana = dr = 0;
    for ( paf = o[i]->first_affect ? o[i]->first_affect : o[i]->pIndexData->first_affect; paf; paf = paf_next )
    {
      switch( paf->location )
      {
        case APPLY_HIT:
        hp += paf->modifier; break;
        case APPLY_MANA:
        mana += paf->modifier; break;
        case APPLY_DAMROLL:
        dr += paf->modifier; break;
      }
      paf_next = paf->next ? paf->next : paf == o[i]->pIndexData->last_affect ? NULL : o[i]->pIndexData->first_affect;
    }
    points[i] += hp / ch->level;
    points[i] += mana / (ch->level * 4);
    points[i] += dr / 3;

    if ( !IS_NPC( ch )
    &&   can_use_skill( ch, 0, gsn_circle )
    && ( o[i]->value[4] == WEP_DAGGER
    ||   o[i]->value[4] == WEP_SPEAR
    ||   o[i]->value[3] == 2
    ||   o[i]->value[3] == 6
    ||   o[i]->value[3] == 7 ) )
      points[i] += 12;
  }

  points[1] = (points[1] * number_range(85,115))/100;

  if ( points[0] > points[1] )
    return o1;
  else
    return o2;
}


37. In special.c, in spec_thief, find something like this:

        if ( IS_AWAKE(victim) && number_range( 0, ch->level ) == 0 )

    Replace it with this:
    
        /* doomed victims easier to rob */
        if ( IS_AWAKE(victim) && number_range( 0, ch->level ) == 0
        && ( !IS_DOOMED( victim ) || !number_bits(1) ) )


38. A little further below the material in step 37, find something like this:

            ch->gold     += 9 * gold / 10;

    Above it, add this:
    
            if ( IS_DOOMED( victim )
            &&   gold * 1.2 <= victim->gold/4 )
            {
              gold *= 1.2;
              ch->gold += 8 * gold / 10;
            }
            else


39. In update.c, in advance_level, find something like this:

    add_hp      = UMAX(  1, add_hp   );

    Right above it, add this:
    
    /*
     * If a doomed player is about to gain 19hp or more, they suffer
     *        a 1/8 chance of that gain being reduced by one
     */
    if ( IS_DOOMED( ch )
    &&   add_hp >= 19
    &&   !number_bits(3) )
       --add_hp;
       

40. In update.c, in hit_gain, find something like this:

	case POS_MORTAL:   return -1;
	case POS_INCAP:    return -1;
	case POS_STUNNED:  return 1;

    Replace it with this:

        case POS_MORTAL:   return IS_DOOMED(ch)? -10 : -1;
        case POS_INCAP:    return IS_DOOMED(ch)? -3 : -1;
        case POS_STUNNED:  return IS_DOOMED(ch)? -1 : 1;


41. In skills.c, find something like this:

    if ( IS_AFFECTED(ch, AFF_CURSE) )
    {
        send_to_char("You are cursed and cannot recall!\n\r", ch );
        return;
    }

    Above it, add this:

    if ( IS_DOOMED( ch ) )
    {
       ch_printf( ch, "You are %sdoomed and cannot recall!\n\r",
                      IS_AFFECTED( ch, AFF_CURSE ) ? "cursed and " : "" );
       return;
    }


42. Recompile SMAUG and reboot the MUD.

-- The following steps are optional and will guide you through
   creating a basic doom spell using SMAUGSPELLS.
   You should definitely fine tune the details.


43. Here are the commands I used to create a doom spell online:

sset create skill doom
sset doom type spell
sset doom target offensive
sset doom minpos 12
sset doom mana 50
sset doom beats 25
sset doom wearoff Your future seems bright once more.
sset doom hitchar $N's shoulders sag under the weight of an ominous doom.
sset doom hitvict Your shoulders sag under the weight of an ominous doom.
sset doom hitroom $N's shoulders sag under the weight of an ominous doom.
sset doom immchar $N shakes off your spell, defiantly mocking the fates that be.
sset doom affect affected '' 500 doomed

Like I said, you definitely want to fine tune this.

44. The command to save the spell is: sset save skill table

45. Once the spell is created and saved youll need to reboot the MUD once more.
    NOTE:  If you give the spell a name besides "doom" you'll probably want
    to change the ASSIGN_GSN from step 3.
    

Have fun and may you never be doomed yourself!