Re: [Circle] [Code] falling_char

From: Ron Hensley (ron@cross.dmv.com)
Date: 11/17/96


Brian,

Heres a working version of the code you posted a while back.
Fixes the problem with the 'for' loop never actually changing.
Fixes the problem that if there is no dir_option[5] your mud would crash as
 the code never checked that dir_option[5] was not NULL before trying to
 access world[ch->in_room].cir_option[5]->to_room
Fixes problem that the CASEs were upside down, and none had break
 statements
Adds making the player actually look at each room as they drop, or else
 they wouldnt get a feeling of dropping, theyd only get a message to know
 they even moved
Still a problem if you are in the AIR and there is no down exit you will
 stop in mid air. With judicious building, itll work i guess, that being 
 a down door from any 'in the air' room

void fall_char(struct char_data *ch) {

  int rooms_fallen, down_room, dam;

  if (IS_NPC(ch))
    return;

  rooms_fallen = 1; /* Falling in the same room is considered 1 room */

  if (world[ch->in_room].dir_option[5]) {
    down_room = world[ch->in_room].dir_option[5]->to_room;
    for (; down_room; down_room=world[ch->in_room].dir_option[5]->to_room) {
      rooms_fallen++;
      send_to_char("You fall!\r\n", ch);
      char_from_room(ch);  
      char_to_room(ch, down_room);  
      look_at_room(ch, 0); 
      if (!(world[ch->in_room].dir_option[5]))
        break;
    }
  }
  switch(rooms_fallen) {
    case 1:
      dam = GET_MAX_HIT(ch) * .9;
      break;
    case 2:
      dam = GET_MAX_HIT(ch) * .66;
      break;
    case 3:   
      dam = GET_MAX_HIT(ch) * .3;
      break;
    case 4:
      dam = GET_MAX_HIT(ch) * .2;
      break;
    default:
      dam = GET_MAX_HIT(ch);  /* ouch */
      break;
  }
  
  GET_HIT(ch) = dam;
  send_to_char("You hit the ground with a loud THUD!\r\n", ch);
  act("$n falls onto the ground with a THUD!", FALSE, ch, 0, 0, TO_ROOM);
};



    *******************************************************************
    *   Ron Hensley                     ron@dmv.com                   *
    *   Systems Administrator           http://www.dmv.com/~ron       *
    *                                   PGP Key at WWW Page           *
    *   DelMarVa OnLine                 749-7898 Ext. 403             *
    *******************************************************************

+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



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