Lightning Storms [by Axl]
Snippet Posted Wednesday, August 12th @ 11:30:05 PM, by George Greer in the Specials dept.
Updated May 6, 1997. Click the link below to read it or download it.

From: AxL <axl@mindwarp.plymouth.edu>
Subject: Random Lightning Storms


I realized I had never reposted the few updates I had made that
people suggested awhile ago. :)  Just some minor tidying up and such.
If you are a mud still in development, i.e. only having about 3-4 PC's
on at any given time, you are the only targets it'll cycle through, hence
the spam of lightning bolts.  There's several ways of dealing with this,
such as making it target NPC's too.  You can vary the percenatages, damage
values, etc... in weather.c

Please note:  I did _not_ write this.  As noted in the
comments, I ported it from EltaninMUD, which was done by Miikka.
I just don't wanna take or be given credit for something that is
not mine.

Enjoy.
--
-axl @)-->---   "Beneath the stain of time, the feeling disappears.
 axl@mindwarp    You are someone else.  I am still right here." - NIN


---- In comm.c ----


Around line 100, add:

void beware_lightning(void);



Around line 687, add:

  if (!(pulse % (SECS_PER_MUD_HOUR/3))){
    beware_lightning();
  }


--- In weather.c ---


Around line 24, add:

extern struct char_data *character_list; /* lightning */
extern struct room_data *world;
void die(struct char_data * ch);



Around line 36, add:

/* ported from Eltanin by AxL, 2feb97 */
/*  added by Miikka M. Kangas  8-14-91 (note this is called with own pulses!) *
/
/*   I was getting bored so I wanted to add some edge to weather.    */
void beware_lightning(void)
{
  int dam = 0;
  struct char_data *victim = NULL, *temp = NULL;
  char buf[256];

  if (!(weather_info.sky == SKY_LIGHTNING))
    return;   /*   go away if its not even stormy!   */

  if (!(number(0, 9) == 0))
    return;  /*  Bolt only 10% of time  */

  if (number(0,99) == 0) {   /* nobody targeted 99% */
    send_to_outdoor("You hear the clap of distant thunder.\n\r");
    return;
  }

  for (victim = character_list; victim; victim = temp) {
    temp = victim->next;
    if ( (OUTSIDE(victim) == TRUE) && (!IS_NPC(victim)) ) {  /* PCs only */
      if  ( (number(0, 9) == 0) ) {  /* hit 10%  */


/* damage routine here */

dam = number(1, (GET_MAX_HIT(victim) * 2));

if (IS_AFFECTED(victim, AFF_SANCTUARY))
          dam = MIN(dam, 18);  /* Max 18 damage when sanctuary */

dam = MIN(dam, 100);  /* no more than 100 hp per round */

dam = MAX(dam, 0);    /* no less than 0 hp per round */

if ((GET_LEVEL(victim) >= LVL_IMMORT) && !IS_NPC(victim))
        /* You can't damage an immortal! */
          dam = 0;

GET_HIT(victim) -= dam;

act("KAZAK! a lightning bolt hits $n.  You hear a sick sizzle.",
         TRUE, victim, 0, 0, TO_ROOM);

act("KAZAK! a lightning bolt hits you.  You hear a sick sizzle.",
         FALSE, victim, 0, 0, TO_CHAR);

        if (dam > (GET_MAX_HIT(victim) >> 2))
          act("That Really did HURT!", FALSE, victim, 0, 0, TO_CHAR);

        send_to_outdoor("*BOOM*  You hear the clap of thunder.\n\r");
        update_pos(victim);
        switch (GET_POS(victim)) {
          case POS_MORTALLYW:
            act("$n is mortally wounded, and will die soon, if not aided.",
             TRUE, victim, 0, 0, TO_ROOM);

    act("You are mortally wounded, and will die soon, if not aided.",
             FALSE, victim, 0, 0, TO_CHAR);
            break;

  case POS_INCAP:

    act("$n is incapacitated and will slowly die, if not aided.",
             TRUE, victim, 0, 0, TO_ROOM);

    act("You are incapacitated an will slowly die, if not aided.",
              FALSE, victim, 0, 0, TO_CHAR);
            break;

  case POS_STUNNED:
            act("$n is stunned, but will probably regain conscience again.",
              TRUE, victim, 0, 0, TO_ROOM);

    act("You're stunned, but will probably regain conscience again.",
              FALSE, victim, 0, 0, TO_CHAR);
            break;
          case POS_DEAD:
            act("$n is dead! R.I.P.", TRUE, victim, 0, 0, TO_ROOM);
            act("You are dead!  Sorry...", FALSE, victim, 0, 0, TO_CHAR);
            break;
          default:  /* >= POS_SLEEPING */
            if (GET_HIT(victim) < (GET_MAX_HIT(victim) >> 2)) {
              act("You wish that your wounds would stop BLEEDING that much!",
              FALSE,victim,0,0,TO_CHAR);

    }  /* if BLEEDING */
            break;
        } /* switch */

        if (GET_POS(victim) == POS_DEAD) {
          sprintf(buf, "Thunderstorm killed %s", GET_NAME(victim));
          log(buf);
          die(victim);
        } /* of death */
        return;
      } else { /* number(0,10) */
          act("KAZAK! a lightning bolt hits nearby.",
            FALSE, victim, 0, 0, TO_ROOM);
          act("KAZAK! a lightning bolt hits nearby.",
            FALSE, victim, 0, 0, TO_CHAR);
          send_to_outdoor("*BOOM*  You hear the clap of thunder.\n\r");
          return;    /*  only 1 bolt at a time   */
      }
    }  /*  if outside=true */
  } /* of for victim hunt */
} /* of procedure */


<< Liblist: Room/Object/Mob listing [by Stormrider] | Reply | View as text | Flattened | Listen Skill [by Ted Dubroff] >>

 


Related Links
  download
Related Articles
More by greerga
 
 

CircleMUD Snippets
 
Note: Not all of these snippets will work perfectly with your version of code, so be prepared to fix one or two bugs that may arise, and please let me know what you needed to do to fix it. Sending a corrected version is always welcome.
Finally, if you wish to use any of the snippets from this page, you are more than welcome, just mention the authors in your credits. If you wish to release any of these snippets to the public on another site, contact me FIRST.