Re: [Code] simple_mob, adding new value

From: Skylar (skylar@ifconfig.intserv.com)
Date: 10/13/96


On Sun, 13 Oct 1996, annick elziere wrote:

>     Im adding a new value to parse_simple_mob in db.c
> I added and everything compiles, but i forgot one thing
> every mob on my mob has a blank space for the value.  
> Does anyone have an idea what i could do to add an extra
> 0 to the part of the mob file: 8 8 1 0<-- new value

Whats this, pos, default and sex?^^^^^ Must be...

> Or, in db.c what could i do, if there is nothing there, to
> just set to 0?  I am not familliar with writeing to files

In db.c, parse_simple_mob() You want to make a slight modification to
how it reads in these vars, something like this..,

/* I think this is line 877 - just before it assigns position, default
   position and sex...*/

    get_line(mob_f, line);

    /* check for new variable ... bringing the total to 4 for that line */
    if (sscanf(line, " %d %d %d %d ", t, t + 1, t + 2, t + 3, t+4) == 4) {
    
    mob_proto[i].char_specials.position = t[0];
    mob_proto[i].mob_specials.default_pos = t[1];
    mob_proto[i].player.sex = t[2];
    /* new var goes here */
    mob_proto[i].YOUR.NEW.VARIABLE = t[3];
    } else {  /* didnt get 4 vars, so process it the normal way */
    /* stock code follows */
      if (sscanf(line, " %d %d %d %d ", t, t + 1, t + 2, t + 3) != 3) {
        fprintf(stderr, "Format error in mob #%d, second line after S flag\n"
  	      "...expecting line of form '# # #'\n", nr);
      }

      mob_proto[i].char_specials.position = t[0];
      mob_proto[i].mob_specials.default_pos = t[1];
      mob_proto[i].player.sex = t[2];
    } /* <-- dont forget to close the new 'else' */


That should let you read both "old" and "new" mobs without a problem...
you might want to (if you have olc) save all the mobs from inside the
game after it boots and remove this code for some just expecting the
new normal number of variables on that line, unless you want to be compat
with standard area files that is... it will get pretty hairy if you
continue to add these little hacks to read in different types of mobs -
I have tons of this spagetti in my own code... its pretty ugly/kludgy.
On the other hand, you can go pretty far afield from the standards and
alwas maintain compatibililty... :)


-Sky

+-----------------------------------------------------------+
| Ensure that you have read the CircleMUD Mailing List FAQ: |
|   http://cspo.queensu.ca/~fletcher/Circle/list_faq.html   |
+-----------------------------------------------------------+



This archive was generated by hypermail 2b30 : 12/18/00 PST