Re: [NEWBIE] [CODE] AFF_FLYING

From: Thomas Arp (t_arp@stofanet.dk)
Date: 01/02/03


From: "Jim" <realm@CITLINK.NET>
> Am attempting to add a flying spell and was wondering how? In
> constants.c, I see in "int movement_loss[] ="  a /* Flying*/ entry for
> loss of one movement point. And in
> "/* SECT_ */
> const char *sector_types[] = {" there is an "In Flight" entry. Is there
> somewhere I can go to learn how to "tie" flying in to AFF_FLY?
> Thank you for any advice/help and sorry for such a newbie question...

In do_simple_move() in act.movement.c find


  /* move points needed is avg. move loss for src and destination sect type
*/
  need_movement = (movement_loss[SECT(IN_ROOM(ch))] +
     movement_loss[SECT(EXIT(ch, dir)->to_room)]) / 2;


Change to:
(add new var: int flying=FALSE;)

  /* set the flying var - note ; on end */
  if ((flying = AFF_FLAGGED(ch, AFF_FLY)) ||
      (flying = affected_by_spell(ch, SPELL_FLY)));

  if (SECT(EXIT(ch, dir)->to_room) == SECT_FLY) && !flying ) {
    send_to_char(ch, "Grow some wings first!\r\n");
    return;
  }

  /* move points needed is avg. move loss for src and destination sect type
*/
  /* unless you're flying */
  if (flying)
    need_movement=1;
  else
    need_movement = (movement_loss[SECT(IN_ROOM(ch))] +
       movement_loss[SECT(EXIT(ch, dir)->to_room)]) / 2;

As you see, all computations and limitations regarding movement, sectors
etc.
happen in do_simple_move(). I'd suggest you learn to use grep. In this case
grep would show you that movement_loss is used only in these two lines...

Welcor

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   | Newbie List:  http://groups.yahoo.com/group/circle-newbies/   |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 06/26/03 PDT