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) != 0) 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) != 0) fprintf(fd, "Dex: %d\n", GET_DEX(mob)); if (GET_INT(mob) != 0) fprintf(fd, "Int: %d\n", GET_INT(mob)); if (GET_WIS(mob) != 0) fprintf(fd, "Wis: %d\n", GET_WIS(mob)); if (GET_CON(mob) != 0) fprintf(fd, "Con: %d\n", GET_CON(mob)); if (GET_CHA(mob) != 0) fprintf(fd, "Cha: %d\n", GET_CHA(mob)); if(GET_CLASS(mob) != CLASS_NPC_OTHER) fprintf(fd, "Class: %d\n", GET_CLASS(mob)); if(GET_RACE(mob) != RACE_NPC_OTHER) fprintf(fd, "Race: %d\n", GET_RACE(mob)); if(GET_MOB_WEIGHT(mob)) fprintf(fd, "Weight: %d\n", GET_MOB_WEIGHT(mob)); fprintf(fd, "Size: %d\n", GET_MOB_SIZE(mob)); fputs("E\n", fd); return TRUE; }
/* This updates a character by subtracting everything he is affected by * restoring original abilities, and then affecting all again. */ void affect_total(struct char_data *ch) { struct affected_type *af; int i, j; for (i = 0; i < NUM_WEARS; i++) { if (GET_EQ(ch, i)) for (j = 0; j < MAX_OBJ_AFFECT; j++) affect_modify_ar(ch, GET_EQ(ch, i)->affected[j].location, GET_EQ(ch, i)->affected[j].modifier, GET_OBJ_AFFECT(GET_EQ(ch, i)), FALSE); } for (af = ch->affected; af; af = af->next) affect_modify_ar(ch, af->location, af->modifier, af->bitvector, FALSE); ch->aff_abils = ch->real_abils; for (i = 0; i < NUM_WEARS; i++) { if (GET_EQ(ch, i)) for (j = 0; j < MAX_OBJ_AFFECT; j++) affect_modify_ar(ch, GET_EQ(ch, i)->affected[j].location, GET_EQ(ch, i)->affected[j].modifier, GET_OBJ_AFFECT(GET_EQ(ch, i)), TRUE); } for (af = ch->affected; af; af = af->next) affect_modify_ar(ch, af->location, af->modifier, af->bitvector, TRUE); /* Make certain values are between 0..25, not < 0 and not > 25! */ i = (IS_NPC(ch) || GET_LEVEL(ch) >= LVL_GRGOD) ? 25 : 18; GET_DEX(ch) = MAX(0, MIN(GET_DEX(ch), i)); GET_INT(ch) = MAX(0, MIN(GET_INT(ch), i)); GET_WIS(ch) = MAX(0, MIN(GET_WIS(ch), i)); GET_CON(ch) = MAX(0, MIN(GET_CON(ch), i)); GET_CHA(ch) = MAX(0, MIN(GET_CHA(ch), i)); GET_STR(ch) = MAX(0, GET_STR(ch)); if (IS_NPC(ch)) { GET_STR(ch) = MIN(GET_STR(ch), i); } else { if (GET_STR(ch) > 18) { i = GET_ADD(ch) + ((GET_STR(ch) - 18) * 10); GET_ADD(ch) = MIN(i, 100); GET_STR(ch) = 18; } } }
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)); fputs("E\n", fd); return TRUE; }
/* walk even though they could fly at will. */ void affect_total(struct char_data *ch) { struct affected_type *af; int i,j; char buff[200]; for(i=0; i<MAX_WEAR; i++) { if (ch->equipment[i]) for(j=0; j<MAX_OBJ_AFFECT; j++) affect_modify(ch, ch->equipment[i]->affected[j].location, (int)ch->equipment[i]->affected[j].modifier, ch->equipment[i]->obj_flags.bitvector, FALSE); } for(af = ch->affected; af; af=af->next) if(af->type != SPELL_FLY) affect_modify(ch, af->location, (int) af->modifier, af->bitvector, FALSE); ch->tmpabilities = ch->abilities; for(i=0; i<MAX_WEAR; i++) { if (ch->equipment[i]) for(j=0; j<MAX_OBJ_AFFECT; j++) affect_modify(ch, ch->equipment[i]->affected[j].location, (int) ch->equipment[i]->affected[j].modifier, ch->equipment[i]->obj_flags.bitvector, TRUE); } for(af = ch->affected; af; af=af->next) if(af->type != SPELL_FLY) affect_modify(ch, af->location, (int)af->modifier, af->bitvector, TRUE); /* Make certain values are between 0..25, not < 0 and not > 25! */ i = ((!IS_PC(ch)) ? 25 :18); /* f**k polies */ GET_DEX(ch) = MAX(3,MIN(GET_DEX(ch), i)); GET_INT(ch) = MAX(3,MIN(GET_INT(ch), i)); GET_WIS(ch) = MAX(3,MIN(GET_WIS(ch), i)); GET_CON(ch) = MAX(3,MIN(GET_CON(ch), i)); GET_STR(ch) = MAX(3,GET_STR(ch)); if (!IS_PC(ch)) { GET_STR(ch) = MIN(GET_STR(ch), i); } else if(GET_RACE(ch) != RACE_OGRE) { if (GET_STR(ch) > 18) { GET_ADD(ch) = 100; GET_STR(ch) = 18; } } else { /* warning: I am counting on ChangeStrength() */ /* to be working for this to be safe :) */ GET_STR(ch) = MIN(22,GET_STR(ch)); } }
/* Display main menu. */ static void medit_disp_stats_menu(struct descriptor_data *d) { struct char_data *mob; char buf[MAX_STRING_LENGTH]; mob = OLC_MOB(d); get_char_colors(d->character); clear_screen(d); /* Color codes have to be used here, for count_color_codes to work */ sprintf(buf, "(range \ty%d\tn to \ty%d\tn)", GET_HIT(mob) + GET_MOVE(mob), (GET_HIT(mob) * GET_MANA(mob)) + GET_MOVE(mob)); /* Top section - standard stats */ write_to_output(d, "-- Mob Number: %s[%s%d%s]%s\r\n" "(%s1%s) Level: %s[%s%4d%s]%s\r\n" "(%s2%s) %sAuto Set Stats (based on level)%s\r\n\r\n" "Hit Points (xdy+z): Bare Hand Damage (xdy+z): \r\n" "(%s3%s) HP NumDice: %s[%s%5d%s]%s (%s6%s) BHD NumDice: %s[%s%5d%s]%s\r\n" "(%s4%s) HP SizeDice: %s[%s%5d%s]%s (%s7%s) BHD SizeDice: %s[%s%5d%s]%s\r\n" "(%s5%s) HP Addition: %s[%s%5d%s]%s (%s8%s) DamRoll: %s[%s%5d%s]%s\r\n" "%-*s(range %s%d%s to %s%d%s)\r\n\r\n" "(%sA%s) Armor Class: %s[%s%4d%s]%s (%sD%s) Hitroll: %s[%s%5d%s]%s\r\n" "(%sB%s) Exp Points: %s[%s%10d%s]%s (%sE%s) Alignment: %s[%s%5d%s]%s\r\n" "(%sC%s) Gold: %s[%s%10d%s]%s\r\n\r\n", cyn, yel, OLC_NUM(d), cyn, nrm, cyn, nrm, cyn, yel, GET_LEVEL(mob), cyn, nrm, cyn, nrm, cyn, nrm, cyn, nrm, cyn, yel, GET_HIT(mob), cyn, nrm, cyn, nrm, cyn, yel, GET_NDD(mob), cyn, nrm, cyn, nrm, cyn, yel, GET_MANA(mob), cyn, nrm, cyn, nrm, cyn, yel, GET_SDD(mob), cyn, nrm, cyn, nrm, cyn, yel, GET_MOVE(mob), cyn, nrm, cyn, nrm, cyn, yel, GET_DAMROLL(mob), cyn, nrm, count_color_chars(buf)+28, buf, yel, GET_NDD(mob) + GET_DAMROLL(mob), nrm, yel, (GET_NDD(mob) * GET_SDD(mob)) + GET_DAMROLL(mob), nrm, cyn, nrm, cyn, yel, GET_AC(mob), cyn, nrm, cyn, nrm, cyn, yel, GET_HITROLL(mob), cyn, nrm, cyn, nrm, cyn, yel, GET_EXP(mob), cyn, nrm, cyn, nrm, cyn, yel, GET_ALIGNMENT(mob), cyn, nrm, cyn, nrm, cyn, yel, GET_GOLD(mob), cyn, nrm ); if (CONFIG_MEDIT_ADVANCED) { /* Bottom section - non-standard stats, togglable in cedit */ write_to_output(d, "(%sF%s) Str: %s[%s%2d/%3d%s]%s Saving Throws\r\n" "(%sG%s) Int: %s[%s%3d%s]%s (%sL%s) Paralysis %s[%s%3d%s]%s\r\n" "(%sH%s) Wis: %s[%s%3d%s]%s (%sM%s) Rods/Staves %s[%s%3d%s]%s\r\n" "(%sI%s) Dex: %s[%s%3d%s]%s (%sN%s) Petrification %s[%s%3d%s]%s\r\n" "(%sJ%s) Con: %s[%s%3d%s]%s (%sO%s) Breath %s[%s%3d%s]%s\r\n" "(%sK%s) Cha: %s[%s%3d%s]%s (%sP%s) Spells %s[%s%3d%s]%s\r\n\r\n", cyn, nrm, cyn, yel, GET_STR(mob), GET_ADD(mob), cyn, nrm, cyn, nrm, cyn, yel, GET_INT(mob), cyn, nrm, cyn, nrm, cyn, yel, GET_SAVE(mob, SAVING_PARA), cyn, nrm, cyn, nrm, cyn, yel, GET_WIS(mob), cyn, nrm, cyn, nrm, cyn, yel, GET_SAVE(mob, SAVING_ROD), cyn, nrm, cyn, nrm, cyn, yel, GET_DEX(mob), cyn, nrm, cyn, nrm, cyn, yel, GET_SAVE(mob, SAVING_PETRI), cyn, nrm, cyn, nrm, cyn, yel, GET_CON(mob), cyn, nrm, cyn, nrm, cyn, yel, GET_SAVE(mob, SAVING_BREATH), cyn, nrm, cyn, nrm, cyn, yel, GET_CHA(mob), cyn, nrm, cyn, nrm, cyn, yel, GET_SAVE(mob, SAVING_SPELL), cyn, nrm ); } /* Quit to previous menu option */ write_to_output(d, "(%sQ%s) Quit to main menu\r\nEnter choice : ", cyn, nrm); OLC_MODE(d) = MEDIT_STATS_MENU; }
void mag_affects(int level, struct char_data *ch, struct char_data *victim, int spellnum, int savetype) { struct affected_type af[MAX_SPELL_AFFECTS]; bool accum_affect = FALSE, accum_duration = FALSE; const char *to_vict = NULL, *to_room = NULL; int i; if (victim == NULL || ch == NULL) return; for (i = 0; i < MAX_SPELL_AFFECTS; i++) { af[i].type = spellnum; af[i].bitvector = 0; af[i].modifier = 0; af[i].location = APPLY_NONE; } switch (spellnum) { case SPELL_CHILL_TOUCH: af[0].location = APPLY_STR; if (mag_savingthrow(victim, savetype, 0)) af[0].duration = 1; else af[0].duration = 4; af[0].modifier = -1; accum_duration = TRUE; to_vict = "You feel your strength wither!"; break; case SPELL_ARMOR: af[0].location = APPLY_AC; af[0].modifier = -20; af[0].duration = 24; accum_duration = TRUE; to_vict = "You feel someone protecting you."; break; case SPELL_BLESS: af[0].location = APPLY_HITROLL; af[0].modifier = 2; af[0].duration = 6; af[1].location = APPLY_SAVING_SPELL; af[1].modifier = -1; af[1].duration = 6; accum_duration = TRUE; to_vict = "You feel righteous."; break; case SPELL_BLINDNESS: if (MOB_FLAGGED(victim,MOB_NOBLIND) || mag_savingthrow(victim, savetype, 0)) { send_to_char(ch, "You fail.\r\n"); return; } af[0].location = APPLY_HITROLL; af[0].modifier = -4; af[0].duration = 2; af[0].bitvector = AFF_BLIND; af[1].location = APPLY_AC; af[1].modifier = 40; af[1].duration = 2; af[1].bitvector = AFF_BLIND; to_room = "$n seems to be blinded!"; to_vict = "You have been blinded!"; break; case SPELL_CURSE: if (mag_savingthrow(victim, savetype, 0)) { send_to_char(ch, "%s", NOEFFECT); return; } af[0].location = APPLY_HITROLL; af[0].duration = 1 + (GET_LEVEL(ch) / 2); af[0].modifier = -1; af[0].bitvector = AFF_CURSE; af[1].location = APPLY_DAMROLL; af[1].duration = 1 + (GET_LEVEL(ch) / 2); af[1].modifier = -1; af[1].bitvector = AFF_CURSE; accum_duration = TRUE; accum_affect = TRUE; to_room = "$n briefly glows red!"; to_vict = "You feel very uncomfortable."; break; case SPELL_DETECT_ALIGN: af[0].duration = 12 + level; af[0].bitvector = AFF_DETECT_ALIGN; accum_duration = TRUE; to_vict = "Your eyes tingle."; break; case SPELL_DETECT_INVIS: af[0].duration = 12 + level; af[0].bitvector = AFF_DETECT_INVIS; accum_duration = TRUE; to_vict = "Your eyes tingle."; break; case SPELL_DETECT_MAGIC: af[0].duration = 12 + level; af[0].bitvector = AFF_DETECT_MAGIC; accum_duration = TRUE; to_vict = "Your eyes tingle."; break; case SPELL_INFRAVISION: af[0].duration = 12 + level; af[0].bitvector = AFF_INFRAVISION; accum_duration = TRUE; to_vict = "Your eyes glow red."; to_room = "$n's eyes glow red."; break; case SPELL_INVISIBLE: if (!victim) victim = ch; af[0].duration = 12 + (GET_LEVEL(ch) / 4); af[0].modifier = -40; af[0].location = APPLY_AC; af[0].bitvector = AFF_INVISIBLE; accum_duration = TRUE; to_vict = "You vanish."; to_room = "$n slowly fades out of existence."; break; case SPELL_POISON: if (mag_savingthrow(victim, savetype, 0)) { send_to_char(ch, "%s", NOEFFECT); return; } af[0].location = APPLY_STR; af[0].duration = GET_LEVEL(ch); af[0].modifier = -2; af[0].bitvector = AFF_POISON; to_vict = "You feel very sick."; to_room = "$n gets violently ill!"; break; case SPELL_PROT_FROM_EVIL: af[0].duration = 24; af[0].bitvector = AFF_PROTECT_EVIL; accum_duration = TRUE; to_vict = "You feel invulnerable!"; break; case SPELL_SANCTUARY: af[0].duration = 4; af[0].bitvector = AFF_SANCTUARY; accum_duration = TRUE; to_vict = "A white aura momentarily surrounds you."; to_room = "$n is surrounded by a white aura."; break; case SPELL_SLEEP: if (!pk_allowed && !IS_NPC(ch) && !IS_NPC(victim)) return; if (MOB_FLAGGED(victim, MOB_NOSLEEP)) return; if (mag_savingthrow(victim, savetype, 0)) return; af[0].duration = 4 + (GET_LEVEL(ch) / 4); af[0].bitvector = AFF_SLEEP; if (GET_POS(victim) > POS_SLEEPING) { send_to_char(victim, "You feel very sleepy... Zzzz......\r\n"); act("$n goes to sleep.", TRUE, victim, 0, 0, TO_ROOM); GET_POS(victim) = POS_SLEEPING; } break; case SPELL_STRENGTH: if (GET_ADD(victim) == 100) return; af[0].location = APPLY_STR; af[0].duration = (GET_LEVEL(ch) / 2) + 4; af[0].modifier = 1 + (level > 18); accum_duration = TRUE; accum_affect = TRUE; to_vict = "You feel stronger!"; break; case SPELL_SENSE_LIFE: to_vict = "Your feel your awareness improve."; af[0].duration = GET_LEVEL(ch); af[0].bitvector = AFF_SENSE_LIFE; accum_duration = TRUE; break; case SPELL_WATERWALK: af[0].duration = 24; af[0].bitvector = AFF_WATERWALK; accum_duration = TRUE; to_vict = "You feel webbing between your toes."; break; } /* * If this is a mob that has this affect set in its mob file, do not * perform the affect. This prevents people from un-sancting mobs * by sancting them and waiting for it to fade, for example. */ if (IS_NPC(victim) && !affected_by_spell(victim, spellnum)) for (i = 0; i < MAX_SPELL_AFFECTS; i++) if (AFF_FLAGGED(victim, af[i].bitvector)) { send_to_char(ch, "%s", NOEFFECT); return; } /* * If the victim is already affected by this spell, and the spell does * not have an accumulative effect, then fail the spell. */ if (affected_by_spell(victim,spellnum) && !(accum_duration||accum_affect)) { send_to_char(ch, "%s", NOEFFECT); return; } for (i = 0; i < MAX_SPELL_AFFECTS; i++) if (af[i].bitvector || (af[i].location != APPLY_NONE)) affect_join(victim, af+i, accum_duration, FALSE, accum_affect, FALSE); if (to_vict != NULL) act(to_vict, FALSE, victim, 0, ch, TO_CHAR); if (to_room != NULL) act(to_room, TRUE, victim, 0, ch, TO_ROOM); }
/* restoring original abilities, and then affecting all again */ void affect_total(struct char_data * ch) { struct affected_type *af; int i, j, newint, change, oldint; oldint = mem_int_app(ch); for (i = 0; i < NUM_WEARS; i++) { if (GET_EQ(ch, i)) { for (j = 0; j < MAX_OBJ_AFFECT; j++) { affect_modify(ch, GET_EQ(ch, i)->affected[j].location, GET_EQ(ch, i)->affected[j].modifier, GET_EQ(ch, i)->obj_flags.bitvector, FALSE); } } } for (af = ch->affected; af; af = af->next) { affect_modify(ch, af->location, af->modifier, af->bitvector, FALSE); } ch->aff_abils = ch->real_abils; for (i = 0; i < NUM_WEARS; i++) { if (GET_EQ(ch, i)) { for (j = 0; j < MAX_OBJ_AFFECT; j++) { affect_modify(ch, GET_EQ(ch, i)->affected[j].location, GET_EQ(ch, i)->affected[j].modifier, GET_EQ(ch, i)->obj_flags.bitvector, TRUE); } } } for (af = ch->affected; af; af = af->next) { affect_modify(ch, af->location, af->modifier, af->bitvector, TRUE); } /* Make certain values are between 0..25, not < 0 and not > 25! */ // i = (IS_NPC(ch) ? 25 : // (GET_LEVEL(ch) > LVL_IMMORT) ? 25 : 20); i = 25; GET_DEX(ch) = MAX(0, MIN(GET_DEX(ch), i)); GET_INT(ch) = MAX(0, MIN(GET_INT(ch), i)); GET_WIS(ch) = MAX(0, MIN(GET_WIS(ch), i)); GET_CON(ch) = MAX(0, MIN(GET_CON(ch), i)); GET_STR(ch) = MAX(0, GET_STR(ch)); if (IS_NPC(ch)) { GET_STR(ch) = MIN(GET_STR(ch), i); } else { /* PDH 4/29/99 * new method for STRs over 18 and such * now, when PC str > 18/00 go up to 19, 20, etc... */ int addOver100 = 0; if ( (GET_STR(ch) > 18) && (ch->real_abils.str_add != -1) ) { /* STR that is NOT naturally over 18 */ i = GET_ADD(ch) + ((GET_STR(ch) - 18) * 10); if ( i >= 110 ) { /* 19, 20, 21, ... 25 */ addOver100 = ( i - 100) / 10; GET_ADD(ch) = 0; GET_STR(ch) = MIN(25, 18 + addOver100); } else { GET_ADD(ch) = MIN(i, 100); GET_STR(ch) = 18; } } else { /* STR that is naturally over 18 (ie. minotaur) */ } } newint = mem_int_app(ch); change = newint - oldint; if (change) shift_memtimes(ch, change); }
/* * Load a char and inventory into a new ch structure. */ bool load_char_obj( struct descriptor_data * d, const char * name ) { FILE *fp; struct char_data *ch; char strsave [ MAX_INPUT_LENGTH ]; bool found; char sorry_player [] = "********************************************************\n\r" "** One or more of the critical fields in your player **\n\r" "** file were corrupted since you last played. Please **\n\r" "** contact an administrator or programmer to **\n\r" "** investigate the recovery of your characters. **\n\r" "********************************************************\n\r"; char sorry_object [] = "********************************************************\n\r" "** One or more of the critical fields in your player **\n\r" "** file were corrupted leading to the loss of one or **\n\r" "** more of your possessions. **\n\r" "********************************************************\n\r"; char sorry_alias [] = "********************************************************\n\r" "** One or more of the critical fields in your player **\n\r" "** file were corrupted leading to the loss of one or **\n\r" "** more of your aliases. **\n\r" "********************************************************\n\r"; ch = new_character( TRUE ); d->character = ch; GET_DESC(ch) = d; ch->player.name = str_dup( name ); /* ch->pcdata->prompt = str_dup( daPrompt ); ch->last_note = 0; */ strcpy( GET_PASSWD(ch), "" ); POOFIN(ch) = str_dup( "" ); POOFOUT(ch) = str_dup( "" ); GET_TITLE(ch) = str_dup( "" ); GET_STR(ch) = 10; GET_ADD(ch) = 10; GET_INT(ch) = 10; GET_WIS(ch) = 10; GET_DEX(ch) = 10; GET_CON(ch) = 10; GET_CHA(ch) = 10; GET_WILL(ch) = 10; GET_COND(ch, DRUNK) = 48; GET_COND(ch, FULL) = 48; GET_COND(ch, THIRST) = 48; GET_COND(ch, TIRED) = 48; // ch->pcdata->switched = FALSE; found = FALSE; fclose( fpReserve ); /* parsed player file directories by Yaz of 4th Realm */ /* decompress if .gz file exists - Thx Alander */ sprintf( strsave, "%s/%s/%s%s", PLAYER_DIR, player_dir( GET_NAME(ch) ), capitalize( GET_NAME(ch) ), ".gz" ); if ( ( fp = fopen( strsave, "r" ) ) ) { char buf [ MAX_STRING_LENGTH ]; fclose( fp ); sprintf( buf, "gzip -dfq %s", strsave ); system( buf ); } sprintf( strsave, "%s/%s/%s", PLAYER_DIR, player_dir( GET_NAME(ch) ), capitalize( GET_NAME(ch) ) ); if ( ( fp = fopen( strsave, "r" ) ) ) { char buf[ MAX_STRING_LENGTH ]; int iNest; for ( iNest = 0; iNest < MAX_NEST; iNest++ ) rgObjNest[iNest] = NULL; found = TRUE; for ( ; ; ) { char *word; char letter; int status; letter = fread_letter( fp ); if ( letter == '*' ) { fread_to_eol( fp ); continue; } if ( letter != '#' ) { log( "Load_char_obj: # not found." ); break; } word = fread_word_stat( fp, &status ); if ( !str_cmp( word, "PLAYER" ) ) { if ( fread_char ( ch, fp ) ) { sprintf( buf, "Load_char_obj: %s section PLAYER corrupt.\n\r", name ); log( buf ); SEND_TO_Q( sorry_player, d ); /* * In case you are curious, * it is ok to leave ch alone for close_socket * to free. * We want to now kick the bad character out as * what we are missing are MANDATORY fields. -Kahn */ SET_BIT( PRF_FLAGS(ch), PLR_DELETED ); return TRUE; } } else if ( !str_cmp( word, "OBJECT" ) ) { if ( !fread_obj_char( ch, fp ) ) { sprintf( buf, "Load_char_obj: %s section OBJECT corrupt.\n\r", name ); log( buf ); SEND_TO_Q( sorry_object, d ); return FALSE; } } else if ( !str_cmp( word, "ALIAS" ) ) { if ( !fread_alias( ch, fp ) ) { sprintf( buf, "Load_char_obj: %s section ALIAS corrupt.\n\r", name ); log( buf ); SEND_TO_Q( sorry_alias, d ); return FALSE; } } else if ( !str_cmp( word, "END" ) ) break; else { log( "Load_char_obj: bad section." ); break; } } /* for */ fclose( fp ); } fpReserve = fopen( NULL_FILE, "r" ); if ( found ) rent_adjust( d->character ); return found; }
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; }