Mob race problem, pls look

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
2 years 6 days ago - 2 years 6 days ago #6255 by JTP
Mob race problem, pls look was created by JTP
Found the npc race snippet on tbamud site, added it.

6) Position : Standing
7) Default : Standing
8) Attack : blast
0) Race : Mortally wounded
9) Stats Menu...

Why do i get mortally wounded after Race : ?

Other of the old excisting mobs says: 0) Race : Dragon
or 0) Race : Undead
when i edit them the first time after adding npc race, i have never before had npc races.


New mob edits says 0) Race : Undefined as it should

1. Open structs.h and search class_other and remove this block of code:

/* NPC classes (currently unused - feel free to implement!) */
#define CLASS_OTHER       0    /**< NPC Class Other (or undefined) */
#define CLASS_UNDEAD      1    /**< NPC Class Undead */
#define CLASS_HUMANOID    2    /**< NPC Class Humanoid */
#define CLASS_ANIMAL      3    /**< NPC Class Animal */
#define CLASS_DRAGON      4    /**< NPC Class Dragon */
#define CLASS_GIANT       5    /**< NPC Class Giant */

2. Where the above block of code was add this:

/* NPC classes (currently unused - feel free to implement!) */
#define CLASS_NPC_UNDEFINED   0    /**< NPC Class Other (or undefined) */
#define CLASS_NPC_UNDEAD      1    /**< NPC Class Undead */
#define CLASS_NPC_HUMANOID    2    /**< NPC Class Humanoid */
#define CLASS_NPC_ANIMAL      3    /**< NPC Class Animal */
#define CLASS_NPC_DRAGON      4    /**< NPC Class Dragon */
#define CLASS_NPC_GIANT       5    /**< NPC Class Giant */

#define NUM_NPC_CLASSES       6    /** < Total NPC Classes */

3. close structs.h and open constants.c

4. search sector_types and under that block of code add this:

/* NPC Races
Must be in same order as races in structs.h
*/

const char *npc_races[] = {
        "Undefined",
        "Undead",
        "Humanoid",
        "Animal",
        "Dragon",
        "Giant",
        "\n"
};

5. close constants.c 


and open constants.h

6. search sector_types and under it add:

extern const char *npc_races[];

7. close constants.h


8. open oasis.h, search MEDIT_SPELL, and under it add:

#define MEDIT_RACE                      40

9. close oasis.h


10. open medit.c, search: medit_disp_menu and under it add:

static void medit_disp_races(struct descriptor_data *d);

11. search medit_disp_menu and find this line: "%s8%s) Attack    : %s%s\r\n" under it add:
          "%s0%s) Race      : %s%s\r\n"

12. Still in medit_disp_menu find this line:  grn, nrm, yel, attack_hit_text[(int)GET_ATTACK(mob)].singular, under it add:

          grn, nrm, yel, npc_races[(int)GET_CLASS(mob)],


13. After the medit_disp_menu function add this:

/* Display races */
static void medit_disp_races(struct descriptor_data *d)
{
  get_char_colors(d->character);
  clear_screen(d);
  column_list(d->character, 0, npc_races, NUM_NPC_CLASSES, TRUE);
  write_to_output(d, "Enter Race number : ");
}



14. search case '8'(Note: this is the case '8' that sets up olc_mode(d) = MEDIT_ATTACK) and under that block of code add this:

    case '0':
        OLC_MODE(d) = MEDIT_RACE;
        medit_disp_races(d);
        return;

15. search case MEDIT_ATTACK: and under it add:

        case MEDIT_RACE:
                GET_CLASS(OLC_MOB(d)) = LIMIT(i - 1, 0, NUM_NPC_CLASSES - 1);
                break;


16. close medit.c and open genmob.c

17.  search write_mobile_record and find this block of code:

  fprintf(fd,   "%d %d\n"
                "%d %d %d\n",
                GET_GOLD(mob), GET_EXP(mob),
                GET_POS(mob), GET_DEFAULT_POS(mob), GET_SEX(mob)

replace that block with this:

  fprintf(fd,   "%d %d\n"
                "%d %d %d %d\n",
                GET_GOLD(mob), GET_EXP(mob),
                GET_POS(mob), GET_DEFAULT_POS(mob), GET_SEX(mob), GET_CLASS(mob)




18. close genmob.c and open genolc.c

19. search: export_mobile_record, and find this block of code:


  fprintf(fd,   "%d %d\n"
                "%d %d %d\n",
                GET_GOLD(mob), GET_EXP(mob),
                GET_POS(mob), GET_DEFAULT_POS(mob), GET_SEX(mob)


change it to:



  fprintf(fd,   "%d %d\n"
                "%d %d %d %d\n",
                GET_GOLD(mob), GET_EXP(mob),
                GET_POS(mob), GET_DEFAULT_POS(mob), GET_SEX(mob), GET_CLASS(mob)


19. Close genolc.c and open db.c
 

20. search get_sex(it takes you right to where we need to be) and find this block of code:

  if (sscanf(line, " %d %d %d ", t, t + 1, t + 2) != 3) {
    log("SYSERR: Format error in last line of mob #%d\n"
        "...expecting line of form '# # # '", nr);
    exit(1);
  }

  GET_POS(mob_proto + i) = t[0];
  GET_DEFAULT_POS(mob_proto + i) = t[1];
  GET_SEX(mob_proto + i) = t[2];

  GET_CLASS(mob_proto + i) = 0;


and change that block of code to this:

        t[4] = sscanf(line, " %d %d %d %d ", t, t + 1, t + 2, t + 3);

        if(t[4] !=4 && t[4] != 3) {
                log("SYSERR: format error in last line of mob #%d\n"
                "...explecting line of form '# # # #'", nr);
                exit(1);
        }

  GET_POS(mob_proto + i) = t[0];
  GET_DEFAULT_POS(mob_proto + i) = t[1];
  GET_SEX(mob_proto + i) = t[2];
  GET_CLASS(mob_proto + i) = t[3];

  //GET_CLASS(mob_proto + i) = 0; /* Comment this line out or it wont save your classes*/


21. close and compile.


Also

In stat i added:
if (IS_MOB(k)) {
send_to_char(ch, "Keyword: %s, VNum: [%5d], RNum: [%5d], Race: [%5d]\r\n", k->player.name, GET_MOB_VNUM(k), GET_MOB_RNUM(k), GET_CLASS(k));

Stat mob says:
Race: [ 5]

5 is giant, but how do i get it to say giant and not 5 ?
Last edit: 2 years 6 days ago by JTP.

Please Log in or Create an account to join the conversation.

More
2 years 6 days ago #6256 by thomas
Replied by thomas on topic Mob race problem, pls look
About the strange "default" values - in db.c, you need to zero out the t[3] variable before the sscanf:
t[3] = 0;
t[4] = sscanf(line, " %d %d %d %d ", t, t + 1, t + 2, t + 3);
This is because sscanf doesn't write anything there if there's no existing data in that line. Then it will reuse t[3] from a little higher up in the file, and you end up with strange results.

To get out a name instead of a number, look it up in the corresponding table:
send_to_char(ch, "Keyword: %s, VNum: [%5d], RNum: [%5d], Race: [%s]\r\n", k->player.name, GET_MOB_VNUM(k), GET_MOB_RNUM(k), npc_races[GET_CLASS(k)]);

Please Log in or Create an account to join the conversation.

  • JTP
  • Topic Author
  • Offline
  • Platinum Boarder
  • Platinum Boarder
More
2 years 6 days ago #6257 by JTP
Replied by JTP on topic Mob race problem, pls look
Thanks alot Thomas, worked like a charm

Please Log in or Create an account to join the conversation.

Time to create page: 1.115 seconds