Re: Quests Code

From: Mike Breuer (
Date: 04/04/01

>     for (mcounter = 0; mcounter < 99; mcounter ++)
>     {
>         r_num = number(1, top_of_mobt - 1);
>          if ( (vsearch = read_mobile(r_num, REAL)) != NULL)
>          {

-- snip --

>     if(chance(50) && vsearch != NULL) /* chance that a quest will be
> generated
> */

Offhand, I would guess that your odds of finding the proper mob aren't high
enough.  You make 99 searches of the mob table, but how many mobs are
defined?  How many of those have the MOB_QUEST flag?  If you get past that
and your level restrictions, there is still a 50% chance that the mob will
be tossed out.  You further risk the chance that the selected mob is not
currently in the game, and so is tossed out in that case as well.

You might want to refine your top "for" loop to improve your odds of finding
a qualified mob.  Suggestions are:

for ( mcounter = 0; mcounter < top_of_mobt; mcounter++)

...or leave it at 99 but decrement mcounter when you find a mob that doesn't
have the MOB_QUEST flag (WARNING:  This would cause an infinite loop if you
do not have any mobs with the MOB_QUEST flag).

...or build a table of quest mobs, and randomly select from that.

...or, use the following construct:

for (mcounter = 0; mcounter < top_of_mobt; mcounter++)
  if  (!(vsearch = read_mobile(mcounter, REAL))) continue;
  if (!MOB_FLAGGED(vsearch, MOB_QUEST) ||
      level_diff > 10 || level_diff < -5 || number(0, 9)) continue;

The number(0, 10) is arbitrary, and might be adjusted depending on how many
types of MOB_QUEST mobiles you have defined.


   | FAQ: |
   | Archives: |

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