/* I'm not particularly pleased with the MOB/PLR hoops that have to be jumped * through but it hardly calls for a completely new variable. Ideally it would * be its own list, but that would change the '->next' pointer, potentially * confusing some code. -gg This doesn't handle recursive extractions. */ void extract_pending_chars(void) { struct char_data *vict, *next_vict, *prev_vict; if (extractions_pending < 0) log("SYSERR: Negative (%d) extractions pending.", extractions_pending); for (vict = character_list, prev_vict = NULL; vict && extractions_pending; vict = next_vict) { next_vict = vict->next; if (MOB_FLAGGED(vict, MOB_NOTDEADYET)) REMOVE_BIT_AR(MOB_FLAGS(vict), MOB_NOTDEADYET); else if (PLR_FLAGGED(vict, PLR_NOTDEADYET)) REMOVE_BIT_AR(PLR_FLAGS(vict), PLR_NOTDEADYET); else { /* Last non-free'd character to continue chain from. */ prev_vict = vict; continue; } extract_char_final(vict); extractions_pending--; if (prev_vict) prev_vict->next = next_vict; else character_list = next_vict; } if (extractions_pending > 0) log("SYSERR: Couldn't find %d extractions as counted.", extractions_pending); extractions_pending = 0; }
/* Why do we do this? Because trying to iterate over the character list with * 'ch = ch->next' does bad things if the current character happens to die. The * trivial workaround of 'vict = next_vict' doesn't work if the _next_ person * in the list gets killed, for example, by an area spell. Why do we leave them * on the character_list? Because code doing 'vict = vict->next' would get * really confused otherwise. */ void extract_char(struct char_data *ch) { char_from_furniture(ch); clear_char_event_list(ch); if (IS_NPC(ch)) SET_BIT_AR(MOB_FLAGS(ch), MOB_NOTDEADYET); else SET_BIT_AR(PLR_FLAGS(ch), PLR_NOTDEADYET); extractions_pending++; }
/* Display main menu. */ static void medit_disp_menu(struct descriptor_data *d) { struct char_data *mob; char flags[MAX_STRING_LENGTH], flag2[MAX_STRING_LENGTH]; mob = OLC_MOB(d); get_char_colors(d->character); clear_screen(d); write_to_output(d, "-- Mob Number: [%s%d%s]\r\n" "%s1%s) Sex: %s%-7.7s%s %s2%s) Keywords: %s%s\r\n" "%s3%s) S-Desc: %s%s\r\n" "%s4%s) L-Desc:-\r\n%s%s\r\n" "%s5%s) D-Desc:-\r\n%s%s\r\n", cyn, OLC_NUM(d), nrm, grn, nrm, yel, genders[(int)GET_SEX(mob)], nrm, grn, nrm, yel, GET_ALIAS(mob), grn, nrm, yel, GET_SDESC(mob), grn, nrm, yel, GET_LDESC(mob), grn, nrm, yel, GET_DDESC(mob) ); sprintbitarray(MOB_FLAGS(mob), action_bits, AF_ARRAY_MAX, flags); sprintbitarray(AFF_FLAGS(mob), affected_bits, AF_ARRAY_MAX, flag2); write_to_output(d, "%s6%s) Position : %s%s\r\n" "%s7%s) Default : %s%s\r\n" "%s8%s) Attack : %s%s\r\n" "%s9%s) Stats Menu...\r\n" "%sA%s) NPC Flags : %s%s\r\n" "%sB%s) AFF Flags : %s%s\r\n" "%sS%s) Script : %s%s\r\n" "%sW%s) Copy mob\r\n" "%sX%s) Delete mob\r\n" "%sQ%s) Quit\r\n" "Enter choice : ", grn, nrm, yel, position_types[(int)GET_POS(mob)], grn, nrm, yel, position_types[(int)GET_DEFAULT_POS(mob)], grn, nrm, yel, attack_hit_text[(int)GET_ATTACK(mob)].singular, grn, nrm, grn, nrm, cyn, flags, grn, nrm, cyn, flag2, grn, nrm, cyn, OLC_SCRIPT(d) ?"Set.":"Not Set.", grn, nrm, grn, nrm, grn, nrm ); OLC_MODE(d) = MEDIT_MAIN_MENU; }
/** * For the .list command. * * @param char_data *mob The thing to list. * @param bool detail If TRUE, provide additional details * @return char* The line to show (without a CRLF). */ char *list_one_mobile(char_data *mob, bool detail) { static char output[MAX_STRING_LENGTH]; char flags[MAX_STRING_LENGTH]; bitvector_t show_flags = MOB_BRING_A_FRIEND | MOB_SENTINEL | MOB_AGGRESSIVE | MOB_MOUNTABLE | MOB_ANIMAL | MOB_AQUATIC | MOB_NO_ATTACK | MOB_SPAWNED | MOB_CHAMPION | MOB_FAMILIAR | MOB_EMPIRE | MOB_CITYGUARD | MOB_GROUP | MOB_HARD | MOB_DPS | MOB_TANK | MOB_CASTER | MOB_VAMPIRE | MOB_HUMAN; if (detail) { if (IS_SET(MOB_FLAGS(mob), show_flags)) { sprintbit(MOB_FLAGS(mob) & show_flags, action_bits, flags, TRUE); } else { *flags = '\0'; } snprintf(output, sizeof(output), "[%5d] %s (%s) %s", GET_MOB_VNUM(mob), GET_SHORT_DESC(mob), level_range_string(GET_MIN_SCALE_LEVEL(mob), GET_MAX_SCALE_LEVEL(mob), 0), flags); } else { snprintf(output, sizeof(output), "[%5d] %s", GET_MOB_VNUM(mob), GET_SHORT_DESC(mob)); } return output; }
/* * Display mob-flags menu. */ void medit_disp_mob_flags(struct descriptor_data *d) { int i, columns = 0; get_char_colors(d->character); clear_screen(d); for (i = 0; i < NUM_MOB_FLAGS; i++) { sprintf(buf, "%s%2d%s) %-20.20s %s", grn, i + 1, nrm, action_bits[i], !(++columns % 2) ? "\r\n" : ""); SEND_TO_Q(buf, d); } sprintbit(MOB_FLAGS(OLC_MOB(d)), action_bits, buf1); sprintf(buf, "\r\nCurrent flags : %s%s%s\r\nEnter mob flags (0 to quit) : ", cyn, buf1, nrm); SEND_TO_Q(buf, d); }
/* Display mob-flags menu. */ static void medit_disp_mob_flags(struct descriptor_data *d) { int i, count = 0, columns = 0; char flags[MAX_STRING_LENGTH]; get_char_colors(d->character); clear_screen(d); /* Mob flags has special handling to remove illegal flags from the list */ for (i = 0; i < NUM_MOB_FLAGS; i++) { if (medit_illegal_mob_flag(i)) continue; write_to_output(d, "%s%2d%s) %-20.20s %s", grn, ++count, nrm, action_bits[i], !(++columns % 2) ? "\r\n" : ""); } sprintbitarray(MOB_FLAGS(OLC_MOB(d)), action_bits, AF_ARRAY_MAX, flags); write_to_output(d, "\r\nCurrent flags : %s%s%s\r\nEnter mob flags (0 to quit) : ", cyn, flags, nrm); }
int write_mobile_record(mob_vnum mvnum, struct char_data *mob, FILE *fd) { char ldesc[MAX_STRING_LENGTH], ddesc[MAX_STRING_LENGTH]; ldesc[MAX_STRING_LENGTH - 1] = '\0'; ddesc[MAX_STRING_LENGTH - 1] = '\0'; strip_cr(strncpy(ldesc, GET_LDESC(mob), MAX_STRING_LENGTH - 1)); strip_cr(strncpy(ddesc, GET_DDESC(mob), MAX_STRING_LENGTH - 1)); fprintf(fd, "#%d\n" "%s%c\n" "%s%c\n" "%s%c\n" "%s%c\n", mvnum, GET_ALIAS(mob), STRING_TERMINATOR, GET_SDESC(mob), STRING_TERMINATOR, ldesc, STRING_TERMINATOR, ddesc, STRING_TERMINATOR ); fprintf(fd, "%ld %ld %d E\n" "%d %d %d %dd%d+%d %dd%d+%d\n", MOB_FLAGS(mob), AFF_FLAGS(mob), GET_ALIGNMENT(mob), GET_LEVEL(mob), 20 - GET_HITROLL(mob), GET_AC(mob) / 10, GET_HIT(mob), GET_MANA(mob), GET_MOVE(mob), GET_NDD(mob), GET_SDD(mob), GET_DAMROLL(mob) ); 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) ); if (write_mobile_espec(mvnum, mob, fd) < 0) log("SYSERR: GenOLC: Error writing E-specs for mobile #%d.", mvnum); script_save_to_disk(fd, mob, MOB_TRIGGER); #if CONFIG_GENOLC_MOBPROG if (write_mobile_mobprog(mvnum, mob, fd) < 0) log("SYSERR: GenOLC: Error writing MobProgs for mobile #%d.", mvnum); #endif return TRUE; }
void medit_disp_mobflags_menu(struct descriptor_data *d) { int c; CLS(CH); for (c = 0; c < MOB_MAX; c += 2) { send_to_char(CH, "%2d) %-20s %2d) %-20s\r\n", c + 1, action_bits[c], c + 2, c + 1 < MOB_MAX ? action_bits[c + 1] : ""); } MOB_FLAGS(MOB).PrintBits(buf1, MAX_STRING_LENGTH, action_bits, MOB_MAX); send_to_char(CH, "Mob flags: %s%s%s\r\n" "Enter mob flag, 0 to quit:", CCCYN(CH, C_CMP), buf1, CCNRM(CH, C_CMP)); }
/* * Ideally, this function should be in db.c, but I'll put it here for * portability. */ void init_mobile(struct char_data *mob) { clear_char(mob); GET_HIT(mob) = GET_MANA(mob) = 1; GET_MAX_MANA(mob) = GET_MAX_MOVE(mob) = 100; GET_NDD(mob) = GET_SDD(mob) = 1; GET_WEIGHT(mob) = 200; GET_HEIGHT(mob) = 198; GET_MOB_WEIGHT(mob) = 1; mob->real_abils.str = mob->real_abils.intel = mob->real_abils.wis = 11; mob->real_abils.dex = mob->real_abils.con = mob->real_abils.cha = 11; mob->aff_abils = mob->real_abils; SET_BIT(MOB_FLAGS(mob), MOB_ISNPC); mob->player_specials = &dummy_mob; }
void do_mob_report (struct char_data *ch) { struct char_data *mob; FILE *reportfile; int i; if (!(reportfile = fopen("report.mob", "w"))) { mlog("SYSERR: Mob report file unavailable."); send_to_char ("Report.mob could not be generated.\r\n",ch); return; } sprintf(buf, "MOBS\n----\n"); for (i=0; i<top_of_mobt;i++) { mob=read_mobile(i, REAL); char_to_room(mob, 0); sprintf(buf+strlen(buf), "[%5d] %s Spec Proc: ", GET_MOB_VNUM(mob), GET_NAME(mob)); if (mob_index[GET_MOB_RNUM(mob)].func!=NULL) get_spec_name(GET_MOB_RNUM(mob), buf2,'m'); else sprintf(buf2, "none"); sprintf(buf+strlen(buf), "%s\n",buf2); sprintf(buf+strlen(buf),mob->player.description); sprintf(buf+strlen(buf),"Difficulty: %d XP: %d HP: %d Mana: %d Gold %d\n", GET_DIFFICULTY(mob), GET_EXP(mob), GET_MAX_HIT(mob), GET_MAX_MANA(mob), GET_GOLD(mob)); sprintf(buf+strlen(buf),"Passive Defense: %d Damage Reduction: %d ", GET_PD(mob), GET_REDUCTION(mob)); sprintf(buf+strlen(buf), "Attack Type: %s\n", attack_hit_text[mob->mob_specials.attack_type].singular); sprintbit(MOB_FLAGS(mob), action_bits, buf2, sizeof(buf2)); sprintf(buf+strlen(buf),"Flags: %s\n", buf2); sprintbit(AFF_FLAGS(mob), affected_bits, buf2, sizeof(buf2)); sprintf(buf+strlen(buf),"Affects: %s\n\n-------\n", buf2); extract_char(mob); fprintf(reportfile, buf); buf[0]='\0'; }/*for i=0...*/ fclose (reportfile); send_to_char ("report.mob printed\r\n",ch); }
/* Ideally, this function should be in db.c, but I'll put it here for portability. */ static void init_mobile(struct char_data *mob) { clear_char(mob); GET_HIT(mob) = GET_MANA(mob) = 1; GET_MAX_MANA(mob) = GET_MAX_MOVE(mob) = 100; GET_NDD(mob) = GET_SDD(mob) = 1; GET_WEIGHT(mob) = 200; GET_HEIGHT(mob) = 198; mob->real_abils.str = mob->real_abils.intel = mob->real_abils.wis = 11; mob->real_abils.dex = mob->real_abils.con = mob->real_abils.cha = 11; mob->aff_abils = mob->real_abils; GET_SAVE(mob, SAVING_PARA) = 0; GET_SAVE(mob, SAVING_ROD) = 0; GET_SAVE(mob, SAVING_PETRI) = 0; GET_SAVE(mob, SAVING_BREATH) = 0; GET_SAVE(mob, SAVING_SPELL) = 0; SET_BIT_AR(MOB_FLAGS(mob), MOB_ISNPC); mob->player_specials = &dummy_mob; }
/** * Creates a new mob entry. * * @param mob_vnum vnum The number to create. * @return char_data* The new mob's prototype. */ char_data *create_mob_table_entry(mob_vnum vnum) { void add_mobile_to_table(char_data *mob); char_data *mob; // sanity if (mob_proto(vnum)) { log("SYSERR: Attempting to insert mobile at existing vnum %d", vnum); return mob_proto(vnum); } CREATE(mob, char_data, 1); clear_char(mob); mob->vnum = vnum; SET_BIT(MOB_FLAGS(mob), MOB_ISNPC); // need this for some macroes add_mobile_to_table(mob); // save mob index and mob file now so there's no trouble later save_index(DB_BOOT_MOB); save_library_file_for_vnum(DB_BOOT_MOB, vnum); return mob; }
void convert_mobs_to_disk(int zone_num) { int i, rmob_num, zone, top; FILE *mob_file; char fname[64]; struct char_data *mob; struct mob_attacks_data *attack; struct mob_equipment_data *equipment; struct mob_action_data *action; MPROG_DATA *mob_prog; zone = zone_table[zone_num].number; top = zone_table[zone_num].top; sprintf(fname, "%s/%i.mob", MOB_PREFIX, zone); if (!(mob_file = fopen(fname, "w"))) { mudlog("SYSERR: OLC: Cannot open mob file!", 'G', COM_BUILDER, TRUE); return; } /*. Seach database for mobs in this zone and save em .*/ for (i = zone * 100; i <= top; i++) { rmob_num = real_mobile(i); if (rmob_num != -1) { if (fprintf(mob_file, "#%d\n", i) < 0) { mudlog("SYSERR: OLC: Cannot write mob file!\r\n", 'G', COM_BUILDER, TRUE); fclose(mob_file); return; } mob = (mob_proto + rmob_num); attack = GET_ATTACKS(mob); equipment = GET_EQUIP(mob); action = GET_ACTION(mob); mob_prog = mob_index[rmob_num].mobprogs; /*. Clean up strings .*/ strcpy(buf1, GET_LDESC(mob)); strip_string(buf1); if (GET_DDESC(mob)) { strcpy(buf2, GET_DDESC(mob)); strip_string(buf2); } else strcpy(buf2, ""); fprintf(mob_file, "%s~\n" "%s~\n" "%s~\n" "%s~\n" "%ld %ld %i X\n" "%d %d %i %dd%d+%d %dd%d+%d\n" "%d %d\n" /*. Gold & Exp are longs in my mud, ignore any warning .*/ "%d %d %d %d %d %d\n", GET_ALIAS(mob), GET_SDESC(mob), buf1, buf2, MOB_FLAGS(mob), AFF_FLAGS(mob), GET_ALIGNMENT(mob), GET_LEVEL(mob), GET_HITROLL(mob), GET_AC(mob) / 10, GET_HIT(mob), GET_MANA(mob), GET_MOVE(mob), GET_NDD(mob), GET_SDD(mob), GET_DAMROLL(mob), GET_GOLD(mob), GET_EXP(mob), GET_POS(mob), GET_DEFAULT_POS(mob), GET_SEX(mob), GET_CLASS(mob), GET_RACE(mob), GET_SIZE(mob)); while (attack) { fprintf(mob_file, "T %d %dd%d+%d %d\n", attack->attacks, attack->nodice, attack->sizedice, attack->damroll, attack->attack_type); attack = attack->next; } while (action) { fprintf(mob_file, "A %d %d %s\n", action->chance, action->minpos, action->action); action = action->next; } while (equipment) { fprintf(mob_file, "E %d %d %d %d\n", equipment->pos, equipment->chance, equipment->vnum, equipment->max); equipment = equipment->next; } /*. Deal with Extra stats in case they are there .*/ if ((GET_STR(mob) != 11) && (GET_STR(mob) < 19)) fprintf(mob_file, "Str: %d\n", (GET_STR(mob) * 5)); else if ((GET_STR(mob) > 18) && (GET_STR(mob) != 50)) fprintf(mob_file, "Str: 100\n"); if ((GET_DEX(mob) != 11) && (GET_DEX(mob) < 19)) { fprintf(mob_file, "Dex: %d\n", (GET_DEX(mob) * 5)); fprintf(mob_file, "Agi: %d\n", (GET_DEX(mob) * 5)); } else if ((GET_DEX(mob) > 18) && (GET_DEX(mob) != 50)) { fprintf(mob_file, "Dex: 100\n"); fprintf(mob_file, "Agi: 100\n"); } if ((GET_INT(mob) != 11) && (GET_INT(mob) < 19)) fprintf(mob_file, "Int: %d\n", (GET_INT(mob) * 5)); else if ((GET_INT(mob) > 18) && (GET_INT(mob) != 50)) fprintf(mob_file, "Int: 100\n"); if ((GET_WIS(mob) != 11) && (GET_WIS(mob) < 19)) fprintf(mob_file, "Wis: %d\n", (GET_WIS(mob) * 5)); else if ((GET_WIS(mob) > 18) && (GET_WIS(mob) != 50)) fprintf(mob_file, "Wis: 100\n"); if ((GET_CON(mob) != 11) && (GET_CON(mob) < 19)) fprintf(mob_file, "Con: %d\n", (GET_CON(mob) * 5)); else if ((GET_CON(mob) > 18) && (GET_CON(mob) != 50)) fprintf(mob_file, "Con: 100\n"); /*. Deal with Mob Progs .*/ while (mob_prog) { switch (mob_prog->type) { case IN_FILE_PROG: fprintf(mob_file, ">in_file_prog"); break; case ACT_PROG: fprintf(mob_file, ">act_prog"); break; case SPEECH_PROG: fprintf(mob_file, ">speech_prog"); break; case RAND_PROG: fprintf(mob_file, ">rand_prog"); break; case FIGHT_PROG: fprintf(mob_file, ">fight_prog"); break; case HITPRCNT_PROG: fprintf(mob_file, ">hitprcnt_prog"); break; case DEATH_PROG: fprintf(mob_file, ">death_prog"); break; case ENTRY_PROG: fprintf(mob_file, ">entry_prog"); break; case GREET_PROG: fprintf(mob_file, ">greet_prog"); break; case ALL_GREET_PROG: fprintf(mob_file, ">all_greet_prog"); break; case GIVE_PROG: fprintf(mob_file, ">give_prog"); break; case BRIBE_PROG: fprintf(mob_file, ">bribe_prog"); break; case SHOUT_PROG: fprintf(mob_file, ">shout_prog"); break; case HOLLER_PROG: fprintf(mob_file, ">holler_prog"); break; case TELL_PROG: fprintf(mob_file, ">tell_prog"); break; case TIME_PROG: fprintf(mob_file, ">time_prog"); break; } strcpy(buf1, mob_prog->arglist); strip_string(buf1); strcpy(buf2, mob_prog->comlist); strip_string(buf2); fprintf(mob_file, " %s~\n%s", buf1, buf2); mob_prog = mob_prog->next; if (!mob_prog) fprintf(mob_file, "~\n|\n"); else fprintf(mob_file, "~\n"); } } } fclose(mob_file); }
void write_mobs_to_disk(int zone) { int counter, realcounter; FILE *fp; struct char_data *mob; zone = real_zone(zone); int i; // ideally, this would just fill a VTable with vals...maybe one day sprintf(buf, "%s/%d.mob", MOB_PREFIX, zone_table[zone].number); fp = fopen(buf, "w+"); /* start running through all mobiles in this zone */ for (counter = zone_table[zone].number * 100; counter <= zone_table[zone].top; counter++) { /* write mobile to disk */ realcounter = real_mobile(counter); if (realcounter >= 0) { mob = mob_proto+realcounter; if (!strcmp("an unfinished mob", GET_NAME(mob))) continue; fprintf(fp, "#%ld\n", GET_MOB_VNUM(mob)); fprintf(fp, "Keywords:\t%s\n" "Name:\t%s\n" "RoomDesc:$\n%s\n~\n", mob->player.physical_text.keywords? mob->player.physical_text.keywords : "mob unnamed", mob->player.physical_text.name? mob->player.physical_text.name : "An unnamed mob", cleanup(buf2, mob->player.physical_text.room_desc? mob->player.physical_text.room_desc : "An unnamed mob is here.")); fprintf(fp, "LookDesc:$\n%s~\n", cleanup(buf2, mob->player.physical_text.look_desc? mob->player.physical_text.look_desc : "An unnamed mob is here.")); if (mob->mob_specials.arrive) fprintf(fp, "ArriveMsg:\t%s\n", mob->mob_specials.arrive); if (mob->mob_specials.leave) fprintf(fp, "LeaveMsg:\t%s\n", mob->mob_specials.leave); fprintf(fp, "MobFlags:\t%s\n" "AffFlags:\t%s\n" "Race:\t%s\n" "Gender:\t%s\n", MOB_FLAGS(mob).ToString(), AFF_FLAGS(mob).ToString(), npc_classes[(int)mob->player.race], genders[(int)mob->player.sex]); if (mob->char_specials.position != POS_STANDING) fprintf(fp, "Position:\t%s\n", position_types[(int)mob->char_specials.position]); if (mob->mob_specials.default_pos) fprintf(fp, "DefaultPos:\t%s\n", position_types[(int)mob->mob_specials.default_pos]); if (mob->mob_specials.attack_type != TYPE_HIT) fprintf(fp, "AttackType:\t%s\n", attack_types[mob->mob_specials.attack_type-TYPE_HIT]); fprintf(fp, "[ATTRIBUTES]\n" "\tBod:\t%d\n" "\tQui:\t%d\n" "\tStr:\t%d\n" "\tCha:\t%d\n" "\tInt:\t%d\n" "\tWil:\t%d\n" "\tMag:\t%d\n", GET_REAL_BOD(mob), GET_REAL_QUI(mob), GET_REAL_STR(mob), GET_REAL_CHA(mob), GET_REAL_INT(mob), GET_REAL_WIL(mob), mob->real_abils.mag / 100); fprintf(fp, "[POINTS]\n" "\tHeight:\t%d\n" "\tWeight:\t%d\n", mob->player.height, mob->player.weight); if (GET_LEVEL(mob) > 0) fprintf(fp, "\tLevel:\t%d\n", GET_LEVEL(mob)); if (int(GET_MAX_PHYSICAL(mob) / 100) != 10) fprintf(fp, "\tMaxPhys:\t%d\n", int(GET_MAX_PHYSICAL(mob) / 100)); if (int(GET_MAX_MENTAL(mob) / 100) != 10) fprintf(fp, "\tMaxMent:\t%d\n", int(GET_MAX_MENTAL(mob) / 100)); if (GET_BALLISTIC(mob) > 0) fprintf(fp, "\tBallistic:\t%d\n", GET_BALLISTIC(mob)); if (GET_IMPACT(mob) > 0) fprintf(fp, "\tImpact:\t%d\n", GET_IMPACT(mob)); if (GET_NUYEN(mob) > 0) fprintf(fp, "\tCash:\t%d\n", GET_NUYEN(mob)); if (GET_BANK(mob) > 0) fprintf(fp, "\tBank:\t%d\n", GET_BANK(mob)); if (GET_KARMA(mob) > 0) fprintf(fp, "\tKarma:\t%d\n", GET_KARMA(mob)); fprintf(fp, "[SKILLS]\n"); for (i = 0; i <= 8; i = i +2) if (mob->mob_specials.mob_skills[i]) fprintf(fp, "\t%s:\t%d\n", skills[mob->mob_specials.mob_skills[i]].name, mob->mob_specials.mob_skills[i+1]); fprintf(fp, "BREAK\n"); } // close if statement } // close for loop fprintf(fp, "END\n"); fclose(fp); write_index_file("mob"); }
/* * Display main menu. */ void medit_disp_menu(struct descriptor_data *d) { struct char_data *mob; mob = OLC_MOB(d); get_char_colors(d->character); clear_screen(d); sprintf(buf, "-- Mob Number: [%s%d%s]\r\n" "%s1%s) Sex: %s%-7.7s%s %s2%s) Alias: %s%s\r\n" "%s3%s) S-Desc: %s%s\r\n" "%s4%s) L-Desc:-\r\n%s%s" "%s5%s) D-Desc:-\r\n%s%s" "%s6%s) Level: [%s%4d%s], %s7%s) Alignment: [%s%4d%s]\r\n" "%s8%s) HR//SKY: [%s%4d%s], %s9%s) DR//FD: [%s%4d%s]\r\n" "%sA%s) NumDamDice: [%s%4d%s], %sB%s) SizeDamDice: [%s%4d%s]\r\n" "%sC%s) Num HP Dice: [%s%4d%s], %sD%s) Size HP Dice: [%s%4d%s], %sE%s) HP Bonus: [%s%5d%s]\r\n" "%sF%s) Armor Class: [%s%4d%s], %sG%s) Exp: [%s%9d%s], %sH%s) Gold: [%s%8d%s]\r\n", cyn, OLC_NUM(d), nrm, grn, nrm, yel, genders[(int)GET_SEX(mob)], nrm, grn, nrm, yel, GET_ALIAS(mob), grn, nrm, yel, GET_SDESC(mob), grn, nrm, yel, GET_LDESC(mob), grn, nrm, yel, GET_DDESC(mob), grn, nrm, cyn, GET_LEVEL(mob), nrm, grn, nrm, cyn, GET_ALIGNMENT(mob), nrm, grn, nrm, cyn, GET_HITROLL(mob), nrm, grn, nrm, cyn, GET_DAMROLL(mob), nrm, grn, nrm, cyn, GET_NDD(mob), nrm, grn, nrm, cyn, GET_SDD(mob), nrm, grn, nrm, cyn, GET_HIT(mob), nrm, grn, nrm, cyn, GET_MANA(mob), nrm, grn, nrm, cyn, GET_MOVE(mob), nrm, grn, nrm, cyn, GET_AC(mob), nrm, grn, nrm, cyn, GET_EXP(mob), nrm, grn, nrm, cyn, convert_all_to_copper(mob), nrm ); SEND_TO_Q(buf, d); sprintbit(MOB_FLAGS(mob), action_bits, buf1); sprintbit(AFF_FLAGS(mob), affected_bits, buf2); sprintf(buf, "%sI%s) Position : %s%s\r\n" "%sJ%s) Default : %s%s\r\n" "%sK%s) Attack : %s%s\r\n" "%sN%s) Class : %s%s\r\n" "%sR%s) Race : %s%s\r\n" "%sS%s) Size : %s%d\r\n" "%sW%s) Weight : %s%d\r\n" "%sL%s) NPC Flags : %s%s\r\n" "%sM%s) AFF Flags : %s%s\r\n" #if CONFIG_OASIS_MPROG "%sP%s) Mob Progs : %s%s\r\n" #endif "%sQ%s) Quit\r\n" "Enter choice : ", grn, nrm, yel, position_types[(int)GET_POS(mob)], grn, nrm, yel, position_types[(int)GET_DEFAULT_POS(mob)], grn, nrm, yel, attack_hit_text[GET_ATTACK(mob)].singular, grn, nrm, cyn, npc_class_types[(int)GET_CLASS(mob)], grn, nrm, cyn, npc_race_types[(int)GET_RACE(mob)], grn, nrm, cyn, GET_MOB_SIZE(mob), grn, nrm, cyn, GET_MOB_WEIGHT(mob), grn, nrm, cyn, buf1, grn, nrm, cyn, buf2, #if CONFIG_OASIS_MPROG grn, nrm, cyn, (OLC_MPROGL(d) ? "Set." : "Not Set."), #endif grn, nrm ); SEND_TO_Q(buf, d); OLC_MODE(d) = MEDIT_MAIN_MENU; }
void medit_parse(struct descriptor_data *d, char *arg) { int i = -1; char *oldtext = NULL; if (OLC_MODE(d) > MEDIT_NUMERICAL_RESPONSE) { i = atoi(arg); if (!*arg || (!isdigit(arg[0]) && ((*arg == '-') && !isdigit(arg[1])))) { SEND_TO_Q("Field must be numerical, try again : ", d); return; } } else { /* String response. */ if (!genolc_checkstring(d, arg)) return; } switch (OLC_MODE(d)) { /*-------------------------------------------------------------------*/ case MEDIT_CONFIRM_SAVESTRING: /* * Ensure mob has MOB_ISNPC set or things will go pear shaped. */ SET_BIT(MOB_FLAGS(OLC_MOB(d)), MOB_ISNPC); switch (*arg) { case 'y': case 'Y': /* * Save the mob in memory and to disk. */ SEND_TO_Q("Saving mobile to memory.\r\n", d); medit_save_internally(d); sprintf(buf, "OLC: %s edits mob %d", GET_NAME(d->character), OLC_NUM(d)); mudlog(buf, CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), TRUE); /* FALL THROUGH */ case 'n': case 'N': cleanup_olc(d, CLEANUP_ALL); return; default: SEND_TO_Q("Invalid choice!\r\n", d); SEND_TO_Q("Do you wish to save the mobile? : ", d); return; } break; /*-------------------------------------------------------------------*/ case MEDIT_MAIN_MENU: i = 0; switch (*arg) { case 'q': case 'Q': if (OLC_VAL(d)) { /* Anything been changed? */ SEND_TO_Q("Do you wish to save the changes to the mobile? (y//n) : ", d); OLC_MODE(d) = MEDIT_CONFIRM_SAVESTRING; } else cleanup_olc(d, CLEANUP_ALL); return; case '1': OLC_MODE(d) = MEDIT_SEX; medit_disp_sex(d); return; case '2': OLC_MODE(d) = MEDIT_ALIAS; i--; break; case '3': OLC_MODE(d) = MEDIT_S_DESC; i--; break; case '4': OLC_MODE(d) = MEDIT_L_DESC; i--; break; case '5': OLC_MODE(d) = MEDIT_D_DESC; send_editor_help(d); SEND_TO_Q("Enter mob description:\r\n\r\n", d); if (OLC_MOB(d)->player.description) { SEND_TO_Q(OLC_MOB(d)->player.description, d); oldtext = str_dup(OLC_MOB(d)->player.description); } string_write(d, &OLC_MOB(d)->player.description, MAX_MOB_DESC, 0, oldtext); OLC_VAL(d) = 1; return; case '6': OLC_MODE(d) = MEDIT_LEVEL; i++; break; case '7': OLC_MODE(d) = MEDIT_ALIGNMENT; i++; break; case '8': OLC_MODE(d) = MEDIT_HITROLL; i++; break; case '9': OLC_MODE(d) = MEDIT_DAMROLL; i++; break; case 'a': case 'A': OLC_MODE(d) = MEDIT_NDD; i++; break; case 'b': case 'B': OLC_MODE(d) = MEDIT_SDD; i++; break; case 'c': case 'C': OLC_MODE(d) = MEDIT_NUM_HP_DICE; i++; break; case 'd': case 'D': OLC_MODE(d) = MEDIT_SIZE_HP_DICE; i++; break; case 'e': case 'E': OLC_MODE(d) = MEDIT_ADD_HP; i++; break; case 'f': case 'F': OLC_MODE(d) = MEDIT_AC; i++; break; case 'g': case 'G': OLC_MODE(d) = MEDIT_EXP; i++; break; case 'h': case 'H': OLC_MODE(d) = MEDIT_GOLD; i++; break; case 'i': case 'I': OLC_MODE(d) = MEDIT_POS; medit_disp_positions(d); return; case 'j': case 'J': OLC_MODE(d) = MEDIT_DEFAULT_POS; medit_disp_positions(d); return; case 'k': case 'K': OLC_MODE(d) = MEDIT_ATTACK; medit_disp_attack_types(d); return; case 'l': case 'L': OLC_MODE(d) = MEDIT_NPC_FLAGS; medit_disp_mob_flags(d); return; case 'm': case 'M': OLC_MODE(d) = MEDIT_AFF_FLAGS; medit_disp_aff_flags(d); return; case 'n': case 'N': OLC_MODE(d) = MEDIT_CLASS; medit_disp_class_flags(d); return; case 'r': case 'R': OLC_MODE(d) = MEDIT_RACE; medit_disp_race_flags(d); return; case 's': case 'S': OLC_MODE(d) = MEDIT_MSIZE; medit_disp_size_flags(d); return; case 'w': case 'W': OLC_MODE(d) = MEDIT_WEIGHT; send_to_char("Please enter the mobiles weight in pounds: ", d->character); return; #if CONFIG_OASIS_MPROG case 'p': case 'P': OLC_MODE(d) = MEDIT_MPROG; medit_disp_mprog(d); return; #endif default: medit_disp_menu(d); return; } if (i == 0) break; else if (i == 1) SEND_TO_Q("\r\nEnter new value : ", d); else if (i == -1) SEND_TO_Q("\r\nEnter new text :\r\n] ", d); else SEND_TO_Q("Oops...\r\n", d); return; /*-------------------------------------------------------------------*/ case MEDIT_ALIAS: if (GET_ALIAS(OLC_MOB(d))) free(GET_ALIAS(OLC_MOB(d))); GET_ALIAS(OLC_MOB(d)) = str_udup(arg); break; /*-------------------------------------------------------------------*/ case MEDIT_S_DESC: if (GET_SDESC(OLC_MOB(d))) free(GET_SDESC(OLC_MOB(d))); GET_SDESC(OLC_MOB(d)) = str_udup(arg); break; /*-------------------------------------------------------------------*/ case MEDIT_L_DESC: if (GET_LDESC(OLC_MOB(d))) free(GET_LDESC(OLC_MOB(d))); if (arg && *arg) { strcpy(buf, arg); strcat(buf, "\r\n"); GET_LDESC(OLC_MOB(d)) = str_dup(buf); } else GET_LDESC(OLC_MOB(d)) = str_dup("undefined"); break; /*-------------------------------------------------------------------*/ case MEDIT_D_DESC: /* * We should never get here. */ cleanup_olc(d, CLEANUP_ALL); mudlog("SYSERR: OLC: medit_parse(): Reached D_DESC case!", BRF, LVL_BUILDER, TRUE); SEND_TO_Q("Oops...\r\n", d); break; /*-------------------------------------------------------------------*/ #if CONFIG_OASIS_MPROG case MEDIT_MPROG_COMLIST: /* * We should never get here, but if we do, bail out. */ cleanup_olc(d, CLEANUP_ALL); mudlog("SYSERR: OLC: medit_parse(): Reached MPROG_COMLIST case!", BRF, LVL_BUILDER, TRUE); break; #endif /*-------------------------------------------------------------------*/ case MEDIT_NPC_FLAGS: if ((i = atoi(arg)) <= 0) break; else if (i <= NUM_MOB_FLAGS) TOGGLE_BIT(MOB_FLAGS(OLC_MOB(d)), 1 << (i - 1)); medit_disp_mob_flags(d); return; /*-------------------------------------------------------------------*/ case MEDIT_AFF_FLAGS: if ((i = atoi(arg)) <= 0) break; else if (i <= NUM_AFF_FLAGS) TOGGLE_BIT(AFF_FLAGS(OLC_MOB(d)), 1 << (i - 1)); medit_disp_aff_flags(d); return; /*-------------------------------------------------------------------*/ #if CONFIG_OASIS_MPROG case MEDIT_MPROG: if ((i = atoi(arg)) == 0) medit_disp_menu(d); else if (i == OLC_MTOTAL(d)) { struct mob_prog_data *temp; CREATE(temp, struct mob_prog_data, 1); temp->next = OLC_MPROGL(d); temp->type = -1; temp->arglist = NULL; temp->comlist = NULL; OLC_MPROG(d) = temp; OLC_MPROGL(d) = temp; OLC_MODE(d) = MEDIT_CHANGE_MPROG; medit_change_mprog (d); } else if (i < OLC_MTOTAL(d)) { struct mob_prog_data *temp; int x = 1; for (temp = OLC_MPROGL(d); temp && x < i; temp = temp->next) x++; OLC_MPROG(d) = temp; OLC_MODE(d) = MEDIT_CHANGE_MPROG; medit_change_mprog (d); } else if (i == (OLC_MTOTAL(d) + 1)) { SEND_TO_Q("Which mob prog do you want to purge? ", d); OLC_MODE(d) = MEDIT_PURGE_MPROG; } else medit_disp_menu(d); return; case MEDIT_PURGE_MPROG: if ((i = atoi(arg)) > 0 && i < OLC_MTOTAL(d)) { struct mob_prog_data *temp; int x = 1; for (temp = OLC_MPROGL(d); temp && x < i; temp = temp->next) x++; OLC_MPROG(d) = temp; REMOVE_FROM_LIST(OLC_MPROG(d), OLC_MPROGL(d), next); free(OLC_MPROG(d)->arglist); free(OLC_MPROG(d)->comlist); free(OLC_MPROG(d)); OLC_MPROG(d) = NULL; OLC_VAL(d) = 1; } medit_disp_mprog(d); return; case MEDIT_CHANGE_MPROG: if ((i = atoi(arg)) == 1) medit_disp_mprog_types(d); else if (i == 2) { SEND_TO_Q("Enter new arg list: ", d); OLC_MODE(d) = MEDIT_MPROG_ARGS; } else if (i == 3) { SEND_TO_Q("Enter new mob prog commands:\r\n", d); /* * Pass control to modify.c for typing. */ OLC_MODE(d) = MEDIT_MPROG_COMLIST; if (OLC_MPROG(d)->comlist) { SEND_TO_Q(OLC_MPROG(d)->comlist, d); oldtext = str_dup(OLC_MPROG(d)->comlist); } string_write(d, &OLC_MPROG(d)->comlist, MAX_STRING_LENGTH, 0, oldtext); OLC_VAL(d) = 1; } else medit_disp_mprog(d); return; #endif /*-------------------------------------------------------------------*/ /* * Numerical responses. */ #if CONFIG_OASIS_MPROG case MEDIT_MPROG_TYPE: /* * This calculation may be off by one too many powers of 2? * Someone who actually uses MobProgs will have to check. */ OLC_MPROG(d)->type = (1 << LIMIT(atoi(arg), 0, NUM_PROGS - 1)); OLC_VAL(d) = 1; medit_change_mprog(d); return; case MEDIT_MPROG_ARGS: OLC_MPROG(d)->arglist = str_dup(arg); OLC_VAL(d) = 1; medit_change_mprog(d); return; #endif case MEDIT_SEX: GET_SEX(OLC_MOB(d)) = LIMIT(i, 0, NUM_GENDERS - 1); break; case MEDIT_HITROLL: GET_HITROLL(OLC_MOB(d)) = LIMIT(i, 0, 50); break; case MEDIT_DAMROLL: GET_DAMROLL(OLC_MOB(d)) = LIMIT(i, 0, 50); break; case MEDIT_NDD: GET_NDD(OLC_MOB(d)) = LIMIT(i, 0, 30); break; case MEDIT_SDD: GET_SDD(OLC_MOB(d)) = LIMIT(i, 0, 127); break; case MEDIT_NUM_HP_DICE: GET_HIT(OLC_MOB(d)) = LIMIT(i, 0, 30); break; case MEDIT_SIZE_HP_DICE: GET_MANA(OLC_MOB(d)) = LIMIT(i, 0, 1000); break; case MEDIT_ADD_HP: GET_MOVE(OLC_MOB(d)) = LIMIT(i, 0, 30000); break; case MEDIT_AC: GET_AC(OLC_MOB(d)) = LIMIT(i, 10, 200); break; case MEDIT_EXP: GET_EXP(OLC_MOB(d)) = MAX(i, 0); break; case MEDIT_GOLD: add_money_to_char(OLC_MOB(d), MAX(i, 0), COPPER_COINS); break; case MEDIT_POS: GET_POS(OLC_MOB(d)) = LIMIT(i, 0, NUM_POSITIONS - 1); break; case MEDIT_DEFAULT_POS: GET_DEFAULT_POS(OLC_MOB(d)) = LIMIT(i, 0, NUM_POSITIONS - 1); break; case MEDIT_ATTACK: GET_ATTACK(OLC_MOB(d)) = LIMIT(i, 0, NUM_ATTACK_TYPES - 1); break; case MEDIT_LEVEL: GET_LEVEL(OLC_MOB(d)) = i; break; case MEDIT_ALIGNMENT: GET_ALIGNMENT(OLC_MOB(d)) = LIMIT(i, -1000, 1000); break; case MEDIT_CLASS: GET_CLASS(OLC_MOB(d)) = MAX(0, MIN(NUM_NPC_CLASS, atoi(arg))); break; case MEDIT_RACE: GET_RACE(OLC_MOB(d)) = MAX(0, MIN(NUM_NPC_RACE, atoi(arg))); // INT, WIS, STR, DEX, CON, CHA GET_INT(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][0]; GET_WIS(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][1]; GET_STR(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][2]; GET_DEX(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][3]; GET_CON(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][4]; GET_CHA(OLC_MOB(d)) = mob_stats[(int)GET_RACE(OLC_MOB(d))][5]; GET_HIT(OLC_MOB(d)) = mob_hp[i][0]; GET_MANA(OLC_MOB(d)) = mob_hp[i][2]; GET_MOVE(OLC_MOB(d)) = mob_hp[i][3]; break; case MEDIT_WEIGHT: GET_MOB_WEIGHT(OLC_MOB(d)) = LIMIT(i, 1, 1000); break; case MEDIT_MSIZE: GET_MOB_SIZE(OLC_MOB(d)) = atoi(arg); break; /*-------------------------------------------------------------------*/ default: /* * We should never get here. */ cleanup_olc(d, CLEANUP_ALL); mudlog("SYSERR: OLC: medit_parse(): Reached default case!", BRF, LVL_BUILDER, TRUE); SEND_TO_Q("Oops...\r\n", d); break; }
/* * Remove an affected_type structure from a char (called when duration * reaches zero). Pointer *af must never be NIL! Frees mem and calls * affect_location_apply */ void affect_remove(struct char_data * ch, struct affected_type * af, int output) { struct affected_type *temp; struct affected_type aff; bool accum_affect = FALSE; int k; if (ch->affected == NULL) { core_dump(); return; } switch (af->type) { case SPELL_CHARM: { struct char_data* victim = ch->master; if (output == 0) break; affect_modify(ch, af->location, af->modifier, af->bitvector, FALSE); REMOVE_FROM_LIST(af, ch->affected, next); free(af); affect_total(ch); if (ch->master) { stop_follower(ch); } if (victim) { if(IS_NPC(ch)) { SET_BIT(MOB_FLAGS(ch), MOB_AGGRESSIVE | MOB_MEMORY); } if (mag_savingthrow(victim, SAVING_SPELL)) { hit(victim, ch, TYPE_UNDEFINED); } } return; } case SPELL_LIGHT: if (output == 0) break; if (!af->next || (af->next->type != af->type) || (af->next->duration > 0)) { if (world[ch->in_room].name != (char*) NULL) { world[ch->in_room].light -= 10; } } break; case SPELL_DARKNESS: if (output == 0) break; if (!af->next || (af->next->type != af->type) || (af->next->duration > 0)) { if (world[ch->in_room].name != (char*) NULL) { world[ch->in_room].light += 10; } } break; case SPELL_BLACK_PLAGUE: mag_affects(30, ch, ch, SPELL_BREATH_OF_LIFE, SAVING_SPELL); break; case SPELL_CALL_ANIMAL_SPIRIT: case SPELL_ANIMAL_SUMMONING: case SPELL_ANIMAL_SUMMONING_II: case SPELL_ANIMAL_SUMMONING_III: case SPELL_CONJURE_ELEMENTAL: case SPELL_GREATER_ELEMENTAL: case SPELL_DUST_DEVIL: case SPELL_STICKS_TO_SNAKES: case SPELL_SUMMON_INSECTS: case SPELL_AERIAL_SERVANT: case SPELL_SUMMON_GUARD: if (IS_NPC(ch)) { if (GET_POS(ch) > POS_DEAD) { if (output == 1) { affect_modify(ch, af->location, af->modifier, af->bitvector, FALSE); REMOVE_FROM_LIST(af, ch->affected, next); free(af); affect_total(ch); GET_NAME(ch, chname); stop_fighting(ch); /*Fighting Bug Fix Jasrags*/ sprintf(buf, "%s disappears into thin air as the summoning ends.", chname); act(buf, FALSE, world[ch->in_room].people, 0, 0, TO_ROOM); FREE_NAME(chname); extract_char(ch); ch = NULL; return; } } } break; case SPELL_POLYMORPH: if (!PRF_FLAGGED(ch, PRF_NOTSELF)) { affect_modify(ch, af->location, af->modifier, af->bitvector, FALSE); REMOVE_FROM_LIST(af, ch->affected, next); free(af); affect_total(ch); return; } break; case SPELL_DONTUSEME: if(AFF_FLAGGED(ch, AFF_STANCE) && !AFF_FLAGGED(ch, AFF_TIRED)) { aff.type = SKILL_STANCE; aff.duration = 2; aff.location = APPLY_STR; aff.modifier = -2; aff.bitvector = AFF_TIRED; accum_affect = FALSE; affect_to_char(ch, &aff); } break; default: break; } if (output && (af->type > 0) && (af->type <= MAX_SPELLS) && af->type != SPELL_POLYMORPH && af->type != SPELL_DONTUSEME) { if (!af->next || (af->next->type != af->type) || (af->next->duration > 0)) { if (*spell_wear_off_msg[af->type]) { send_to_char(spell_wear_off_msg[af->type], ch); send_to_char("\r\n", ch); } } } if (output && (af->type > 0) && (af->type <= MAX_SPELLS) && af->type == SPELL_POLYMORPH) { if (!af->next || (af->next->type != af->type) || (af->next->duration > 0)) { if (PLR_FLAGGED(ch, PLR_RABBIT)){ REMOVE_BIT(PLR_FLAGS(ch), PLR_RABBIT); REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF); send_to_char("You feel yourself growing, and your ears shrinking. You no longer feel like a rabbit.\r\n", ch); act("$n's body grows, $s ears shrinking. $n no longer looks like a rabbit.\r\n", 0, ch, 0, 0, TO_ROOM); } if (PLR_FLAGGED(ch, PLR_BIRD)) { REMOVE_BIT(PLR_FLAGS(ch), PLR_BIRD); REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF); send_to_char("You feel yourself growing and your feathers falling away. You no longer feel like a bird.\r\n", ch); act("$n's body grows, $s feathers falling away as it expands. $n no longer looks like a bird.\r\n", 0, ch, 0, 0, TO_ROOM); } if (PLR_FLAGGED(ch, PLR_WOLF)) { REMOVE_BIT(PLR_FLAGS(ch), PLR_WOLF); REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF); send_to_char("You feel your your fur shed and your teeth shrink. You no longer feel like a wolf.\r\n", ch); act("$n's teeth shrink, $s fur shedding. $n no longer looks like a wolf.\r\n", 0, ch, 0, 0, TO_ROOM); } if (PLR_FLAGGED(ch, PLR_BEAR)) { REMOVE_BIT(PLR_FLAGS(ch), PLR_BEAR); REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF); send_to_char("Your claws shrink as does the rest of your body. You no longer feel like a bear.\r\n", ch); act("$n's claws shrink as does the rest of $s body. $n no longer looks like a bear.\r\n", 0, ch, 0, 0, TO_ROOM); } if (PLR_FLAGGED(ch, PLR_CAT)){ REMOVE_BIT(PLR_FLAGS(ch), PLR_CAT); REMOVE_BIT(PRF_FLAGS(ch), PRF_NOTSELF); send_to_char("You feel your body growing, and your fur shedding. You no longer feel like a cat.\r\n", ch); act("$n's body slowly grows, $s fur shedding. $n no longer looks like a cat.\r\n", 0, ch, 0, 0, TO_ROOM); } for (k = 0; k < NUM_WEARS; k++) if (GET_EQ(ch, k)){ GET_OBJ_DISGUISE(GET_EQ(ch, k)) = 0; } } } affect_modify(ch, af->location, af->modifier, af->bitvector, FALSE); REMOVE_FROM_LIST(af, ch->affected, next); free(af); affect_total(ch); }
void medit_parse(struct descriptor_data *d, char *arg) { int number; int mob_number; // the RNUM switch(d->edit_mode) { case MEDIT_CONFIRM_EDIT: /* if player hits 'Y' then edit mob */ switch (*arg) { case 'y': case 'Y': medit_disp_menu(d); break; case 'n': case 'N': STATE(d) = CON_PLAYING; /* free up the editing mob */ if (d->edit_mob) Mem->DeleteCh(d->edit_mob); d->edit_mob = NULL; d->edit_number = 0; PLR_FLAGS(d->character).RemoveBit(PLR_EDITING); break; default: send_to_char("That's not a valid choice!\r\n", CH); send_to_char("Do you wish to edit it?\r\n", CH); break; } break; /* end of MEDIT_CONFIRM_EDIT */ case MEDIT_CONFIRM_SAVESTRING: switch(*arg) { case 'y': case 'Y': // first write to the internal tables if (!from_ip_zone(d->edit_number)) { sprintf(buf,"%s wrote new mob #%ld", GET_CHAR_NAME(d->character), d->edit_number); mudlog(buf, d->character, LOG_WIZLOG, TRUE); } mob_number = real_mobile(d->edit_number); if (mob_number > 0) { // first we go through the entire list of mobs to find out // which are pointing to this prototype; if it is, it gets // replaced struct char_data *i, *temp; int c; for (i = character_list; i; i = i->next) { if (mob_number == i->nr) { // alloc a temp mobile temp = Mem->GetCh(); *temp = *i; *i = *d->edit_mob; /* copy game-time dependent vars over */ i->in_room = temp->in_room; i->nr = mob_number; i->affected = temp->affected; i->carrying = temp->carrying; i->cyberware = temp->cyberware; i->bioware = temp->bioware; // any eq worn for (c = 0; c < NUM_WEARS; ++c) i->equipment[c] = temp->equipment[c]; i->next_in_room = temp->next_in_room; i->next = temp->next; i->next_fighting = temp->next_fighting; i->followers = temp->followers; i->master = temp->master; i->char_specials.fighting = temp->char_specials.fighting; i->char_specials.hunting = temp->char_specials.hunting; i->mob_specials.last_direction = temp->mob_specials.last_direction; i->mob_specials.memory = temp->mob_specials.memory; i->mob_specials.wait_state = temp->mob_specials.wait_state; Mem->ClearCh(temp); } // end if statement } // end for loop // now you can free the old prototype and put in the new one if (mob_proto[mob_number].player.physical_text.keywords) delete [] mob_proto[mob_number].player.physical_text.keywords; if (mob_proto[mob_number].player.title) delete [] mob_proto[mob_number].player.title; if (mob_proto[mob_number].player.physical_text.name) delete [] mob_proto[mob_number].player.physical_text.name; if (mob_proto[mob_number].player.physical_text.room_desc) delete [] mob_proto[mob_number].player.physical_text.room_desc; if (mob_proto[mob_number].player.physical_text.look_desc) delete [] mob_proto[mob_number].player.physical_text.look_desc; if (mob_proto[mob_number].mob_specials.arrive) delete [] mob_proto[mob_number].mob_specials.arrive; if (mob_proto[mob_number].mob_specials.leave) delete [] mob_proto[mob_number].mob_specials.leave; mob_proto[mob_number] = *d->edit_mob; mob_proto[mob_number].nr = mob_number; } else { // if not, we need to make a new spot in the list int counter; int found = FALSE; struct char_data *new_mob_proto; struct index_data *new_mob_index; struct char_data *temp_mob; // two because you are adding one and you need one over new_mob_index = new struct index_data[top_of_mobt + 2]; new_mob_proto = new struct char_data[top_of_mobt + 2]; // count through the tables for (counter = 0; counter < top_of_mobt + 1; counter++) { /* if we haven't found it */ if (!found) { /* check if current virtual is bigger than our virtual */ if (MOB_VNUM_RNUM(counter) > d->edit_number) { /* eureka. insert now */ /*---------*/ new_mob_index[counter].vnum = d->edit_number; new_mob_index[counter].number = 0; new_mob_index[counter].func = NULL; /*---------*/ new_mob_proto[counter] = *(d->edit_mob); new_mob_proto[counter].in_room = NOWHERE; /* it is now safe (and necessary!) to assign real number to * the edit_mob, which has been -1 all this time */ d->edit_mob->nr = counter; /* and assign to prototype as well */ new_mob_proto[counter].nr = counter; found = TRUE; /* insert the other proto at this point */ new_mob_index[counter + 1] = mob_index[counter]; new_mob_proto[counter + 1] = mob_proto[counter]; new_mob_proto[counter + 1].nr = counter + 1; } else { /* just copy from old to new, no num change */ new_mob_proto[counter] = mob_proto[counter]; new_mob_index[counter] = mob_index[counter]; } } else { // if !found else /* we HAVE already found it.. therefore copy to mobile + 1 */ new_mob_index[counter + 1] = mob_index[counter]; new_mob_proto[counter + 1] = mob_proto[counter]; new_mob_proto[counter + 1].nr = counter + 1; } } // for loop through list /* if we STILL haven't found it, means the mobile was > than all * the other mobs.. so insert at end */ if (!found) { new_mob_index[top_of_mobt + 1].vnum = d->edit_number; new_mob_index[top_of_mobt + 1].number = 0; new_mob_index[top_of_mobt + 1].func = NULL; clear_char(new_mob_proto + top_of_mobt + 1); new_mob_proto[top_of_mobt + 1] = *(d->edit_mob); new_mob_proto[top_of_mobt + 1].in_room = NOWHERE; new_mob_proto[top_of_mobt + 1].nr = top_of_mobt + 1; /* it is now safe (and necessary!) to assign real number to * the edit_mob, which has been -1 all this time */ d->edit_mob->nr = top_of_mobt + 1; } top_of_mobt++; /* we also have to renumber all the mobiles currently * * existing in the world. This is because when I start * * extracting mobiles, bad things will happen! */ for (temp_mob = character_list; temp_mob; temp_mob = temp_mob->next) if (GET_MOB_RNUM (temp_mob) >= d->edit_mob->nr) GET_MOB_RNUM (temp_mob)++; /* free and replace old tables */ delete [] mob_proto; delete [] mob_index; mob_proto = new_mob_proto; mob_index = new_mob_index; /* RENUMBER ZONE TABLES HERE, only * * because I ADDED a mobile! * * This code shamelessly ripped off from db.c */ int zone, cmd_no; for (zone = 0; zone <= top_of_zone_table; zone++) for (cmd_no = 0; cmd_no < zone_table[zone].num_cmds; cmd_no++) { switch (ZCMD.command) { case 'M': ZCMD.arg1 = (ZCMD.arg1 >= d->edit_mob->nr ? ZCMD.arg1 + 1 : ZCMD.arg1); break; } } } // finally done putting the mobile into memory send_to_char("Writing mobile to disk...", CH); write_mobs_to_disk(d->character->player_specials->saved.zonenum); // again, here we don't delete it cause we don't want to end up // deleting the strings from the prototypes if (d->edit_mob) Mem->ClearCh(d->edit_mob); d->edit_mob = NULL; STATE(d) = CON_PLAYING; PLR_FLAGS(d->character).RemoveBit(PLR_EDITING); send_to_char("Done.\r\n", d->character); break; case 'n': case 'N': send_to_char("Mobile not saved, aborting.\r\n", d->character); STATE(d) = CON_PLAYING; // complete nuke if (d->edit_mob) Mem->DeleteCh(d->edit_mob); d->edit_mob = NULL; d->edit_number = 0; d->edit_zone = 0; PLR_FLAGS(d->character).RemoveBit(PLR_EDITING); break; default: send_to_char("Invalid choice!\r\n", d->character); send_to_char("Do you wish to save this mobile internally?\r\n", d->character); break; } break; case MEDIT_MAIN_MENU: switch (*arg) { case 'q': case 'Q': d->edit_mode = MEDIT_CONFIRM_SAVESTRING; medit_parse(d, "y"); break; case 'x': case 'X': d->edit_mode = MEDIT_CONFIRM_SAVESTRING; medit_parse(d, "n"); break; case '1': send_to_char("Enter keywords:", CH); d->edit_mode = MEDIT_EDIT_NAMELIST; break; case '2': send_to_char("Enter name:", CH); d->edit_mode = MEDIT_SHORT_DESCR; break; case '3': send_to_char("Enter room description:", CH); d->edit_mode = MEDIT_REG_DESCR; d->str = new (char *); if (!d->str) { mudlog("Malloc failed!", NULL, LOG_SYSLOG, TRUE); shutdown(); } *(d->str) = NULL; d->max_str = MAX_REG_DESC_LENGTH; d->mail_to = 0; break; case '4': // go to modify.cc send_to_char("Enter look description:\r\n", CH); d->edit_mode = MEDIT_LONG_DESCR; d->str = new (char *); if (!d->str) { mudlog("Malloc failed!", NULL, LOG_SYSLOG, TRUE); shutdown(); } *(d->str) = NULL; d->max_str = MAX_MESSAGE_LENGTH; d->mail_to = 0; break; case '5': medit_disp_mobflags_menu(d); d->edit_mode = MEDIT_MOB_FLAGS; break; case '6': medit_disp_affected_menu(d); d->edit_mode = MEDIT_AFF_FLAGS; break; case '8': send_to_char("Enter average nuyen: ", CH); d->edit_mode = MEDIT_NUYEN; break; case '9': send_to_char("Enter bonus karma points: ", CH); d->edit_mode = MEDIT_EXPERIENCE; break; case 'a': medit_disp_att_menu(d); d->edit_mode = MEDIT_ATTRIBUTES; break; case 'b': send_to_char("Enter level: ", CH); d->edit_mode = MEDIT_LEVEL; break; case 'c': send_to_char("Enter ballistic armor points: ", CH); d->edit_mode = MEDIT_BALLISTIC; break; case 'd': send_to_char("Enter impact armor points: ", CH); d->edit_mode = MEDIT_IMPACT; break; case 'e': send_to_char("Enter max physical points: ", CH); d->edit_mode = MEDIT_PHYSICAL; break; case 'f': send_to_char("Enter max mental points: ", CH); d->edit_mode = MEDIT_MENTAL; break; case 'g': medit_disp_pos_menu(d); send_to_char("Enter position: ", CH); d->edit_mode = MEDIT_POSITION; break; case 'h': medit_disp_pos_menu(d); send_to_char("Enter default position: ", CH); d->edit_mode = MEDIT_DEFAULT_POSITION; break; case 'i': medit_disp_gender_menu(d); d->edit_mode = MEDIT_GENDER; break; case 'j': send_to_char("Enter weight (in kilograms): ", CH); d->edit_mode = MEDIT_WEIGHT; break; case 'k': send_to_char("Enter height (in centimeters): ", CH); d->edit_mode = MEDIT_HEIGHT; break; case 'l': medit_disp_class_menu(d); d->edit_mode = MEDIT_CLASS; break; case 'm': medit_disp_attack_menu(d); d->edit_mode = MEDIT_ATTACK_TYPE; break; case 'n': medit_disp_skill_menu(d); d->edit_mode = MEDIT_SKILLS; break; case 'o': send_to_char("Enter arrive text: ", CH); d->edit_mode = MEDIT_ARRIVE_MSG; break; case 'p': send_to_char("Enter leave text: ", CH); d->edit_mode = MEDIT_LEAVE_MSG; break; default: medit_disp_menu(d); break; } break; case MEDIT_EDIT_NAMELIST: if (MOB->player.physical_text.keywords) delete [] MOB->player.physical_text.keywords; MOB->player.physical_text.keywords = str_dup(arg); medit_disp_menu(d); break; case MEDIT_SHORT_DESCR: if (MOB->player.physical_text.name) delete [] MOB->player.physical_text.name; MOB->player.physical_text.name = str_dup(arg); medit_disp_menu(d); break; case MEDIT_ARRIVE_MSG: if (MOB->mob_specials.arrive) delete [] MOB->mob_specials.arrive; MOB->mob_specials.arrive = str_dup(arg); medit_disp_menu(d); break; case MEDIT_LEAVE_MSG: if (MOB->mob_specials.leave) delete [] MOB->mob_specials.leave; MOB->mob_specials.leave = str_dup(arg); medit_disp_menu(d); break; case MEDIT_REG_DESCR: // you should not come here break; case MEDIT_LONG_DESCR: // you should not come here break; case MEDIT_MOB_FLAGS: number = atoi(arg); if ((number < 0) || (number > MOB_MAX)) medit_disp_mobflags_menu(d); else { if (number == 0) // 0 = quit medit_disp_menu(d); else { MOB_FLAGS(MOB).ToggleBit(number-1); medit_disp_mobflags_menu(d); } } break; case MEDIT_AFF_FLAGS: number = atoi(arg); if ((number < 0) || (number > AFF_MAX)) medit_disp_affected_menu(d); else { if (number == 0) // 0 = quit medit_disp_menu(d); else { AFF_FLAGS(MOB).ToggleBit(number - 1); medit_disp_affected_menu(d); } } break; case MEDIT_NUYEN: number = atoi(arg); if ((number < 0) || (number > 999999)) { send_to_char("Value must range between 0 and 999999.\r\n", CH); send_to_char("Enter average nuyen: ", CH); } else { GET_NUYEN(MOB) = number; send_to_char("Enter average credstick value: ", CH); d->edit_mode = MEDIT_CREDSTICK; } break; case MEDIT_CREDSTICK: number = atoi(arg); if ((number < 0) || (number > 999999)) { send_to_char("Value must range between 0 and 999999.\r\n", CH); send_to_char("Enter average credstick value: ", CH); } else { GET_BANK(MOB) = number; medit_disp_menu(d); } break; case MEDIT_EXPERIENCE: number = atoi(arg); if ((number < 0) || (number > 7500)) { send_to_char("Value must range between 0 and 7500.\r\n", CH); send_to_char("Enter bonus karma points: ", CH); } else { int karma; if (number > (karma=calc_karma(NULL, MOB))) { send_to_char("Bonus karma may not be higher than actual karma. Lowering.\r\n", CH); number = karma; } GET_KARMA(MOB) = number; medit_disp_menu(d); } break; case MEDIT_SKILLS: switch (*arg) { case '0': medit_disp_menu(d); break; case '1': medit_disp_skills(d); send_to_char("Enter a skill (0 to quit): ", CH); d->edit_mode = MEDIT_SKILL1; break; case '2': medit_disp_skills(d); send_to_char("Enter a skill (0 to quit): ", CH); d->edit_mode = MEDIT_SKILL2; break; case '3': medit_disp_skills(d); send_to_char("Enter a skill (0 to quit): ", CH); d->edit_mode = MEDIT_SKILL3; break; case '4': medit_disp_skills(d); send_to_char("Enter a skill (0 to quit): ", CH); d->edit_mode = MEDIT_SKILL4; break; case '5': medit_disp_skills(d); send_to_char("Enter a skill (0 to quit): ", CH); d->edit_mode = MEDIT_SKILL5; break; default: medit_disp_skill_menu(d); break; } break; // end of MEDIT_SKILLS case MEDIT_SKILL1: number = atoi(arg); if ((number < 0) || (number > MAX_SKILLS)) { medit_disp_skills(d); send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS); send_to_char("Enter a skill (0 to quit): ", CH); } else if (number == 0) { // 0 = quit medit_disp_skill_menu(d); d->edit_mode = MEDIT_SKILLS; } else { SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0) MOB->mob_specials.mob_skills[0] = number; // to adjust it send_to_char("Enter skill level (0 to quit): ", CH); d->edit_mode = MEDIT_SKILL1_VAL; } break; case MEDIT_SKILL2: number = atoi(arg); if ((number < 0) || (number > MAX_SKILLS)) { medit_disp_skills(d); send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS); send_to_char("Enter a skill (0 to quit): ", CH); } else if (number == 0) { // 0 = quit medit_disp_skill_menu(d); d->edit_mode = MEDIT_SKILLS; } else { SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0) MOB->mob_specials.mob_skills[0] = number; // to adjust it send_to_char("Enter skill level (0 to quit): ", CH); d->edit_mode = MEDIT_SKILL2_VAL; } break; case MEDIT_SKILL3: number = atoi(arg); if ((number < 0) || (number > MAX_SKILLS)) { medit_disp_skills(d); send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS); send_to_char("Enter a skill (0 to quit): ", CH); } else if (number == 0) { // 0 = quit medit_disp_skill_menu(d); d->edit_mode = MEDIT_SKILLS; } else { SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0) MOB->mob_specials.mob_skills[0] = number; // to adjust it send_to_char("Enter skill level (0 to quit): ", CH); d->edit_mode = MEDIT_SKILL3_VAL; } break; case MEDIT_SKILL4: number = atoi(arg); if ((number < 0) || (number > MAX_SKILLS)) { medit_disp_skills(d); send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS); send_to_char("Enter a skill (0 to quit): ", CH); } else if (number == 0) { // 0 = quit medit_disp_skill_menu(d); d->edit_mode = MEDIT_SKILLS; } else { SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0) MOB->mob_specials.mob_skills[0] = number; // to adjust it send_to_char("Enter skill level (0 to quit): ", CH); d->edit_mode = MEDIT_SKILL4_VAL; } break; case MEDIT_SKILL5: number = atoi(arg); if ((number < 0) || (number > MAX_SKILLS)) { medit_disp_skills(d); send_to_char(CH, "Value must range between 1 and %d.\r\n", MAX_SKILLS); send_to_char("Enter a skill (0 to quit): ", CH); } else if (number == 0) { // 0 = quit medit_disp_skill_menu(d); d->edit_mode = MEDIT_SKILLS; } else { SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], 0) MOB->mob_specials.mob_skills[0] = number; // to adjust it send_to_char("Enter skill level (0 to quit): ", CH); d->edit_mode = MEDIT_SKILL5_VAL; } break; case MEDIT_SKILL1_VAL: number = atoi(arg); if ((number < 0) || (number > 50)) { send_to_char("Skill level must be between 1 and 50.\r\n", CH); send_to_char("Enter skill level: ", CH); } else if (number == 0) { MOB->mob_specials.mob_skills[0] = 0; MOB->mob_specials.mob_skills[1] = 0; d->edit_mode = MEDIT_SKILLS; medit_disp_skill_menu(d); } else { MOB->mob_specials.mob_skills[1] = number; GET_SKILL(MOB, MOB->mob_specials.mob_skills[0]) = MOB->mob_specials.mob_skills[1]; SET_SKILL(MOB, MOB->mob_specials.mob_skills[0], MOB->mob_specials.mob_skills[1]); d->edit_mode = MEDIT_SKILLS; medit_disp_skill_menu(d); } break; case MEDIT_SKILL2_VAL: number = atoi(arg); if ((number < 0) || (number > 50)) { send_to_char("Skill level must be between 1 and 50.\r\n", CH); send_to_char("Enter skill level: ", CH); } else if (number == 0) { MOB->mob_specials.mob_skills[2] = 0; MOB->mob_specials.mob_skills[3] = 0; d->edit_mode = MEDIT_SKILLS; medit_disp_skill_menu(d); } else { MOB->mob_specials.mob_skills[3] = number; GET_SKILL(MOB, MOB->mob_specials.mob_skills[2]) = MOB->mob_specials.mob_skills[3]; SET_SKILL(MOB, MOB->mob_specials.mob_skills[2], MOB->mob_specials.mob_skills[3]); d->edit_mode = MEDIT_SKILLS; medit_disp_skill_menu(d); } break; case MEDIT_SKILL3_VAL: number = atoi(arg); if ((number < 0) || (number > 50)) { send_to_char("Skill level must be between 1 and 50.\r\n", CH); send_to_char("Enter skill level: ", CH); } else if (number == 0) { MOB->mob_specials.mob_skills[4] = 0; MOB->mob_specials.mob_skills[5] = 0; d->edit_mode = MEDIT_SKILLS; medit_disp_skill_menu(d); } else { MOB->mob_specials.mob_skills[5] = number; GET_SKILL(MOB, MOB->mob_specials.mob_skills[4]) = MOB->mob_specials.mob_skills[5]; SET_SKILL(MOB, MOB->mob_specials.mob_skills[4], MOB->mob_specials.mob_skills[5]); d->edit_mode = MEDIT_SKILLS; medit_disp_skill_menu(d); } break; case MEDIT_SKILL4_VAL: number = atoi(arg); if ((number < 0) || (number > 50)) { send_to_char("Skill level must be between 1 and 50.\r\n", CH); send_to_char("Enter skill level: ", CH); } else if (number == 0) { MOB->mob_specials.mob_skills[6] = 0; MOB->mob_specials.mob_skills[7] = 0; d->edit_mode = MEDIT_SKILLS; medit_disp_skill_menu(d); } else { MOB->mob_specials.mob_skills[7] = number; GET_SKILL(MOB, MOB->mob_specials.mob_skills[6]) = MOB->mob_specials.mob_skills[7]; SET_SKILL(MOB, MOB->mob_specials.mob_skills[6], MOB->mob_specials.mob_skills[7]); d->edit_mode = MEDIT_SKILLS; medit_disp_skill_menu(d); } break; case MEDIT_SKILL5_VAL: number = atoi(arg); if ((number < 0) || (number > 50)) { send_to_char("Skill level must be between 1 and 50.\r\n", CH); send_to_char("Enter skill level: ", CH); } else if (number == 0) { MOB->mob_specials.mob_skills[8] = 0; MOB->mob_specials.mob_skills[9] = 0; d->edit_mode = MEDIT_SKILLS; medit_disp_skill_menu(d); } else { MOB->mob_specials.mob_skills[9] = number; GET_SKILL(MOB, MOB->mob_specials.mob_skills[8]) = MOB->mob_specials.mob_skills[9]; SET_SKILL(MOB, MOB->mob_specials.mob_skills[8], MOB->mob_specials.mob_skills[9]); d->edit_mode = MEDIT_SKILLS; medit_disp_skill_menu(d); } break; case MEDIT_ATTRIBUTES: switch (*arg) { case '1': send_to_char("Enter body attribute: ", CH); d->edit_mode = MEDIT_BOD; break; case '2': send_to_char("Enter quickness attribute: ", CH); d->edit_mode = MEDIT_QUI; break; case '3': send_to_char("Enter strength attribute: ", CH); d->edit_mode = MEDIT_STR; break; case '4': send_to_char("Enter charisma attribute: ", CH); d->edit_mode = MEDIT_CHA; break; case '5': send_to_char("Enter intelligence attribute: ", CH); d->edit_mode = MEDIT_INT; break; case '6': send_to_char("Enter willpower attribute: ", CH); d->edit_mode = MEDIT_WIL; break; case '7': send_to_char("Enter magic attribute: ", CH); d->edit_mode = MEDIT_MAG; break; case 'q': case 'Q': // back to main menu medit_disp_menu(d); break; default: medit_disp_att_menu(d); break; } break; case MEDIT_BOD: number = atoi(arg); if ((number < 1) || (number > 50)) { send_to_char("Value must range between 1 and 50.\r\n", CH); send_to_char("Enter body attribute: ", CH); } else { GET_REAL_BOD(MOB) = number; MOB->real_abils.bod_index = number * 100; medit_disp_att_menu(d); } break; case MEDIT_QUI: number = atoi(arg); if ((number < 1) || (number > 50)) { send_to_char("Value must range between 1 and 50.\r\n", CH); send_to_char("Enter quickness attribute: ", CH); } else { GET_REAL_QUI(MOB) = number; GET_REAL_REA(MOB) = (number + GET_REAL_INT(MOB)) >> 1; medit_disp_att_menu(d); } break; case MEDIT_STR: number = atoi(arg); if ((number < 1) || (number > 50)) { send_to_char("Value must range between 1 and 50.\r\n", CH); send_to_char("Enter strength attribute: ", CH); } else { GET_REAL_STR(MOB) = number; medit_disp_att_menu(d); } break; case MEDIT_CHA: number = atoi(arg); if ((number < 1) || (number > 50)) { send_to_char("Value must range between 1 and 50.\r\n", CH); send_to_char("Enter charisma attribute: ", CH); } else { GET_REAL_CHA(MOB) = number; medit_disp_att_menu(d); } break; case MEDIT_INT: number = atoi(arg); if ((number < 1) || (number > 50)) { send_to_char("Value must range between 1 and 50.\r\n", CH); send_to_char("Enter intelligence attribute: ", CH); } else { GET_REAL_INT(MOB) = number; GET_REAL_REA(MOB) = (number + GET_REAL_QUI(MOB)) >> 1; medit_disp_att_menu(d); } break; case MEDIT_WIL: number = atoi(arg); if ((number < 1) || (number > 50)) { send_to_char("Value must range between 1 and 50.\r\n", CH); send_to_char("Enter willpower attribute: ", CH); } else { GET_REAL_WIL(MOB) = number; medit_disp_att_menu(d); } break; case MEDIT_MAG: number = atoi(arg); if ((number < 0) || (number > 50)) { send_to_char("Value must range between 0 and 50.\r\n", CH); send_to_char("Enter magic attribute: ", CH); } else { MOB->real_abils.mag = number * 100; medit_disp_att_menu(d); } break; case MEDIT_LEVEL: number = atoi(arg); if (number < 0) { send_to_char("Invalid choice.\r\n", CH); send_to_char("Enter level: ", CH); } else { GET_LEVEL(MOB) = number; medit_disp_menu(d); } break; case MEDIT_BALLISTIC: number = atoi(arg); if (number < 0) { send_to_char("Value must be greater than 0.\r\n", CH); send_to_char("Enter ballistic armor points: ", CH); } else { GET_BALLISTIC(MOB) = number; medit_disp_menu(d); } break; case MEDIT_IMPACT: number = atoi(arg); if (number < 0) { send_to_char("Value must be greater than 0.\r\n", CH); send_to_char("Enter impact armor points: ", CH); } else { GET_IMPACT(MOB) = number; medit_disp_menu(d); } break; case MEDIT_PHYSICAL: number = atoi(arg); if ((number < 0) || (number > 10)) { send_to_char("Value must range between 0 and 10.\r\n", CH); send_to_char("Enter max physical points: ", CH); } else { GET_MAX_PHYSICAL(MOB) = number * 100; GET_PHYSICAL(MOB) = number * 100; medit_disp_menu(d); } break; case MEDIT_MENTAL: number = atoi(arg); if ((number < 0) || (number > 10)) { send_to_char("Value must range between 0 and 10.\r\n", CH); send_to_char("Enter max mental points: ", CH); } else { GET_MAX_MENTAL(MOB) = number * 100; GET_MENTAL(MOB) = number * 100; medit_disp_menu(d); } break; case MEDIT_WEIGHT: number = atoi(arg); if (number < 0) { send_to_char("Value must be greater than 0.\r\n", CH); send_to_char("Enter weight (in kilograms): ", CH); } else { GET_WEIGHT(MOB) = number; medit_disp_menu(d); } break; case MEDIT_HEIGHT: number = atoi(arg); if (number < 0) { send_to_char("Value must be greater than 0.\r\n", CH); send_to_char("Enter height (in centimeters): ", CH); } else { GET_HEIGHT(MOB) = number; medit_disp_menu(d); } break; case MEDIT_CLASS: number = atoi(arg); if ((number < 1) || (number > NUM_MOB_CLASSES)) medit_disp_class_menu(d); else { GET_RACE(MOB) = (number - 1); medit_disp_menu(d); } break; case MEDIT_POSITION: number = atoi(arg); if ((number < POS_MORTALLYW) || (number > POS_STANDING)) { send_to_char("Invalid choice.\r\nEnter position: ", CH); medit_disp_pos_menu(d); } else { GET_POS(MOB) = number; medit_disp_menu(d); } break; case MEDIT_DEFAULT_POSITION: number = atoi(arg); if ((number < POS_MORTALLYW) || (number > POS_STANDING)) { send_to_char("Invalid choice.\r\nEnter default position: ", CH); medit_disp_pos_menu(d); } else { GET_DEFAULT_POS(MOB) = number; medit_disp_menu(d); } break; case MEDIT_GENDER: number = atoi(arg); if ((number < 0) || (number > 3)) { send_to_char("Invalid choice.\r\n", CH); medit_disp_gender_menu(d); } else if (number != 0) // 0 = quit GET_SEX(MOB) = (number - 1); medit_disp_menu(d); break; case MEDIT_ATTACK_TYPE: number = atoi(arg); if ((number < 0) || (number > NUM_ATTACK_TYPES)) { send_to_char("Invalid choice.\r\n", CH); medit_disp_attack_menu(d); } else if (number != 0) // 0 = quit MOB->mob_specials.attack_type = number-1 + TYPE_HIT; medit_disp_menu(d); break; } }
void mobile_activity(void) { register struct char_data *ch, *next_ch, *vict; struct char_data *min_vict = NULL; struct obj_data *obj, *next_obj, *best_obj, *cont; int door, found, max, where; int casual, max_abil=0, curr_abil, gold; memory_rec *names; room_rnum target_room; extern int no_specials; ACMD(do_get); for (ch = character_list; ch; ch = next_ch) { next_ch = ch->next; if (!IS_MOB(ch)) continue; //lance ripristina il master! if (IS_NPC(ch) && MOB_FLAGGED(ch, MOB_SAVE)) chkmaster(ch); // Examine call for special procedure if (MOB_FLAGGED(ch, MOB_SPEC) && !no_specials) { if (mob_index[GET_MOB_RNUM(ch)].func == NULL) { sprintf(buf, "SYSERR: %s (#%d): Attempting to call non-existing mob func", GET_NAME(ch), GET_MOB_VNUM(ch)); log(buf); REMOVE_BIT(MOB_FLAGS(ch), MOB_SPEC); } else { //(mob_index[GET_MOB_RNUM(ch)].func) (ch, ch, 0, ""); if ((mob_index[GET_MOB_RNUM(ch)].func) (ch, ch, 0, "")) continue; /* go to next char*/ } } // If the mob has no specproc, do the default actions if (FIGHTING(ch) || !AWAKE(ch)) continue; // Nuovo Scavenger (picking up objects) by Rusty if (MOB_FLAGGED(ch, MOB_SCAVENGER)) if (world[ch->in_room].contents && (number(0, 10) > 5)) { max = -1000; best_obj = NULL; for (obj = world[ch->in_room].contents; obj; obj = obj->next_content) if (CAN_GET_OBJ(ch, obj) && objlevel(obj) > max) { best_obj = obj; max = objlevel(obj); } if (best_obj != NULL) { obj_from_room(best_obj); obj_to_char(best_obj, ch); act("$n prende $p.", FALSE, ch, best_obj, 0, TO_ROOM); // Orione, tolta la procedura che fa indossare l'eq raccolto ai mob scavenger // Scavenger Plus:Mob wear the best object /* where=find_eq_pos(ch, best_obj, 0); if (CAN_WEAR(best_obj, ITEM_WEAR_WIELD)) where=WEAR_WIELD; if ( (where>0) && GET_EQ(ch,where)) { // se ce l'ha gia! if ((objlevel((ch)->equipment[where]))< objlevel(best_obj)) { obj_to_char((obj=unequip_char(ch, where)), ch); act("$n smette di usare $p.", FALSE, ch, obj, 0, TO_ROOM); } else { where = NUM_WEARS; // cioe' oggetto non indossabile } if (GET_LEVEL(ch)>=objlevel(best_obj)) { if (where>=0 && where <NUM_WEARS) { obj_from_char(best_obj); equip_char(ch,best_obj,where); wear_message(ch,best_obj,where); } } } */ } } //End ifif // Mob BodyGuard !? if (MOB_FLAGGED(ch, MOB_BGUARD) && (ch->master)) { if ( (FIGHTING(ch->master) && (npc_rescue(ch, ch->master) == FALSE)) || (ch->master && WHOKILLED(ch->master)) ) { act("$N Si schiera Prontamente al tuo fianco!", FALSE,ch->master, 0, ch, TO_CHAR); act("$n Si schiera prontamente al fianco di $N", FALSE, ch, 0, ch->master, TO_ROOM); if (WHOKILLED(ch->master)) hit(ch, WHOKILLED(ch->master), TYPE_UNDEFINED);/*in ogni caso assiste*/ else hit(ch, FIGHTING(ch->master), TYPE_UNDEFINED);/*in ogni caso assiste*/ } if (FIGHTING(ch)) { npc_rescue(ch, ch->master); if (WHOKILLED(ch->master)) hit(ch, WHOKILLED(ch->master), TYPE_UNDEFINED); /*in ogni caso assiste*/ continue; } } //MOB_THIEF if ( MOB_FLAGGED(ch, MOB_CRIMINAL) && (GET_POS(ch) == POS_RESTING) && IS_AFFECTED(ch, AFF_HIDE) && GET_HIT(ch) >= 2*GET_MAX_HIT(ch)/3) { appear(ch); GET_POS(ch)=POS_STANDING; } if ( MOB_FLAGGED(ch, MOB_CRIMINAL) && ( GET_POS(ch) == POS_STANDING) && ( (casual = number(0, 11)) < 6 ) ) { // 50% Rubare // cerca le vittime 1) Devono aver almeno 1 coin // 2) Deve aver una buona prob di farcela for (found=FALSE, min_vict = NULL, vict = world[ch->in_room].people; vict; vict = vict->next_in_room) { if (CAN_SEE(ch, vict) && (vict != ch)) { if ((min_vict == NULL) || (max_abil < 100)) { //se ha il 100% tanto vale fermarsi //Calcolo dell abilita:presa esattamente da D n'D curr_abil = MIN(90, (10*(GET_LEVEL(ch)) - 5*GET_LEVEL(vict))); curr_abil -= dex_app[GET_DEX(vict)].reaction; if (GET_POS(vict) < POS_STANDING) curr_abil += 200; // Se la vittima e' addormentata-stunned - incap o morta ovviamente // deruberai questa sicuramente if ( (curr_abil >= 40) && (GET_GOLD(vict) != 0) && (curr_abil > max_abil) ) { min_vict = vict; max_abil = curr_abil; found=TRUE; } } } } // Se ha trovato la vittima if (found == TRUE) { if ((casual = number(1, 100)) > max_abil) { if (!IS_NPC(min_vict)) act(" $n cerca di prendere dei soldi dal tuo Borsello", FALSE, ch, 0, min_vict, TO_CHAR); else { act("Oops...", FALSE, ch, 0, min_vict, TO_ROOM); act("$n cerca di rubare soldi a $N..Ma viene Scoperto! ", FALSE, ch, 0, min_vict, TO_ROOM); } //Beccato ... fa 2 tentativi di fuga if (((door = number(1, 7)) < NUM_OF_DIRS) && CAN_GO(ch, door) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) ) perform_move(ch,door,1,CAN_SHOW_ROOM); if ((door -= 1) < NUM_OF_DIRS && CAN_GO(ch, door) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) ) perform_move(ch,door,1,CAN_SHOW_ROOM); if ((door += 2) < NUM_OF_DIRS && CAN_GO(ch, door) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) ) perform_move(ch,door,1,CAN_SHOW_ROOM); if (IS_NPC(min_vict)) { act("$n Urla: $N e' uno sporco LADRO!!!!", FALSE, min_vict, 0, ch, TO_ROOM); hit(min_vict, ch, TYPE_UNDEFINED); } } // Il Bastardo ce la fa! else { if (GET_POS(min_vict) < 5) { GET_GOLD(ch) += GET_GOLD(min_vict); GET_GOLD(min_vict) = 0; //la ripulisce completamente } else { gold = number((GET_GOLD(min_vict) / 10), (GET_GOLD(min_vict) / 2)); //gold = MIN(5000, gold); if (gold > 0) { GET_GOLD(ch) += gold; GET_GOLD(min_vict) -= gold; if (GET_GOLD(min_vict) < 0) GET_GOLD(min_vict) = 0; } } // Dopo il furto si allontana if (((door = number(1, 6)) < NUM_OF_DIRS) && CAN_GO(ch, door) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) ) perform_move(ch,door,1,CAN_SHOW_ROOM); if ((door -=1) < NUM_OF_DIRS && CAN_GO(ch, door) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) ) perform_move(ch,door,1,CAN_SHOW_ROOM); if ((door +=2) < NUM_OF_DIRS && CAN_GO(ch, door) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) ) perform_move(ch,door,1,CAN_SHOW_ROOM); } } else { // Nessuna vittima appetibile:se ne va! if (((door = number(0, 6)) < NUM_OF_DIRS) && CAN_GO(ch, door) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) ) perform_move(ch, door, 1, CAN_SHOW_ROOM); } } // Mob Sciacalli indossano EQ if (MOB_FLAGGED(ch, MOB_NECRO) && !FIGHTING(ch) && AWAKE(ch)) if (world[ch->in_room].contents) { max = -1000; best_obj=NULL; for (cont = world[ch->in_room].contents;cont;cont = cont->next_content) if (GET_OBJ_TYPE(cont) == ITEM_CONTAINER) { for (obj = cont->contains; obj; obj = next_obj) { next_obj = obj->next_content; if (obj != NULL) { if (CAN_SEE_OBJ(ch, obj) && ( (max = objlevel(obj)) <= GET_LEVEL(ch)) ) { perform_get_from_container(ch, obj, cont, FIND_OBJ_INV); if (obj != NULL) { where = find_eq_pos(ch, obj, 0); if (CAN_WEAR(obj, ITEM_WEAR_HOLD)) where = WEAR_HOLD; if (GET_OBJ_TYPE(obj)==ITEM_LIGHT) where = WEAR_LIGHT; if (CAN_WEAR(obj, ITEM_WEAR_WIELD)) where = WEAR_WIELD; if (where < 0) { sprintf(buf,"SYSERR:pos < 0 ,in cont %s obj %d %s In room %d", cont->name, GET_OBJ_RNUM(obj), obj->name, IN_ROOM(ch)); log(buf); where = NUM_WEARS; } if (GET_EQ(ch, where) && where < NUM_WEARS) { if ((objlevel((ch)->equipment[where])) < objlevel(obj)) { obj_to_char((best_obj = unequip_char(ch, where)), ch); act("$n smette di usare $p.",FALSE, ch, best_obj, 0, TO_ROOM); } else where = NUM_WEARS; } if (where >= 0 && where < NUM_WEARS) { wear_message(ch, obj, where); obj_from_char(obj); equip_char(ch, obj, where); } } } } } } //End forif } //End ifif // Mob Movement if (HUNTING(ch)) hunt_victim(ch); else { if (MOB_FLAGGED(ch , MOB_SEARCHER)) {} else { if (ch->in_room != NOWHERE) { if (!IS_IN_WILD(ch)) { if ( !MOB_FLAGGED(ch, MOB_SENTINEL) && (GET_POS(ch) == POS_STANDING) && ( (door = number(0, 8)) < NUM_OF_DIRS) && CAN_GO(ch, door) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB | ROOM_DEATH) && ( !MOB_FLAGGED(ch, MOB_STAY_ZONE) || (world[EXIT(ch, door)->to_room].zone == world[ch->in_room].zone))) { perform_move(ch, door, 1, CAN_SHOW_ROOM); } } else { // E' in wilderness if (MOB_FLAGGED(ch, MOB_WILDHUNT)) door = wild_mobhunter(ch); else door = number(0, 8); if (door >= 0 && door < NUM_OF_DIRS) target_room = wild_target_room(ch, door); else target_room = -1; if ( !MOB_FLAGGED(ch, MOB_SENTINEL) && (GET_POS(ch) == POS_STANDING) && (target_room != -1) && ( !MOB_FLAGGED(ch, MOB_STAY_ZONE) || (world[target_room].wild_rnum == world[ch->in_room].wild_rnum))) { perform_move(ch, door, 1, CAN_SHOW_ROOM); } } } } } // Aggressive Mobs if (MOB_FLAGGED(ch, MOB_AGGRESSIVE | MOB_AGGR_TO_ALIGN)) { found = FALSE; for (vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room) { if (IS_NPC(vict) || !CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE)) continue; if (number(0, 3) < 2) continue; // Simple simulate Random a Joke from Phantom ;P if (GET_ABIL (vict, ABIL_TRATTATIVA) >= EXPERT_LIV) continue; // I pg con trattativa ad esperto fanno pace con gli aggressivi (by Spini) if (controllo_volo(ch, vict)) continue; if (affected_by_spell (vict, SPELLSKILL, DISEASE_PESTE)) continue; if (MOB_FLAGGED(ch, MOB_AGGR_NO_PROP) && (MASTER_ID(ch)==GET_IDNUM(vict))) continue; if (MOB_FLAGGED(ch, MOB_AGGR_NO_CLAN) && (CLAN_ID(ch)==GET_CLAN(vict))) continue; if (MOB_FLAGGED(ch, MOB_AGGR_NO_AL_CLAN) && (GET_CLAN_DIPLO(GET_CLAN(ch),GET_CLAN(vict)) == ALLIANCE)) continue; if (MOB_FLAGGED(ch, MOB_AGGR_NO_EN_CLAN) && (GET_CLAN_DIPLO(GET_CLAN(ch),GET_CLAN(vict)) == WAR)) continue; if (MOB_FLAGGED(ch, MOB_AGGR_NO_PC_CLAN) && (GET_CLAN_DIPLO(GET_CLAN(ch),GET_CLAN(vict)) == PEACE)) continue; if (MOB_FLAGGED(ch, MOB_AGGR_VAS_CLAN) && (GET_CLAN_DIPLO(GET_CLAN(ch),GET_CLAN(vict)) == VASSALLO)) continue; if ( !MOB_FLAGGED(ch, MOB_AGGR_TO_ALIGN) || (MOB_FLAGGED(ch, MOB_AGGR_EVIL) && IS_EVIL(vict)) || (MOB_FLAGGED(ch, MOB_AGGR_NEUTRAL) && IS_NEUTRAL(vict)) || (MOB_FLAGGED(ch, MOB_AGGR_GOOD) && IS_GOOD(vict)) ) { if (GET_MOB_SPEC(ch)== thief) npc_backstab(ch,vict); else hit(ch, vict, TYPE_UNDEFINED); found = TRUE; } } } // Mob Memory if (MOB_FLAGGED(ch, MOB_MEMORY) && MEMORY(ch)) { found = FALSE; for (vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room) { if (!CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE)) continue; for (names = MEMORY(ch); names && !found; names = names->next) if (names->id == GET_IDNUM(vict)) { found = TRUE; act("$n esclama, 'Hey!! Tu sei il tipo che mi ha attaccato!!!'", FALSE, ch, 0, 0, TO_ROOM); hit(ch, vict, TYPE_UNDEFINED); } //End forif } } // Helper Mobs Paladino del bene if ( MOB_FLAGGED(ch, MOB_HELPER) && !MOB_FLAGGED(ch, MOB_CRIMINALHELPER) ) { found = FALSE; for (vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room) if ( ch != vict && IS_NPC(vict) && FIGHTING(vict) && !IS_NPC(FIGHTING(vict)) && ch != FIGHTING(vict) ) { if ( MOB_FLAGGED(vict, MOB_CRIMINAL) || ( (ch->master) && (FIGHTING(vict) == ch->master) ) ) { hit(ch, vict, TYPE_UNDEFINED); found = TRUE; } else { act("$n arriva in aiuto di $N!", FALSE, ch, 0, vict, TO_ROOM); hit(ch, FIGHTING(vict), TYPE_UNDEFINED); found = TRUE; } } //End forif } // Helper Mobs Servo del male if ( MOB_FLAGGED(ch, MOB_CRIMINALHELPER) && !MOB_FLAGGED(ch, MOB_HELPER) ) { found = FALSE; for (vict = world[ch->in_room].people; vict && !found; vict = vict->next_in_room) if ( ch != vict && IS_NPC(vict) && FIGHTING(vict) && !IS_NPC(FIGHTING(vict)) && ch != FIGHTING(vict) ) { if ( MOB_FLAGGED(vict, MOB_CRIMINAL) || ( (ch->master) && (vict == ch->master) ) ) { act("$n arriva in aiuto di $N!", FALSE, ch, 0, vict, TO_ROOM); hit(ch, FIGHTING(vict), TYPE_UNDEFINED); found = TRUE; } } //End forif } // Add new mobile actions here } // end for() }
void medit_disp_menu(struct descriptor_data *d) { int base = calc_karma(NULL, MOB); CLS(CH); send_to_char(CH, "Mob number: %s%d%s\r\n", CCCYN(CH, C_CMP), d->edit_number, CCNRM(CH, C_CMP)); send_to_char(CH, "1) Keywords: %s%s%s\r\n", CCCYN(CH, C_CMP), MOB->player.physical_text.keywords, CCNRM(CH, C_CMP)); send_to_char(CH, "2) Name: %s%s%s\r\n", CCCYN(CH, C_CMP), MOB->player.physical_text.name, CCNRM(CH, C_CMP)); send_to_char(CH, "3) Room description:\r\n%s%s%s\r\n", CCCYN(CH, C_CMP), MOB->player.physical_text.room_desc,CCNRM(CH, C_CMP)); send_to_char(CH, "4) Look description:\r\n%s\r\n", MOB->player.physical_text.look_desc); MOB_FLAGS(MOB).PrintBits(buf1, MAX_STRING_LENGTH, action_bits, MOB_MAX); send_to_char(CH, "5) Mob Flags: %s%s%s\r\n", CCCYN(CH, C_CMP), buf1, CCNRM(CH, C_CMP)); MOB->char_specials.saved.affected_by.PrintBits(buf1, MAX_STRING_LENGTH, affected_bits, AFF_MAX); send_to_char(CH, "6) Affected Flags: %s%s%s\r\n", CCCYN(CH, C_CMP), buf1, CCNRM(CH, C_CMP)); send_to_char(CH, "8) Avg. nuyen: %s%6d%s Avg. credstick value: %s%6d%s\r\n", CCCYN(CH, C_CMP), GET_NUYEN(MOB), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), GET_BANK(MOB), CCNRM(CH, C_CMP)); send_to_char(CH, "9) Bonus karma points: %s%d%s (Total karma points: %s%d%s)\r\n", CCCYN(CH, C_CMP), GET_KARMA(MOB), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), base, CCNRM(CH, C_CMP)); send_to_char(CH, "a) Attributes: B(%s%d%s), Q(%s%d%s), S(%s%d%s), C(%s%d%s), " "I(%s%d%s), W(%s%d%s), M(%s%d%s), R(%s%d%s)\r\n", CCCYN(CH, C_CMP), GET_REAL_BOD(MOB), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), GET_REAL_QUI(MOB), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), GET_REAL_STR(MOB), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), GET_REAL_CHA(MOB), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), GET_REAL_INT(MOB), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), GET_REAL_WIL(MOB), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), MOB->real_abils.mag / 100, CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), GET_REAL_REA(MOB), CCNRM(CH, C_CMP)); send_to_char(CH, "b) Level: %s%d%s\r\n", CCCYN(CH, C_CMP), GET_LEVEL(MOB), CCNRM(CH, C_CMP)); send_to_char(CH, "c) Ballistic: %s%d%s, ", CCCYN(CH, C_CMP), GET_BALLISTIC(MOB), CCNRM(CH, C_CMP)); send_to_char(CH, "d) Impact: %s%d%s\r\n", CCCYN(CH, C_CMP), GET_IMPACT(MOB), CCNRM(CH, C_CMP)); send_to_char(CH, "e) Max physical points: %s%d%s, f) Max mental points: %s%d%s\r\n", CCCYN(CH, C_CMP), (int)(GET_MAX_PHYSICAL(MOB) / 100), CCNRM(CH, C_CMP), CCCYN(CH, C_CMP), (int)(GET_MAX_MENTAL(MOB) / 100), CCNRM(CH, C_CMP)); sprinttype(GET_POS(MOB), position_types, buf1); send_to_char(CH, "g) Position: %s%s%s, ", CCCYN(CH, C_CMP), buf1, CCNRM(CH, C_CMP)); sprinttype(GET_DEFAULT_POS(MOB), position_types, buf1); send_to_char(CH, "h) Default Position: %s%s%s\r\n", CCCYN(CH, C_CMP), buf1, CCNRM(CH, C_CMP)); sprinttype(GET_SEX(MOB), genders, buf1); // strcpy(buf1, genders[GET_SEX(d->edit_mob)]); send_to_char(CH, "i) Gender: %s%s%s, ", CCCYN(CH, C_CMP), buf1, CCNRM(CH, C_CMP)); send_to_char(CH, "j) Weight: %s%d%s, ", CCCYN(CH, C_CMP), GET_WEIGHT(MOB), CCNRM(CH, C_CMP)); send_to_char(CH, "k) Height: %s%d%s\r\n", CCCYN(CH, C_CMP), GET_HEIGHT(MOB), CCNRM(CH, C_CMP)); sprinttype(GET_RACE(MOB), npc_classes, buf1); send_to_char(CH, "l) Mob class: %s%s%s\r\n", CCCYN(CH, C_CMP), buf1, CCNRM(CH, C_CMP)); // gotta subtract TYPE_HIT to make it work properly sprinttype(!(MOB->mob_specials.attack_type) ? 0 : (MOB->mob_specials.attack_type - TYPE_HIT), attack_types, buf1); send_to_char(CH, "m) Attack Type: %s%s%s\r\n", CCCYN(CH, C_CMP), buf1, CCNRM(CH, C_CMP)); send_to_char("n) Skill menu.\r\n", CH); send_to_char(CH, "o) Arrive text: ^c%s^n, p) Leave text: ^c%s^n\r\n", MOB->mob_specials.arrive, MOB->mob_specials.leave); send_to_char("q) Quit and save\r\n", CH); send_to_char("x) Exit and abort\r\n", CH); send_to_char("Enter your choice:\r\n", CH); d->edit_mode = MEDIT_MAIN_MENU; }
void mobile_activity(void) { struct char_data *ch, *next_ch, *vict; struct obj_data *obj, *best_obj; int door, found, max; memory_rec *names; for (ch = character_list; ch; ch = next_ch) { next_ch = ch->next; if (!IS_MOB(ch)) continue; /* Examine call for special procedure */ if (MOB_FLAGGED(ch, MOB_SPEC) && !no_specials) { if (mob_index[GET_MOB_RNUM(ch)].func == NULL) { log("SYSERR: %s (#%d): Attempting to call non-existing mob function.", GET_NAME(ch), GET_MOB_VNUM(ch)); REMOVE_BIT_AR(MOB_FLAGS(ch), MOB_SPEC); } else { char actbuf[MAX_INPUT_LENGTH] = ""; if ((mob_index[GET_MOB_RNUM(ch)].func) (ch, ch, 0, actbuf)) continue; /* go to next char */ } } /* If the mob has no specproc, do the default actions */ if (FIGHTING(ch) || !AWAKE(ch)) continue; /* hunt a victim, if applicable */ hunt_victim(ch); /* Scavenger (picking up objects) */ if (MOB_FLAGGED(ch, MOB_SCAVENGER)) if (world[IN_ROOM(ch)].contents && !rand_number(0, 10)) { max = 1; best_obj = NULL; for (obj = world[IN_ROOM(ch)].contents; obj; obj = obj->next_content) if (CAN_GET_OBJ(ch, obj) && GET_OBJ_COST(obj) > max) { best_obj = obj; max = GET_OBJ_COST(obj); } if (best_obj != NULL) { obj_from_room(best_obj); obj_to_char(best_obj, ch); act("$n gets $p.", FALSE, ch, best_obj, 0, TO_ROOM); } } /* Mob Movement */ if (!MOB_FLAGGED(ch, MOB_SENTINEL) && (GET_POS(ch) == POS_STANDING) && ((door = rand_number(0, 18)) < DIR_COUNT) && CAN_GO(ch, door) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_NOMOB) && !ROOM_FLAGGED(EXIT(ch, door)->to_room, ROOM_DEATH) && (!MOB_FLAGGED(ch, MOB_STAY_ZONE) || (world[EXIT(ch, door)->to_room].zone == world[IN_ROOM(ch)].zone))) { /* If the mob is charmed, do not move the mob. */ if (ch->master == NULL) perform_move(ch, door, 1); } /* Aggressive Mobs */ if (!MOB_FLAGGED(ch, MOB_HELPER) && (!AFF_FLAGGED(ch, AFF_BLIND) || !AFF_FLAGGED(ch, AFF_CHARM))) { found = FALSE; for (vict = world[IN_ROOM(ch)].people; vict && !found; vict = vict->next_in_room) { if (IS_NPC(vict) || !CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE)) continue; if (MOB_FLAGGED(ch, MOB_WIMPY) && AWAKE(vict)) continue; if (MOB_FLAGGED(ch, MOB_AGGRESSIVE ) || (MOB_FLAGGED(ch, MOB_AGGR_EVIL ) && IS_EVIL(vict)) || (MOB_FLAGGED(ch, MOB_AGGR_NEUTRAL) && IS_NEUTRAL(vict)) || (MOB_FLAGGED(ch, MOB_AGGR_GOOD ) && IS_GOOD(vict))) { /* Can a master successfully control the charmed monster? */ if (aggressive_mob_on_a_leash(ch, ch->master, vict)) continue; hit(ch, vict, TYPE_UNDEFINED); found = TRUE; } } } /* Mob Memory */ if (MOB_FLAGGED(ch, MOB_MEMORY) && MEMORY(ch)) { found = FALSE; for (vict = world[IN_ROOM(ch)].people; vict && !found; vict = vict->next_in_room) { if (IS_NPC(vict) || !CAN_SEE(ch, vict) || PRF_FLAGGED(vict, PRF_NOHASSLE)) continue; for (names = MEMORY(ch); names && !found; names = names->next) { if (names->id != GET_IDNUM(vict)) continue; /* Can a master successfully control the charmed monster? */ if (aggressive_mob_on_a_leash(ch, ch->master, vict)) continue; found = TRUE; act("'Hey! You're the fiend that attacked me!!!', exclaims $n.", FALSE, ch, 0, 0, TO_ROOM); hit(ch, vict, TYPE_UNDEFINED); } } } /* Charmed Mob Rebellion: In order to rebel, there need to be more charmed * monsters than the person can feasibly control at a time. Then the * mobiles have a chance based on the charisma of their leader. * 1-4 = 0, 5-7 = 1, 8-10 = 2, 11-13 = 3, 14-16 = 4, 17-19 = 5, etc. */ if (AFF_FLAGGED(ch, AFF_CHARM) && ch->master && num_followers_charmed(ch->master) > (GET_CHA(ch->master) - 2) / 3) { if (!aggressive_mob_on_a_leash(ch, ch->master, ch->master)) { if (CAN_SEE(ch, ch->master) && !PRF_FLAGGED(ch->master, PRF_NOHASSLE)) hit(ch, ch->master, TYPE_UNDEFINED); stop_follower(ch); } } /* Helper Mobs */ if (MOB_FLAGGED(ch, MOB_HELPER) && (!AFF_FLAGGED(ch, AFF_BLIND) || !AFF_FLAGGED(ch, AFF_CHARM))) { found = FALSE; for (vict = world[IN_ROOM(ch)].people; vict && !found; vict = vict->next_in_room) { if (ch == vict || !IS_NPC(vict) || !FIGHTING(vict)) continue; if (IS_NPC(FIGHTING(vict)) || ch == FIGHTING(vict)) continue; act("$n jumps to the aid of $N!", FALSE, ch, 0, vict, TO_ROOM); hit(ch, FIGHTING(vict), TYPE_UNDEFINED); found = TRUE; } } /* Add new mobile actions here */ } /* end for() */ }
void medit_parse(struct descriptor_data *d, char *arg) { int i = -1, j; char *oldtext = NULL; if (OLC_MODE(d) > MEDIT_NUMERICAL_RESPONSE) { i = atoi(arg); if (!*arg || (!isdigit(arg[0]) && ((*arg == '-') && !isdigit(arg[1])))) { write_to_output(d, "Try again : "); return; } } else { /* String response. */ if (!genolc_checkstring(d, arg)) return; } switch (OLC_MODE(d)) { case MEDIT_CONFIRM_SAVESTRING: /* Ensure mob has MOB_ISNPC set. */ SET_BIT_AR(MOB_FLAGS(OLC_MOB(d)), MOB_ISNPC); switch (*arg) { case 'y': case 'Y': /* Save the mob in memory and to disk. */ medit_save_internally(d); mudlog(CMP, MAX(LVL_BUILDER, GET_INVIS_LEV(d->character)), TRUE, "OLC: %s edits mob %d", GET_NAME(d->character), OLC_NUM(d)); if (CONFIG_OLC_SAVE) { medit_save_to_disk(zone_table[real_zone_by_thing(OLC_NUM(d))].number); write_to_output(d, "Mobile saved to disk.\r\n"); } else write_to_output(d, "Mobile saved to memory.\r\n"); cleanup_olc(d, CLEANUP_ALL); return; case 'n': case 'N': /* If not saving, we must free the script_proto list. We do so by * assigning it to the edited mob and letting free_mobile in * cleanup_olc handle it. */ OLC_MOB(d)->proto_script = OLC_SCRIPT(d); cleanup_olc(d, CLEANUP_ALL); return; default: write_to_output(d, "Invalid choice!\r\n"); write_to_output(d, "Do you wish to save your changes? : "); return; } break; case MEDIT_MAIN_MENU: i = 0; switch (*arg) { case 'q': case 'Q': if (OLC_VAL(d)) { /* Anything been changed? */ write_to_output(d, "Do you wish to save your changes? : "); OLC_MODE(d) = MEDIT_CONFIRM_SAVESTRING; } else cleanup_olc(d, CLEANUP_ALL); return; case '1': OLC_MODE(d) = MEDIT_SEX; medit_disp_sex(d); return; case '2': OLC_MODE(d) = MEDIT_KEYWORD; i--; break; case '3': OLC_MODE(d) = MEDIT_S_DESC; i--; break; case '4': OLC_MODE(d) = MEDIT_L_DESC; i--; break; case '5': OLC_MODE(d) = MEDIT_D_DESC; send_editor_help(d); write_to_output(d, "Enter mob description:\r\n\r\n"); if (OLC_MOB(d)->player.description) { write_to_output(d, "%s", OLC_MOB(d)->player.description); oldtext = strdup(OLC_MOB(d)->player.description); } string_write(d, &OLC_MOB(d)->player.description, MAX_MOB_DESC, 0, oldtext); OLC_VAL(d) = 1; return; case '6': OLC_MODE(d) = MEDIT_POS; medit_disp_positions(d); return; case '7': OLC_MODE(d) = MEDIT_DEFAULT_POS; medit_disp_positions(d); return; case '8': OLC_MODE(d) = MEDIT_ATTACK; medit_disp_attack_types(d); return; case '9': OLC_MODE(d) = MEDIT_STATS_MENU; medit_disp_stats_menu(d); return; case 'a': case 'A': OLC_MODE(d) = MEDIT_NPC_FLAGS; medit_disp_mob_flags(d); return; case 'b': case 'B': OLC_MODE(d) = MEDIT_AFF_FLAGS; medit_disp_aff_flags(d); return; case 'w': case 'W': write_to_output(d, "Copy what mob? "); OLC_MODE(d) = MEDIT_COPY; return; case 'x': case 'X': write_to_output(d, "Are you sure you want to delete this mobile? "); OLC_MODE(d) = MEDIT_DELETE; return; case 's': case 'S': OLC_SCRIPT_EDIT_MODE(d) = SCRIPT_MAIN_MENU; dg_script_menu(d); return; default: medit_disp_menu(d); return; } if (i == 0) break; else if (i == 1) write_to_output(d, "\r\nEnter new value : "); else if (i == -1) write_to_output(d, "\r\nEnter new text :\r\n] "); else write_to_output(d, "Oops...\r\n"); return; case MEDIT_STATS_MENU: i=0; switch(*arg) { case 'q': case 'Q': medit_disp_menu(d); return; case '1': /* Edit level */ OLC_MODE(d) = MEDIT_LEVEL; i++; break; case '2': /* Autoroll stats */ medit_autoroll_stats(d); medit_disp_stats_menu(d); OLC_VAL(d) = TRUE; return; case '3': OLC_MODE(d) = MEDIT_NUM_HP_DICE; i++; break; case '4': OLC_MODE(d) = MEDIT_SIZE_HP_DICE; i++; break; case '5': OLC_MODE(d) = MEDIT_ADD_HP; i++; break; case '6': OLC_MODE(d) = MEDIT_NDD; i++; break; case '7': OLC_MODE(d) = MEDIT_SDD; i++; break; case '8': OLC_MODE(d) = MEDIT_DAMROLL; i++; break; case 'a': case 'A': OLC_MODE(d) = MEDIT_AC; i++; break; case 'b': case 'B': OLC_MODE(d) = MEDIT_EXP; i++; break; case 'c': case 'C': OLC_MODE(d) = MEDIT_GOLD; i++; break; case 'd': case 'D': OLC_MODE(d) = MEDIT_HITROLL; i++; break; case 'e': case 'E': OLC_MODE(d) = MEDIT_ALIGNMENT; i++; break; case 'f': case 'F': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_STR; i++; break; case 'g': case 'G': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_INT; i++; break; case 'h': case 'H': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_WIS; i++; break; case 'i': case 'I': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_DEX; i++; break; case 'j': case 'J': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_CON; i++; break; case 'k': case 'K': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_CHA; i++; break; case 'l': case 'L': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_PARA; i++; break; case 'm': case 'M': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_ROD; i++; break; case 'n': case 'N': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_PETRI; i++; break; case 'o': case 'O': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_BREATH; i++; break; case 'p': case 'P': if (!CONFIG_MEDIT_ADVANCED) { write_to_output(d, "Invalid Choice!\r\nEnter Choice : "); return; } OLC_MODE(d) = MEDIT_SPELL; i++; break; default: medit_disp_stats_menu(d); return; } if (i == 0) break; else if (i == 1) write_to_output(d, "\r\nEnter new value : "); else if (i == -1) write_to_output(d, "\r\nEnter new text :\r\n] "); else write_to_output(d, "Oops...\r\n"); return; case OLC_SCRIPT_EDIT: if (dg_script_edit_parse(d, arg)) return; break; case MEDIT_KEYWORD: smash_tilde(arg); if (GET_ALIAS(OLC_MOB(d))) free(GET_ALIAS(OLC_MOB(d))); GET_ALIAS(OLC_MOB(d)) = str_udup(arg); break; case MEDIT_S_DESC: smash_tilde(arg); if (GET_SDESC(OLC_MOB(d))) free(GET_SDESC(OLC_MOB(d))); GET_SDESC(OLC_MOB(d)) = str_udup(arg); break; case MEDIT_L_DESC: smash_tilde(arg); if (GET_LDESC(OLC_MOB(d))) free(GET_LDESC(OLC_MOB(d))); if (arg && *arg) { char buf[MAX_INPUT_LENGTH]; snprintf(buf, sizeof(buf), "%s\r\n", arg); GET_LDESC(OLC_MOB(d)) = strdup(buf); } else GET_LDESC(OLC_MOB(d)) = strdup("undefined"); break; case MEDIT_D_DESC: /* * We should never get here. */ cleanup_olc(d, CLEANUP_ALL); mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: OLC: medit_parse(): Reached D_DESC case!"); write_to_output(d, "Oops...\r\n"); break; case MEDIT_NPC_FLAGS: if ((i = atoi(arg)) <= 0) break; else if ( (j = medit_get_mob_flag_by_number(i)) == -1) { write_to_output(d, "Invalid choice!\r\n"); write_to_output(d, "Enter mob flags (0 to quit) :"); return; } else if (j <= NUM_MOB_FLAGS) { TOGGLE_BIT_AR(MOB_FLAGS(OLC_MOB(d)), (j)); } medit_disp_mob_flags(d); return; case MEDIT_AFF_FLAGS: if ((i = atoi(arg)) <= 0) break; else if (i <= NUM_AFF_FLAGS) TOGGLE_BIT_AR(AFF_FLAGS(OLC_MOB(d)), i); /* Remove unwanted bits right away. */ REMOVE_BIT_AR(AFF_FLAGS(OLC_MOB(d)), AFF_CHARM); REMOVE_BIT_AR(AFF_FLAGS(OLC_MOB(d)), AFF_POISON); REMOVE_BIT_AR(AFF_FLAGS(OLC_MOB(d)), AFF_GROUP); REMOVE_BIT_AR(AFF_FLAGS(OLC_MOB(d)), AFF_SLEEP); medit_disp_aff_flags(d); return; /* Numerical responses. */ case MEDIT_SEX: GET_SEX(OLC_MOB(d)) = LIMIT(i - 1, 0, NUM_GENDERS - 1); break; case MEDIT_HITROLL: GET_HITROLL(OLC_MOB(d)) = LIMIT(i, 0, 50); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_DAMROLL: GET_DAMROLL(OLC_MOB(d)) = LIMIT(i, 0, 50); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_NDD: GET_NDD(OLC_MOB(d)) = LIMIT(i, 0, 30); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_SDD: GET_SDD(OLC_MOB(d)) = LIMIT(i, 0, 127); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_NUM_HP_DICE: GET_HIT(OLC_MOB(d)) = LIMIT(i, 0, 30); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_SIZE_HP_DICE: GET_MANA(OLC_MOB(d)) = LIMIT(i, 0, 1000); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_ADD_HP: GET_MOVE(OLC_MOB(d)) = LIMIT(i, 0, 30000); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_AC: GET_AC(OLC_MOB(d)) = LIMIT(i, -200, 200); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_EXP: GET_EXP(OLC_MOB(d)) = LIMIT(i, 0, MAX_MOB_EXP); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_GOLD: GET_GOLD(OLC_MOB(d)) = LIMIT(i, 0, MAX_MOB_GOLD); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_STR: GET_STR(OLC_MOB(d)) = LIMIT(i, 11, 25); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_INT: GET_INT(OLC_MOB(d)) = LIMIT(i, 11, 25); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_WIS: GET_WIS(OLC_MOB(d)) = LIMIT(i, 11, 25); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_DEX: GET_DEX(OLC_MOB(d)) = LIMIT(i, 11, 25); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_CON: GET_CON(OLC_MOB(d)) = LIMIT(i, 11, 25); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_CHA: GET_CHA(OLC_MOB(d)) = LIMIT(i, 11, 25); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_PARA: GET_SAVE(OLC_MOB(d), SAVING_PARA) = LIMIT(i, 0, 100); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_ROD: GET_SAVE(OLC_MOB(d), SAVING_ROD) = LIMIT(i, 0, 100); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_PETRI: GET_SAVE(OLC_MOB(d), SAVING_PETRI) = LIMIT(i, 0, 100); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_BREATH: GET_SAVE(OLC_MOB(d), SAVING_BREATH) = LIMIT(i, 0, 100); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_SPELL: GET_SAVE(OLC_MOB(d), SAVING_SPELL) = LIMIT(i, 0, 100); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_POS: GET_POS(OLC_MOB(d)) = LIMIT(i - 1, 0, NUM_POSITIONS - 1); break; case MEDIT_DEFAULT_POS: GET_DEFAULT_POS(OLC_MOB(d)) = LIMIT(i - 1, 0, NUM_POSITIONS - 1); break; case MEDIT_ATTACK: GET_ATTACK(OLC_MOB(d)) = LIMIT(i, 0, NUM_ATTACK_TYPES - 1); break; case MEDIT_LEVEL: GET_LEVEL(OLC_MOB(d)) = LIMIT(i, 1, LVL_IMPL); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_ALIGNMENT: GET_ALIGNMENT(OLC_MOB(d)) = LIMIT(i, -1000, 1000); OLC_VAL(d) = TRUE; medit_disp_stats_menu(d); return; case MEDIT_COPY: if ((i = real_mobile(atoi(arg))) != NOWHERE) { medit_setup_existing(d, i); } else write_to_output(d, "That mob does not exist.\r\n"); break; case MEDIT_DELETE: if (*arg == 'y' || *arg == 'Y') { if (delete_mobile(GET_MOB_RNUM(OLC_MOB(d))) != NOBODY) write_to_output(d, "Mobile deleted.\r\n"); else write_to_output(d, "Couldn't delete the mobile!\r\n"); cleanup_olc(d, CLEANUP_ALL); return; } else if (*arg == 'n' || *arg == 'N') { medit_disp_menu(d); OLC_MODE(d) = MEDIT_MAIN_MENU; return; } else write_to_output(d, "Please answer 'Y' or 'N': "); break; default: /* We should never get here. */ cleanup_olc(d, CLEANUP_ALL); mudlog(BRF, LVL_BUILDER, TRUE, "SYSERR: OLC: medit_parse(): Reached default case!"); write_to_output(d, "Oops...\r\n"); break; } /* END OF CASE If we get here, we have probably changed something, and now want to return to main menu. Use OLC_VAL as a 'has changed' flag */ OLC_VAL(d) = TRUE; medit_disp_menu(d); }
int save_mobiles(zone_rnum rznum) { zone_vnum vznum; FILE *mobfd; room_vnum i; mob_rnum rmob; int written; char mobfname[64], usedfname[64]; #if CIRCLE_UNSIGNED_INDEX if (rznum == NOWHERE || rznum > top_of_zone_table) { #else if (rznum < 0 || rznum > top_of_zone_table) { #endif log("SYSERR: GenOLC: save_mobiles: Invalid real zone number %d. (0-%d)", rznum, top_of_zone_table); return FALSE; } vznum = zone_table[rznum].number; snprintf(mobfname, sizeof(mobfname), "%s%d.new", MOB_PREFIX, vznum); if ((mobfd = fopen(mobfname, "w")) == NULL) { mudlog(BRF, LVL_GOD, TRUE, "SYSERR: GenOLC: Cannot open mob file for writing."); return FALSE; } for (i = genolc_zone_bottom(rznum); i <= zone_table[rznum].top; i++) { if ((rmob = real_mobile(i)) == NOBODY) continue; check_mobile_strings(&mob_proto[rmob]); if (write_mobile_record(i, &mob_proto[rmob], mobfd) < 0) log("SYSERR: GenOLC: Error writing mobile #%d.", i); } fputs("$\n", mobfd); written = ftell(mobfd); fclose(mobfd); snprintf(usedfname, sizeof(usedfname), "%s%d.mob", MOB_PREFIX, vznum); remove(usedfname); rename(mobfname, usedfname); if (in_save_list(vznum, SL_MOB)) remove_from_save_list(vznum, SL_MOB); log("GenOLC: '%s' saved, %d bytes written.", usedfname, written); return written; } int write_mobile_espec(mob_vnum mvnum, struct char_data *mob, FILE *fd) { if (GET_ATTACK(mob) != 0) fprintf(fd, "BareHandAttack: %d\n", GET_ATTACK(mob)); if (GET_STR(mob) != 11) fprintf(fd, "Str: %d\n", GET_STR(mob)); if (GET_ADD(mob) != 0) fprintf(fd, "StrAdd: %d\n", GET_ADD(mob)); if (GET_DEX(mob) != 11) fprintf(fd, "Dex: %d\n", GET_DEX(mob)); if (GET_INT(mob) != 11) fprintf(fd, "Int: %d\n", GET_INT(mob)); if (GET_WIS(mob) != 11) fprintf(fd, "Wis: %d\n", GET_WIS(mob)); if (GET_CON(mob) != 11) fprintf(fd, "Con: %d\n", GET_CON(mob)); if (GET_CHA(mob) != 11) fprintf(fd, "Cha: %d\n", GET_CHA(mob)); if (GET_SAVE(mob, SAVING_PARA) != 0) fprintf(fd, "SavingPara: %d\n", GET_SAVE(mob, SAVING_PARA)); if (GET_SAVE(mob, SAVING_ROD) != 0) fprintf(fd, "SavingRod: %d\n", GET_SAVE(mob, SAVING_ROD)); if (GET_SAVE(mob, SAVING_PETRI) != 0) fprintf(fd, "SavingPetri: %d\n", GET_SAVE(mob, SAVING_PETRI)); if (GET_SAVE(mob, SAVING_BREATH) != 0) fprintf(fd, "SavingBreath: %d\n", GET_SAVE(mob, SAVING_BREATH)); if (GET_SAVE(mob, SAVING_SPELL) != 0) fprintf(fd, "SavingSpell: %d\n", GET_SAVE(mob, SAVING_SPELL)); fputs("E\n", fd); return TRUE; } int write_mobile_record(mob_vnum mvnum, struct char_data *mob, FILE *fd) { char ldesc[MAX_STRING_LENGTH]; char ddesc[MAX_STRING_LENGTH]; char buf[MAX_STRING_LENGTH]; ldesc[MAX_STRING_LENGTH - 1] = '\0'; ddesc[MAX_STRING_LENGTH - 1] = '\0'; strip_cr(strncpy(ldesc, GET_LDESC(mob), MAX_STRING_LENGTH - 1)); strip_cr(strncpy(ddesc, GET_DDESC(mob), MAX_STRING_LENGTH - 1)); int n = snprintf(buf, MAX_STRING_LENGTH, "#%d\n" "%s%c\n" "%s%c\n" "%s%c\n" "%s%c\n", mvnum, GET_ALIAS(mob), STRING_TERMINATOR, GET_SDESC(mob), STRING_TERMINATOR, ldesc, STRING_TERMINATOR, ddesc, STRING_TERMINATOR ); if(n < MAX_STRING_LENGTH) { fprintf(fd, "%s", convert_from_tabs(buf)); fprintf(fd, "%d %d %d %d %d %d %d %d %d E\n" "%d %d %d %dd%d+%d %dd%d+%d\n", MOB_FLAGS(mob)[0], MOB_FLAGS(mob)[1], MOB_FLAGS(mob)[2], MOB_FLAGS(mob)[3], AFF_FLAGS(mob)[0], AFF_FLAGS(mob)[1], AFF_FLAGS(mob)[2], AFF_FLAGS(mob)[3], GET_ALIGNMENT(mob), GET_LEVEL(mob), 20 - GET_HITROLL(mob), GET_AC(mob) / 10, GET_HIT(mob), GET_MANA(mob), GET_MOVE(mob), GET_NDD(mob), GET_SDD(mob), GET_DAMROLL(mob)); 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) ); if (write_mobile_espec(mvnum, mob, fd) < 0) log("SYSERR: GenOLC: Error writing E-specs for mobile #%d.", mvnum); script_save_to_disk(fd, mob, MOB_TRIGGER); #if CONFIG_GENOLC_MOBPROG if (write_mobile_mobprog(mvnum, mob, fd) < 0) log("SYSERR: GenOLC: Error writing MobProgs for mobile #%d.", mvnum); #endif } else { mudlog(BRF,LVL_BUILDER,TRUE, "SYSERR: Could not save mobile #%d due to size (%d > maximum of %d)", mvnum, n, MAX_STRING_LENGTH); } return TRUE; }