Re: mobact.c

From: Mike Stilson (mike@velgarian.sytes.net)
Date: 01/22/02


On Mon, Jan 21, 2002 at 07:40:32PM -0500, Zizazat Lazuras wrote:
>I answered my own question with more debugging. Code to follow:
>
>found = FALSE;
> switch (GET_CLASS(ch)) {
>   case CLASS_THIEF:
>     if (GET_POS(ch) == POS_STANDING && (!MOB_FLAGGED(ch, MOB_SPEC)) ) {
>       for (vict = world[ch->in_room].people; vict && !found; vict =
>vict->next_in_room)
>         if (GET_LEVEL(vict) < LVL_IMMORT && (ch != vict)) {
>           if (number(1, 100) <= GET_MSKILL(ch, SKILL_STEAL)) {
>             npc_steal(ch, vict);
>           }
>           found = TRUE;
>           continue;
>         }
>     }
>   break;
> }
>
>Of course GET_MSKILL doesn't work for most people. But you get the idea.
>There is a skill check to see if the mob is even interested in trying to
>steal from someone. This is functional, and opens the door for me to do much
>cooler things since I have the functionallity :)
>
>I am going to scrap npc_steal and use do_steal, for starters.
>
>I do wonder though if anyone can give me ideas/pointers about trying to
>choose a random vict from world[ch->in_room].people. Right now the theif
>always goes after the first person. Would I do something like mob scavenger
>code, where it would try to determine the best_vict from world[].people?

(mailer code)
struct char_data *rand_vict(struct char_data *ch)
{
    int i = 0, tmp;
    struct char_data *vict;

    /* count the people in the room */
    for(i = 0, vict = world[ch->in_room].people; vict; vict = vict->next, i++);

    /* pick one */
    tmp = number(0,i);

    /* count up to it */
    for(i = 0, vict = world[ch->in_room].people; i < tmp; vict = vict->next, i++);

    return(vict);
}

sorta sloppy but it works.

-me

--
   +---------------------------------------------------------------+
   | 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