Re: [CODE][NEWBIE] Bragging NPC's compiler error

From: Carlos Myers (dhstranger@hotmail.com)
Date: 06/15/01


From: "William Matthews" <trutone@NETZERO.NET>
> Using Borland C++ under Win98, release 30bpl18
>
> I have received the following errors from comm.c when attempting to
compile:

Why is this even in comm.c?  comm.c is for socket handling and port I/O.
This should go in act.comm.c.  Don't tell me we have a rogue snippet
modifying comm.c when it shouldn't.

*checks the archives*

Yeap, rogue snippet.  So let's try to rewrite this snippet on the fly and
clean some things up along the way.

> Code for comm.h is:
>
> void    brag(struct char_data *ch, struct char_data *victim);

This prototype is unnecessary since we've also added the prototype to
fight.c

> Code for fight.c is:
>
> /* External procedures */
> void brag(struct char_data * ch, struct char_data * victim);
>
> _Now call the brag fuction whenever an npc kills a player character.  I
> added it within the following conditional, and works like a charm.
>
>     if (!IS_NPC(victim)) {
>       sprintf(buf2, "%s killed by %s at %s", GET_NAME(victim),
GET_NAME(ch),
>        world[victim->in_room].name);
>       mudlog(buf2, BRF, LVL_IMMORT, TRUE);
>       brag(ch, victim);    /* <- Insert brag call here */
>       if (MOB_FLAGGED(ch, MOB_MEMORY))
>         forget(ch, victim);
>     }
>
> The code for comm.c file is:

This should go in act.comm.c instead.

void brag(struct char_data *ch, struct char_data *vict)
{
  /* Npc taunts slayed player characters.  Text goes out through gossip
     channel.  Muerte - telnet://betterbox.net:4000                     */

  struct descriptor_data *i;
  char brag[256];

  switch (number(0, 11)) {
  case 0:
    sprintf(brag, "$n brags, '%s was just too easy a kill!'",
GET_NAME(vict));
    break;
  case 1:
    sprintf(brag, "$n brags, '%s was a tasty dinner, now who's for desert?
Muhaha!'", GET_NAME(vict));
    break;
  case 2:
    sprintf(brag, "$n brags, 'Bahaha! %s should stick to Odif's
!'",GET_NAME(vict));
    break;
  case 3:
    sprintf(brag, "$n brags, '%s is now in need of some exp...Muhaha!'",
GET_NAME(vict));
    break;
  case 4:
    sprintf(brag, "$n brags, '%s needs a hospital now.
Muhaha!'",GET_NAME(vict));
    break;
  case 5:
    sprintf(brag, "$n brags, '%s's mother is a slut!  Muhaha!'",
GET_NAME(vict));
    break;
  case 6:
    sprintf(brag, "$n brags, '%s is a punk, hits like a swampfly. Bah.'",
GET_NAME(vict));
    break;
  case 7:
    sprintf(brag, "$n brags, '%s, your life force has just run
out...Muahaha!'", GET_NAME(vict));
    break;
  case 8:
    sprintf(brag, "$n brags, 'Bah, %s should stick to the newbie
zone!'",GET_NAME(vict));
    break;
  case 9:
    sprintf(brag, "$n brags, '%s, give me your daughter's number and I might
return your corpse.  Muhaha!'", GET_NAME(vict));
    break;
  case 10:
    sprintf(brag, "$n brags, 'Hey %s!  Come back, you dropped your corpse!
Muahaha'", GET_NAME(vict));
    break;
  case 11:
    sprintf(brag, "$n brags, 'I think %s wears pink chainmail.  Fights like
a girl!  Muhaha!'", GET_NAME(vict));
    break;
  }

  for (i = descriptor_list; i; i = i->next) {
    if (STATE(i) == CON_PLAYING && i != ch->desc && i->character &&
        !PRF_FLAGGED(i->character, PRF_NOGOSS) &&
        !PLR_FLAGGED(i->character, PLR_WRITING) &&
        !ROOM_FLAGGED(i->character->in_room, ROOM_SOUNDPROOF) &&
        AWAKE(i->character)) {

      send_to_char(CCRED(i->character, C_SPR), i->character);
      act(brag, FALSE, ch, 0, i->character, TO_VICT | TO_SLEEP);
      send_to_char(CCNRM(i->character, C_SPR), i->character);
    }
  }
}

Hope this helps.

Carlos Myers

--
   +---------------------------------------------------------------+
   | FAQ: http://qsilver.queensu.ca/~fletchra/Circle/list-faq.html |
   | Archives: http://post.queensu.ca/listserv/wwwarch/circle.html |
   +---------------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/05/01 PST