question about db.c

Login to reply  Page: « < 1 of 1 > »
12 Feb 2010 - 03:082331
question about db.c
What is going on here?

In ....

struct char_data *read_mobile(mob_vnum nr, int type);

  if (!mob->points.max_hit) {
    mob->points.max_hit = dice(mob->points.hit, mob->points.mana) +
      mob->points.move;
  } else
    mob->points.max_hit = rand_number(mob->points.hit, mob->points.mana);

I understand how the first part works:
if (!mob->points.max_hit) {
    mob->points.max_hit = dice(mob->points.hit, mob->points.mana) +
      mob->points.move;

because movement/mana is not used for mobiles, they use it to store the HP dice, etc.

But what about the second part:
} else
    mob->points.max_hit = rand_number(mob->points.hit, mob->points.mana);

In fact I don't understand why it's checking the value of mob->points.max_hit at all.

Can someone explain this?


__________________
The Augmented Dimension 2.0
mud.themudhost.net port 5000

The Hidden Grotto
(Currently being patched up from Circle 3.0 to tba3.62)
Old version: a-d.codewarp.org 8229
Progress: http://a-d.codewarp.org/~schlittk/grotto_changelog.txt

Last edited by Kyle (12 Feb 2010 - 03:33)
12 Feb 2010 - 03:342332
In db.c ....

void parse_simple_mob(FILE *mob_f, int i, int nr)

  /* max hit = 0 is a flag that H, M, V is xdy+z */
  GET_MAX_HIT(mob_proto + i) = 0;
  GET_HIT(mob_proto + i) = t[3];
  GET_MANA(mob_proto + i) = t[4];
  GET_MOVE(mob_proto + i) = t[5];

It looks like they are setting the max_hit to 0 so that the proper code will get executed in the post above.

But as far as I know there are only two types of mobs: simple, and enhanced.

But if we look at the code in

void parse_enhanced_mob(FILE *mob_f, int i, int nr)

void parse_enhanced_mob(FILE *mob_f, int i, int nr)
{
  char line[READ_SIZE];

  parse_simple_mob(mob_f, i, nr);

  while (get_line(mob_f, line)) {
    if (!strcmp(line, "E"))
      /* End of the enhanced section. */
      return;
    else if (*line == '#') {
      /* We've hit the next mob, maybe? */
      log("SYSERR: Unterminated E section in mob #%d", nr);
      exit(1);
    } else
      parse_espec(line, i, nr);
  }

  log("SYSERR: Unexpected end of file reached after mob #%d", nr);
  exit(1);
}

It calls parse_simple_mob() too! So it seems like max_hit will always be set to 0
for every prototype mob that is born. So the "else" code in the original post is never
executed. Is it safe to remove?


__________________
The Augmented Dimension 2.0
mud.themudhost.net port 5000

The Hidden Grotto
(Currently being patched up from Circle 3.0 to tba3.62)
Old version: a-d.codewarp.org 8229
Progress: http://a-d.codewarp.org/~schlittk/grotto_changelog.txt
14 Feb 2010 - 13:282337
Quote Kyle:
So it seems like max_hit will always be set to 0
for every prototype mob that is born. So the "else" code in the original post is never
executed. Is it safe to remove?

I'm pretty sure that the PARSE_X_MOB code is only called on initialization of the mud to create the mob list (rnums).

Other functions, like void reset_zone (db.c) and ACMD(do_load) (act.wizard.c) call read mobile directly.

I don't think you'll notice much of a change if you remove that bit of code, in fact I commented it out and the mud compiles and runs just fine.

It appears that this may be an artifact from a previous version, where max_hit could be either #d#+# or a set number.


15 Feb 2010 - 19:312342
Yeah, I changed it to the latter on ugradMUD, that way the mana points are freed up to be used for mobile spells.


__________________
The Augmented Dimension 2.0
mud.themudhost.net port 5000

The Hidden Grotto
(Currently being patched up from Circle 3.0 to tba3.62)
Old version: a-d.codewarp.org 8229
Progress: http://a-d.codewarp.org/~schlittk/grotto_changelog.txt
Login to reply  Page: « < 1 of 1 > »