[Code] shadow/vampire SPECIAL

From: Jared Buckley (jaredb@TI.COM)
Date: 08/28/97

For what it's worth, here is my code for a shadow SPECIAL.
Upon sunrise, if the mob isn't in a DARK room, it dies.  Setup
requires the usual:



        ASSIGNMOB( xxxx, shadow );

in spec_assign.c.

spec_procs.c requires a reference to the external fn die():

        void die( struct char_data * ch );

I believe that I have tested this for all situations except for
what would happen if the sun rose during a fight.  Let me know
if you dig up any bugs I missed.  Thanks,



SPECIAL( shadow )

  Having the shadow's special proc make a call to destroy itself
  is tricky.  The values passed into the ch and me parameters of
  the fn, differ depending on what caused the call.  If the SPECIAL
  is called as a result of a player's action, the value of ch
  references the player, and me references the mob.  However, if the
  call is made from mobile_activity() in mobact.c or another similar
  fn, both ch and me reference the mob.  Care must be taken not
  to accidently kill the player or other mobs in the room.

  Also mobile_activity() causes the mud to crash when the mob
  it called a special for is extracted.  For this reason, if
  the call originated from mobile_activity(), we mortally wound
  the mob and leave it for dead.  It is assumed that if ch
  references a mob, then we need to avoid calling die().
  Note this might break down if this mob is fighting another mob.
  (see below)

  This has not been tested under fighting conditions; I don't
  know what will happen if you're fighting a shadow when the
  sun comes up.  When fight calls the mob special proc it passes
  ch and me the reference to the mob, similar to mobile_activity().
  ( perform_violence in fight.c )  -jrb 8/28/97

  struct char_data *npc;
  int player_cmd;

  /* start off by assuming this call is a result of mobile_activity() */
  player_cmd = 0;
  npc = ch;

  /* check our assumption and modify premise if necessary */
  if ( !IS_NPC(npc) )
    npc = me;
    player_cmd = 1;

  /* Is it night or is the mob in a dark room? */
  if ( (time_info.hours < 6) || (time_info.hours > 20 ) ||
       IS_DARK( npc->in_room ) )
    return( FALSE );

  /* if exposed to light of day...kill mob */
  if ( !player_cmd )
    GET_HIT( npc ) = -10;
    act( "$n hisses in agony and withers away as the sun hits $e!",
         FALSE, npc, 0, 0, TO_ROOM );
    die( npc );

  return( FALSE );


     | Ensure that you have read the CircleMUD Mailing List FAQ:  |
     | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html |

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