Re: [NEWBIE] Leech command.

From: Daniel A. Koepke (dkoepke@circlemud.org)
Date: 09/18/02


On Wed, 18 Sep 2002, Peter d wrote:

I'm assuming that this command is only going to be given to your
immortals, and not to players in general.  (If this is not true, then
there are obvious design problems with a function that does unmitigated
damage to a victim, without costing the attacker.)

>         struct char_data *victim;
>    char buf[MAX_INPUT_LENGTH];

(0) Indentation is important.  It doesn't matter _what_ style you use, as
long as it's clean and consistent.  If it differs from CircleMUD's style,
use a program like GNU's indent to automatically reformat the code.  Good
coding style will save you more time than you can imagine.


>   else if (!(victim = get_char_vis(ch, argument, NULL, FIND_CHAR_WORLD)))
>         send_to_char(ch, NOPERSON);

(1) You probably don't want to let someone leech from anyone in the world,
regardless of distance.  Thus, you probably want to use FIND_CHAR_ROOM.
You also fail to check if the victim is an immortal and so should not be
leeched from:

  else if (GET_LEVEL(victim) >= LVL_IMMORT)
    send_to_char(ch, "Tsk.  Tsk.\r\n");


>   else {
>   if (ch == victim){
>                 send_to_char(ch, "Well, that wasn't so smart, was it?");
>       return;
>       }

(2) There's no reason to nest this.  You also forgot the CRLF at the end
of the line:

  else if (ch == victim)
    send_to_char(ch, "Well, that wasn't so smart, was it?\r\n");
  else {
    /* ...rest of your code... */
  }


> and a second question.. what is the structure of act()?

Look at the documentation included with CircleMUD.  Specifically,
doc/act.pdf.

-dak

--
   +---------------------------------------------------------------+
   | 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/25/03 PDT