bool spec_executioner( CHAR_DATA *ch ) { char buf[MAX_STRING_LENGTH]; CHAR_DATA *victim; CHAR_DATA *v_next; char *crime; if ( !IS_AWAKE(ch) || ch->fighting != NULL ) return FALSE; crime = ""; for ( victim = ch->in_room->people; victim != NULL; victim = v_next ) { v_next = victim->next_in_room; if ( !IS_NPC(victim) && IS_SET(victim->act, PLR_KILLER) ) { crime = "KILLER"; break; } if ( !IS_NPC(victim) && IS_SET(victim->act, PLR_THIEF) ) { crime = "THIEF"; break; } } if ( victim == NULL ) return FALSE; sprintf( buf, "%s is a %s! PROTECT THE INNOCENT! MORE BLOOOOD!!!", victim->name, crime ); do_shout( ch, buf ); multi_hit( ch, victim, TYPE_UNDEFINED ); char_to_room( create_mobile( get_mob_index(MOB_VNUM_CITYGUARD) ), ch->in_room ); char_to_room( create_mobile( get_mob_index(MOB_VNUM_CITYGUARD) ), ch->in_room ); return TRUE; }
/* * Snarf spec proc declarations. */ void load_specials( FILE *fp ) { for ( ; ; ) { MOB_INDEX_DATA *pMobIndex; char letter; switch ( letter = fread_letter( fp ) ) { default: bug( "Load_specials: letter '%c' not *MS.", letter ); exit( 1 ); case 'S': return; case '*': break; case 'M': pMobIndex = get_mob_index ( fread_number ( fp ) ); pMobIndex->spec_fun = spec_lookup ( fread_word ( fp ) ); if ( pMobIndex->spec_fun == 0 ) { bug( "Load_specials: 'M': vnum %d.", pMobIndex->vnum ); exit( 1 ); } break; } fread_to_eol( fp ); } }
/* * Snarf a shop section. */ void load_shops( FILE *fp ) { SHOP_DATA *pShop; for ( ; ; ) { MOB_INDEX_DATA *pMobIndex; int iTrade; pShop = alloc_perm( sizeof(*pShop) ); pShop->keeper = fread_number( fp ); if ( pShop->keeper == 0 ) break; for ( iTrade = 0; iTrade < MAX_TRADE; iTrade++ ) pShop->buy_type[iTrade] = fread_number( fp ); pShop->profit_buy = fread_number( fp ); pShop->profit_sell = fread_number( fp ); pShop->open_hour = fread_number( fp ); pShop->close_hour = fread_number( fp ); fread_to_eol( fp ); pMobIndex = get_mob_index( pShop->keeper ); pMobIndex->pShop = pShop; if ( shop_first == NULL ) shop_first = pShop; if ( shop_last != NULL ) shop_last->next = pShop; shop_last = pShop; pShop->next = NULL; top_shop++; } return; }
void do_mpmload( CHAR_DATA *ch, char *argument ) { char arg[ MAX_INPUT_LENGTH ]; MOB_INDEX_DATA *pMobIndex; CHAR_DATA *victim; if ( !IS_NPC( ch ) ) { send_to_char( C_DEFAULT, "Huh?\n\r", ch ); return; } if ( IS_AFFECTED( ch, AFF_CHARM ) ) { return; } one_argument( argument, arg ); if ( arg[0] == '\0' || !is_number(arg) ) { bug( "Mpmload - Bad vnum as arg: vnum %d.", ch->pIndexData->vnum ); return; } if ( ( pMobIndex = get_mob_index( atoi( arg ) ) ) == NULL ) { bug( "Mpmload - Bad mob vnum: vnum %d.", ch->pIndexData->vnum ); return; } victim = create_mobile( pMobIndex ); char_to_room( victim, ch->in_room ); return; }
SPEC_RET spec_executioner( CHAR_DATA *ch ) { MOB_PROTO_DATA *cityguard; CHAR_DATA *victim; CHAR_DATA *v_next; char *crime; char buf[MSL]; if ( !is_awake(ch) ) return FALSE; if ( ch->fighting ) return FALSE; crime = ""; for ( victim = ch->in_room->first_person; victim; victim = v_next ) { v_next = victim->next_in_room; if ( IS_PG(victim) && HAS_BIT_PLR(victim, PLAYER_KILLER) ) { crime = "assassino"; break; } if ( IS_PG(victim) && HAS_BIT_PLR(victim, PLAYER_THIEF) ) { crime = "ladro"; break; } } if ( !victim ) return FALSE; if ( HAS_BIT(ch->in_room->flags, ROOM_SAFE) ) { sprintf( buf, "yell codardo di un %s!", crime ); /* (GR) articolo */ send_command( ch, buf, CO ); return TRUE; } sprintf( buf, "yell Proteggiamo l'innocente dal %s!!", crime ); /* (GR) articolo dal dall' */ send_command( ch, buf, CO ); multi_hit( ch, victim, TYPE_UNDEFINED ); if ( char_died(ch) ) return TRUE; /* Aggiunto il log nel caso che venga a mancare la guardia cittadina */ cityguard = get_mob_index( NULL, VNUM_MOB_CITYGUARD ); if ( !cityguard ) { send_log( NULL, LOG_BUG, "spec_executioner: Guardia cittadina mancante - Vnum:[%d]", VNUM_MOB_CITYGUARD ); return TRUE; } char_to_room( make_mobile(cityguard), ch->in_room ); char_to_room( make_mobile(cityguard), ch->in_room ); return TRUE; }
RENUMBER_DATA *gather_one_list( short type, int low, int high, int new_base, bool fill_gaps, int *max_vnum ) /* this function builds a list of renumber data for a type (obj, room, or mob) */ { int cur_vnum; RENUMBER_DATA *r_data, root; bool found; ROOM_INDEX_DATA *room; OBJ_INDEX_DATA *obj; MOB_INDEX_DATA *mob; int i; int highest; memset( &root, 0, sizeof( RENUMBER_DATA ) ); r_data = &root; cur_vnum = new_base; highest = -1; for( i = low; i <= high; i++ ) { found = FALSE; switch ( type ) { case REN_ROOM: room = get_room_index( i ); if( room != NULL ) found = TRUE; break; case REN_OBJ: obj = get_obj_index( i ); if( obj != NULL ) found = TRUE; break; case REN_MOB: mob = get_mob_index( i ); if( mob != NULL ) found = TRUE; break; } if( found ) { if( cur_vnum > highest ) highest = cur_vnum; if( cur_vnum != i ) { CREATE( r_data->next, RENUMBER_DATA, 1 ); r_data = r_data->next; r_data->old_vnum = i; r_data->new_vnum = cur_vnum; } cur_vnum++; } else if( !fill_gaps ) cur_vnum++; } *max_vnum = highest; return root.next; }
/* Snarf a MOBprogram section from the area file. */ bool load_mobprogs( FILE *fp ) { MOB_INDEX_DATA *iMob; MPROG_DATA *original; MPROG_DATA *working; char letter; int value; int stat; bool koniec = FALSE; while ( !koniec ) { letter = fread_letter( fp ); switch ( letter ) { default: cbug( "Load_mobprogs: bad command '%c'.", letter ); return TRUE; case 'S': case 's': fread_to_eol( fp ); koniec = TRUE; break; case '*': fread_to_eol( fp ); break; case 'M': case 'm': value = fread_number( fp, &stat ); if ( ( iMob = get_mob_index( value ) ) == NULL ) { cbug( "Load_mobprogs: vnum %d doesnt exist", value ); return TRUE; } /* Go to the end of the prog command list if other commands exist */ if ( ( original = iMob->mobprogs ) ) for ( ; original->next != NULL; original = original->next ) ; working = new_mprog( ); if ( original ) original->next = working; else iMob->mobprogs = working; working = mprog_file_read( fread_word( fp, &stat, TRUE ), working, iMob, 0 ); if ( !working ) return TRUE; working->next = NULL; fread_to_eol( fp ); break; } } return FALSE; }
bool spec_executioner( CHAR_DATA *ch ) { char buf[MAX_STRING_LENGTH]; MOB_INDEX_DATA *cityguard; CHAR_DATA *victim; CHAR_DATA *v_next; char *crime; if ( !IS_AWAKE(ch) || ch->fighting ) return FALSE; crime = ""; for ( victim = ch->in_room->first_person; victim; victim = v_next ) { v_next = victim->next_in_room; if ( !IS_NPC(victim) && xIS_SET(victim->act, PLR_KILLER) ) { crime = "KILLER"; break; } if ( !IS_NPC(victim) && xIS_SET(victim->act, PLR_THIEF) ) { crime = "THIEF"; break; } } if ( !victim ) return FALSE; if ( xIS_SET( ch->in_room->room_flags, ROOM_SAFE ) ) { sprintf( buf, "%s is a %s! As well as a COWARD!", victim->name, crime ); do_yell( ch, buf ); return TRUE; } sprintf( buf, "%s is a %s! PROTECT THE INNOCENT! MORE BLOOOOD!!!", victim->name, crime ); do_yell( ch, buf ); multi_hit( ch, victim, TYPE_UNDEFINED ); if ( char_died(ch) ) return TRUE; /* Added log in case of missing cityguard -- Tri */ cityguard = get_mob_index( MOB_VNUM_CITYGUARD ); if ( !cityguard ) { sprintf( buf, "Missing Cityguard - Vnum:[%d]", MOB_VNUM_CITYGUARD ); bug( buf, 0 ); return TRUE; } char_to_room( create_mobile( cityguard ), ch->in_room ); char_to_room( create_mobile( cityguard ), ch->in_room ); return TRUE; }
/* * Legge un numero di VNUM da un file * Ritorna il prototipo del mob relativo al vnum */ MOB_PROTO_DATA *fread_vnum_mob( MUD_FILE *fp ) { MOB_PROTO_DATA *mob; VNUM vnum; vnum = fread_vnum( fp ); if ( vnum == 0 ) return NULL; mob = get_mob_index( fp, vnum ); return mob; }
/* These are for creating the super-mob so that the t_progs can use * mprog stuff.. * -- Altrag */ static void check_smob(void) { if (!smob) { smob = create_mobile(get_mob_index(MOB_VNUM_SUPERMOB)); char_list = char_list->next; /*Don't want it in the char_list */ mobs_in_game--; /* Doesn't count as a mob in the game */ } if (smob->in_room) char_from_room(smob); free_string(smob->name); free_string(smob->short_descr); }
/***************************************************************************** Name: vsave_shops Purpose: Saves the #SHOPS section of an area file. New formating thanks to Rac. Called by: save_area(olc_save.c) ****************************************************************************/ void vsave_shops( FILE *fp, AREA_DATA *pArea ) { SHOP_DATA *pShopIndex; MOB_INDEX_DATA *pMobIndex; int iTrade; int vnum; fprintf( fp, "#SHOPS\n" ); for( vnum = pArea->lvnum; vnum <= pArea->uvnum; vnum++ ) { if( ( pMobIndex = get_mob_index(vnum) ) ) { if ( pMobIndex->area == pArea && pMobIndex->pShop ) { pShopIndex = pMobIndex->pShop; fprintf( fp, "%d ", pShopIndex->keeper ); for ( iTrade = 0; iTrade < MAX_TRADE; iTrade++ ) { if ( pShopIndex->buy_type[iTrade] != 0 ) { fprintf( fp, "%2d ", pShopIndex->buy_type[iTrade] ); } else fprintf( fp, " 0 "); } fprintf( fp, "%3d %3d ", pShopIndex->profit_buy, pShopIndex->profit_sell ); fprintf( fp, "%2d %2d ", pShopIndex->open_hour, pShopIndex->close_hour ); fprintf( fp, "\t; %s\n", get_mob_index( pShopIndex->keeper )->short_descr ); } } } fprintf( fp, "0\n\n\n\n" ); return; }
/***************************************************************************** Name: save_mobiles Purpose: Save #MOBILES secion of an area file. Called by: save_area(olc_save.c). Notes: Changed for ROM OLC. ****************************************************************************/ void save_mobiles( FILE *fp, AREA_DATA *pArea ) { int i; MOB_INDEX_DATA *pMob; fprintf( fp, "#MOBILES\n" ); for( i = pArea->min_vnum; i <= pArea->max_vnum; i++ ) { if ( (pMob = get_mob_index( i )) ) save_mobile( fp, pMob ); } fprintf( fp, "#0\n\n\n\n" ); return; }
void do_invade( CHAR_DATA *ch , char *argument ) { char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; char arg3[MAX_INPUT_LENGTH]; AREA_DATA *tarea; int count; bool found=FALSE; MOB_INDEX_DATA *pMobIndex; argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); argument = one_argument( argument, arg3 ); count = atoi( arg2 ); if ( arg1[0] == '\0' || arg2[0] == '\0' ) { send_to_char( "Invade <area> <# of invaders> <mob vnum>\n\r", ch ); return; } for ( tarea = area_first; tarea; tarea = tarea->next ) if ( !str_cmp( tarea->filename, arg1 ) ) { found = TRUE; break; } if ( !found ) { send_to_char( "Area not found.\n\r", ch ); return; } if ( count > 300) { send_to_char( "Whoa...Less than 300 please.\n\r", ch ); return; } if ( ( pMobIndex = get_mob_index( atoi(arg3) ) ) == NULL ) { send_to_char( "No mobile has that vnum.\n\r", ch ); return; } InvadeArea(tarea, pMobIndex, count); send_to_char( "The invasion was successful!\n\r", ch ); return; }
void warn_progs( CHAR_DATA * ch, int low, int high, AREA_DATA * area, RENUMBER_AREA * r_area ) { ROOM_INDEX_DATA *room; OBJ_INDEX_DATA *obj; MOB_INDEX_DATA *mob; MPROG_DATA *mprog; int i; for( i = area->low_r_vnum; i <= area->hi_r_vnum; i++ ) { room = get_room_index( i ); if( !room ) continue; mprog = room->mudprogs; while( mprog ) { warn_in_prog( ch, low, high, "room", i, mprog, r_area ); mprog = mprog->next; } } for( i = area->low_o_vnum; i <= area->hi_o_vnum; i++ ) { obj = get_obj_index( i ); if( !obj ) continue; mprog = obj->mudprogs; while( mprog ) { warn_in_prog( ch, low, high, "obj", i, mprog, r_area ); mprog = mprog->next; } } for( i = area->low_m_vnum; i <= area->hi_m_vnum; i++ ) { mob = get_mob_index( i ); if( !mob ) continue; mprog = mob->mudprogs; while( mprog ) { warn_in_prog( ch, low, high, "mob", i, mprog, r_area ); mprog = mprog->next; } } }
void do_shopstat( CHAR_DATA *ch, char *argument ) { SHOP_DATA *shop; MOB_INDEX_DATA *mob; int vnum; if ( argument[0] == '\0' ) { send_to_char( "Usage: shopstat <keeper vnum>\n\r", ch ); return; } vnum = atoi( argument ); if ( (mob = get_mob_index(vnum)) == NULL ) { send_to_char( "Mobile not found.\n\r", ch ); return; } if ( !mob->pShop ) { send_to_char( "This mobile doesn't keep a shop.\n\r", ch ); return; } shop = mob->pShop; ch_printf( ch, "Keeper: %d %s\n\r", shop->keeper, mob->short_descr ); ch_printf( ch, "buy0 [%s] buy1 [%s] buy2 [%s] buy3 [%s] buy4 [%s]\n\r", o_types[shop->buy_type[0]], o_types[shop->buy_type[1]], o_types[shop->buy_type[2]], o_types[shop->buy_type[3]], o_types[shop->buy_type[4]] ); ch_printf( ch, "Profit: buy %3d%% sell %3d%%\n\r", shop->profit_buy, shop->profit_sell ); ch_printf( ch, "Hours: open %2d close %2d\n\r", shop->open_hour, shop->close_hour ); return; }
void do_makerepair( CHAR_DATA *ch, char *argument ) { REPAIR_DATA *repair; int vnum; MOB_INDEX_DATA *mob; if ( !argument || argument[0] == '\0' ) { send_to_char( "Usage: makerepair <mobvnum>\n\r", ch ); return; } vnum = atoi( argument ); if ( (mob = get_mob_index(vnum)) == NULL ) { send_to_char( "Mobile not found.\n\r", ch ); return; } if ( !can_medit(ch, mob) ) return; if ( mob->rShop ) { send_to_char( "This mobile already has a repair shop.\n\r", ch ); return; } CREATE( repair, REPAIR_DATA, 1 ); LINK( repair, first_repair, last_repair, next, prev ); repair->keeper = vnum; repair->profit_fix = 100; repair->shop_type = SHOP_FIX; repair->open_hour = 0; repair->close_hour = 23; mob->rShop = repair; send_to_char( "Done.\n\r", ch ); return; }
void do_makeshop( CHAR_DATA *ch, char *argument ) { SHOP_DATA *shop; int vnum; MOB_INDEX_DATA *mob; if ( !argument || argument[0] == '\0' ) { send_to_char( "Usage: makeshop <mobvnum>\n\r", ch ); return; } vnum = atoi( argument ); if ( (mob = get_mob_index(vnum)) == NULL ) { send_to_char( "Mobile not found.\n\r", ch ); return; } if ( !can_medit(ch, mob) ) return; if ( mob->pShop ) { send_to_char( "This mobile already has a shop.\n\r", ch ); return; } CREATE( shop, SHOP_DATA, 1 ); LINK( shop, first_shop, last_shop, next, prev ); shop->keeper = vnum; shop->profit_buy = 120; shop->profit_sell = 90; shop->open_hour = 0; shop->close_hour = 23; mob->pShop = shop; send_to_char( "Done.\n\r", ch ); return; }
void do_repairstat( CHAR_DATA *ch, char *argument ) { REPAIR_DATA *repair; MOB_INDEX_DATA *mob; int vnum; if ( argument[0] == '\0' ) { send_to_char( "Usage: repairstat <keeper vnum>\n\r", ch ); return; } vnum = atoi( argument ); if ( (mob = get_mob_index(vnum)) == NULL ) { send_to_char( "Mobile not found.\n\r", ch ); return; } if ( !mob->rShop ) { send_to_char( "This mobile doesn't keep a repair shop.\n\r", ch ); return; } repair = mob->rShop; ch_printf( ch, "Keeper: %d %s\n\r", repair->keeper, mob->short_descr ); ch_printf( ch, "fix0 [%s] fix1 [%s] fix2 [%s]\n\r", o_types[repair->fix_type[0]], o_types[repair->fix_type[1]], o_types[repair->fix_type[2]] ); ch_printf( ch, "Profit: %3d%% Type: %d\n\r", repair->profit_fix, repair->shop_type ); ch_printf( ch, "Hours: open %2d close %2d\n\r", repair->open_hour, repair->close_hour ); return; }
/***************************************************************************** Name: save_specials Purpose: Save #SPECIALS section of area file. Called by: save_area(olc_save.c). ****************************************************************************/ void save_specials( FILE *fp, AREA_DATA *pArea ) { int vnum; MOB_INDEX_DATA *pMobIndex; fprintf( fp, "#SPECIALS\n" ); for( vnum = pArea->lvnum; vnum <= pArea->uvnum; vnum++ ) { if( ( pMobIndex = get_mob_index(vnum) ) ) { if ( pMobIndex->area == pArea && pMobIndex->spec_fun ) { fprintf( fp, "M %d %s\n", pMobIndex->vnum, spec_string( pMobIndex->spec_fun ) ); } } } fprintf( fp, "S\n\n\n\n" ); return; }
/***************************************************************************** Name: save_mobiles Purpose: Save #MOBILES secion of an area file. Called by: save_area(olc_save.c). ****************************************************************************/ void save_mobiles( FILE *fp, AREA_DATA *pArea ) { int vnum; MOB_INDEX_DATA *pMobIndex; fprintf( fp, "#MOBILES\n" ); for( vnum = pArea->lvnum; vnum <= pArea->uvnum; vnum++ ) { if( ( pMobIndex = get_mob_index(vnum) ) ) { if ( pMobIndex->area == pArea ) { fprintf( fp, "#%d\n", pMobIndex->vnum ); fprintf( fp, "%s~\n", pMobIndex->player_name ); fprintf( fp, "%s~\n", pMobIndex->short_descr ); fprintf( fp, "%s~\n", fix_string( pMobIndex->long_descr ) ); fprintf( fp, "%s~\n", fix_string( pMobIndex->description ) ); fprintf( fp, "%d ", pMobIndex->act ); fprintf( fp, "%d ", pMobIndex->affected_by ); fprintf( fp, "%d S\n", pMobIndex->alignment ); fprintf( fp, "%d ", pMobIndex->level ); fprintf( fp, "%d ", pMobIndex->hitroll ); fprintf( fp, "%d ", pMobIndex->ac ); fprintf( fp, "%dd%d+%d ", pMobIndex->hitnodice, pMobIndex->hitsizedice, pMobIndex->hitplus ); fprintf( fp, "%dd%d+%d\n", pMobIndex->damnodice, pMobIndex->damsizedice, pMobIndex->damplus ); fprintf( fp, "%d ", pMobIndex->gold ); fprintf( fp, "0\n0 0 " ); fprintf( fp, "%d\n", pMobIndex->sex ); } } } fprintf( fp, "#0\n\n\n\n" ); return; }
/* * Lets the mobile load another mobile. * * Syntax: mob mload [vnum] */ void do_mpmload(CHAR_DATA * ch, char *argument) { char arg[MAX_INPUT_LENGTH]; MOB_INDEX_DATA *pMobIndex; CHAR_DATA *victim; int vnum; one_argument(argument, arg); if (ch->in_room == NULL || arg[0] == '\0' || !is_number(arg)) return; vnum = atoi(arg); if ((pMobIndex = get_mob_index(vnum)) == NULL) { sprintf(arg, "Mpmload: bad mob index (%d) from mob %d", vnum, IS_NPC(ch) ? ch->pIndexData->vnum : 0); bug(arg, 0); return; } victim = create_mobile(pMobIndex); char_to_room(victim, ch->in_room); return; }
/* lets the mobile load an item or mobile. All items are loaded into inventory. you can specify a level with the load object portion as well. */ void do_mpmload( CHAR_DATA *ch, char *argument ) { char arg[ MAX_INPUT_LENGTH ]; MOB_INDEX_DATA *pMobIndex; CHAR_DATA *victim; if ( !IS_NPC( ch ) ) { typo_message( ch ); return; } if ( IS_SET( ch->act , ACT_PET ) || IS_AFFECTED( ch, AFF_CHARM ) ) return; one_argument( argument, arg ); if ( arg[0] == '\0' || !is_number(arg) ) { sprintf( log_buf, "Mpmload - Bad vnum as arg: vnum %d name %s short %s.", ch->pIndexData->vnum, ch->name, ch->short_descr ); bug( log_buf, -1 ); return; } if ( ( pMobIndex = get_mob_index( atoi( arg ) ) ) == NULL ) { sprintf( log_buf, "Mpmload - Bad mob vnum: vnum %d name %s short %s.", ch->pIndexData->vnum, ch->name, ch->short_descr ); bug( log_buf, -1 ); return; } victim = create_mobile( pMobIndex ); char_to_room( victim, ch->in_room ); return; }
CHAR_DATA *load_mobile( FILE * fp ) { CHAR_DATA *mob = NULL; const char *word; bool fMatch; int inroom = 0; ROOM_INDEX_DATA *pRoomIndex = NULL; word = feof( fp ) ? "EndMobile" : fread_word( fp ); if( !str_cmp( word, "Vnum" ) ) { int vnum; vnum = fread_number( fp ); if( get_mob_index( vnum ) == NULL ) { bug( "%s: No index data for vnum %d", __FUNCTION__, vnum ); return NULL; } mob = create_mobile( get_mob_index( vnum ) ); if( !mob ) { for( ;; ) { word = feof( fp ) ? "EndMobile" : fread_word( fp ); /* * So we don't get so many bug messages when something messes up * * --Shaddai */ if( !str_cmp( word, "EndMobile" ) ) break; } bug( "%s: Unable to create mobile for vnum %d", __FUNCTION__, vnum ); return NULL; } } else { for( ;; ) { word = feof( fp ) ? "EndMobile" : fread_word( fp ); /* * So we don't get so many bug messages when something messes up * * --Shaddai */ if( !str_cmp( word, "EndMobile" ) ) break; } extract_char( mob, TRUE ); bug( "%s: Vnum not found", __FUNCTION__ ); return NULL; } for( ;; ) { word = feof( fp ) ? "EndMobile" : fread_word( fp ); fMatch = FALSE; switch ( UPPER( word[0] ) ) { case '*': fMatch = TRUE; fread_to_eol( fp ); break; case '#': if( !str_cmp( word, "#OBJECT" ) ) { mob->tempnum = -9999; /* Hackish, yes. Works though doesn't it? */ fread_obj( mob, fp, OS_CARRY ); } break; case 'A': if( !str_cmp( word, "Affect" ) || !str_cmp( word, "AffectData" ) ) { AFFECT_DATA *paf; CREATE( paf, AFFECT_DATA, 1 ); if( !str_cmp( word, "Affect" ) ) { paf->type = fread_number( fp ); } else { int sn; const char *sname = fread_word( fp ); if( ( sn = skill_lookup( sname ) ) < 0 ) { if( ( sn = herb_lookup( sname ) ) < 0 ) bug( "%s", "load_mobile: unknown skill." ); else sn += TYPE_HERB; } paf->type = sn; } paf->duration = fread_number( fp ); paf->modifier = fread_number( fp ); paf->location = fread_number( fp ); if( paf->location == APPLY_WEAPONSPELL || paf->location == APPLY_WEARSPELL || paf->location == APPLY_REMOVESPELL || paf->location == APPLY_STRIPSN ) paf->modifier = slot_lookup( paf->modifier ); paf->bitvector = fread_bitvector( fp ); LINK( paf, mob->first_affect, mob->last_affect, next, prev ); fMatch = TRUE; break; } KEY( "AffectedBy", mob->affected_by, fread_bitvector( fp ) ); break; #ifdef OVERLANDCODE case 'C': if( !str_cmp( word, "Coordinates" ) ) { mob->x = fread_number( fp ); mob->y = fread_number( fp ); mob->map = fread_number( fp ); fMatch = TRUE; break; } break; #endif case 'D': if( !str_cmp( word, "Description" ) ) { STRFREE( mob->description ); mob->description = fread_string( fp ); fMatch = TRUE; break; } break; case 'E': if( !str_cmp( word, "EndMobile" ) ) { if( inroom == 0 ) inroom = ROOM_VNUM_LIMBO; pRoomIndex = get_room_index( inroom ); if( !pRoomIndex ) pRoomIndex = get_room_index( ROOM_VNUM_LIMBO ); char_to_room( mob, pRoomIndex ); mob->tempnum = -9998; /* Yet another hackish fix! */ update_room_reset( mob, FALSE ); return mob; } if( !str_cmp( word, "End" ) ) /* End of object, need to ignore this. sometimes they creep in there somehow -- Scion */ fMatch = TRUE; /* Trick the system into thinking it matched something */ break; case 'F': KEY( "Flags", mob->act, fread_number( fp ) ); break; case 'G': KEY( "Gold", mob->gold, fread_number( fp ) ); break; case 'H': if( !str_cmp( word, "HpManaMove" ) ) { mob->hit = fread_number( fp ); mob->max_hit = fread_number( fp ); mob->mana = fread_number( fp ); mob->max_mana = fread_number( fp ); mob->move = fread_number( fp ); mob->max_move = fread_number( fp ); if( mob->max_move <= 0 ) mob->max_move = 150; fMatch = TRUE; break; } break; case 'L': if( !str_cmp( word, "Long" ) ) { STRFREE( mob->long_descr ); mob->long_descr = fread_string( fp ); fMatch = TRUE; break; } KEY( "Level", mob->top_level, fread_number( fp ) ); break; case 'M': if( !str_cmp( word, "Mobclan" ) ) { STRFREE( mob->mob_clan ); mob->mob_clan = fread_string( fp ); fMatch = TRUE; break; } break; case 'N': if( !str_cmp( word, "Name" ) ) { STRFREE( mob->name ); mob->name = fread_string( fp ); fMatch = TRUE; break; } break; case 'P': KEY( "Position", mob->position, fread_number( fp ) ); break; case 'R': KEY( "Room", inroom, fread_number( fp ) ); KEY( "Resetvnum", mob->resetvnum, fread_number( fp ) ); KEY( "Resetnum", mob->resetnum, fread_number( fp ) ); break; case 'S': if( !str_cmp( word, "Short" ) ) { STRFREE( mob->short_descr ); mob->short_descr = fread_string( fp ); fMatch = TRUE; break; } break; } if( !fMatch && str_cmp( word, "End" ) ) bug( "%s: no match: %s", __FUNCTION__, word ); } return NULL; }
void Character::spell_gate (int sn, int lvl, void *vo) { get_mob_index(MOB_VNUM_VAMPIRE)->create_mobile()->char_to_room(in_room); return; }
void Drakes::WakenStone(CHAR_DATA & ch, const char * argument, int skill) { // Check for location if (ch.in_room == NULL || !ON_GROUND(&ch)) { send_to_char("You cannot reach the earth from this place.\n", &ch); return; } // Get the location's stone type and use it to lookup the drake info int stoneType(ch.in_room->stone_type); if (stoneType < 0) stoneType = ch.in_room->area->stone_type; const Info * info(Lookup(stoneType)); if (info == NULL) { send_to_char("You probe your will into the earth, but cannot reach its stony heart from here.\n", &ch); return; } // Check whether an argument was provided if (argument[0] == '\0') { std::ostringstream mess; mess << "You probe your will into the earth, which resonates with a strong sense of "; mess << material_table[stoneType].name << ".\n"; send_to_char(mess.str().c_str(), &ch); return; } // Check for an earth elemental pet present CHAR_DATA * elemental(get_char_room(&ch, argument)); if (elemental == NULL) { send_to_char("You see nobody here by that name.\n", &ch); return; } // Verify the elemental if (ch.pet != elemental || elemental->master != &ch || !IS_NPC(elemental) || elemental->pIndexData->vnum != MOB_VNUM_EARTH_ELEMENTAL) { send_to_char("You may only waken an earth elemental which belongs to you.\n", &ch); return; } // Check for mana if (ch.mana < skill_table[gsn_wakenedstone].min_mana) { send_to_char("You lack the energy to waken stone right now.\n", &ch); return; } // Starting echoes act("You bind your will around $N, seeking a path from $M to the stony heart of the earth.", &ch, NULL, elemental, TO_CHAR); act("A steady murmur of energy flows back up the link, pouring into $N!", &ch, NULL, elemental, TO_CHAR); act("The ground begins to throb with energy, concentrated between $n and $N!", &ch, NULL, elemental, TO_ROOM); act("Shards of rock break and fall away from $M as you call out, waking the stone with your power!", &ch, NULL, elemental, TO_CHAR); act("$n calls out suddenly, and shards of rock break and fall away from $M!", &ch, NULL, elemental, TO_ROOM); // Check for skill success if (number_percent() <= skill) { // Make the base mob and adjust for age and type CHAR_DATA * drake(create_mobile(get_mob_index(MOB_VNUM_DRAKE))); AdjustDrake(ch, *drake, stoneType, *info, UMAX(ch.level, elemental->level), Hatchling); drake->hit = drake->max_hit; drake->mana = drake->max_mana; drake->move = drake->max_move; // Replace the elemental with the drake check_improve(&ch, NULL, gsn_wakenedstone, true, 1); char_to_room(drake, ch.in_room); ch.pet = drake; drake->master = &ch; drake->leader = &ch; // Success echo act("The last bits slough away, leaving behind $n.", drake, NULL, NULL, TO_ROOM); } else { // Failure echo act("You lose control, and $N crumbles away completely!", &ch, NULL, elemental, TO_CHAR); act("$N crumbles away completely, reduced to mere dust in moments.", &ch, NULL, elemental, TO_ROOM); } // Destroy the elemental elemental->master = NULL; extract_char(elemental, true); // Charge mana and lag expend_mana(&ch, skill_table[gsn_wakenedstone].min_mana); WAIT_STATE(&ch, skill_table[gsn_wakenedstone].beats); }
void renumber_area( CHAR_DATA * ch, AREA_DATA * area, RENUMBER_AREA * r_area, bool area_is_proto, bool verbose ) /* this is the function that actualy does the renumbering of "area" according to the renumber data in "r_area". "ch" is to show messages. */ { RENUMBER_DATA *r_data; ROOM_INDEX_DATA *room, *room_prev, *room_list, *room_next; MOB_INDEX_DATA *mob, *mob_prev, *mob_list, *mob_next; OBJ_INDEX_DATA *obj, *obj_prev, *obj_list, *obj_next; RESET_DATA *preset, *treset; int iHash; int low, high; high = UMAX( area->hi_r_vnum, UMIN( area->hi_o_vnum, area->hi_m_vnum ) ); low = UMIN( area->low_r_vnum, UMIN( area->low_o_vnum, area->low_m_vnum ) ); pager_printf( ch, "(Room) Renumbering...\r\n" ); /* * what we do here is, for each list (room/obj/mob) first we * * take each element out of the hash array, change the vnum, * * and move it to our own list. after everything's moved out * * we put it in again. this is to avoid problems in situations * * where where room A is being moved to position B, but theres * * already a room B wich is also being moved to position C. * * a straightforward approach would result in us moving A to * * position B first, and then again to position C, and room * * B being lost inside the hash array, still there, but not * * foundable (its "covered" by A because they'd have the same * * vnum). */ room_list = NULL; for( r_data = r_area->r_room; r_data; r_data = r_data->next ) { if( verbose ) pager_printf( ch, "(Room) %d -> %d\r\n", r_data->old_vnum, r_data->new_vnum ); room = get_room_index( r_data->old_vnum ); if( !room ) { bug( "renumber_area: NULL room %d", r_data->old_vnum ); continue; } /* * remove it from the hash list */ iHash = r_data->old_vnum % MAX_KEY_HASH; if( room_index_hash[iHash] == room ) room_index_hash[iHash] = room->next; else { for( room_prev = room_index_hash[iHash]; room_prev && room_prev->next != room; room_prev = room_prev->next ) ; if( room_prev == NULL ) { bug( "renumber_area: Couldn't find a room in the hash table! Skipping it.\r\n" ); continue; } room_prev->next = room->next; room->next = NULL; } /* * change the vnum */ room->vnum = r_data->new_vnum; /* * move it to the temporary list */ room->next = room_list; room_list = room; } /* * now move everything back into the hash array */ for( room = room_list; room; room = room_next ) { room_next = room->next; /* * add it to the hash list again (new position) */ iHash = room->vnum % MAX_KEY_HASH; room->next = room_index_hash[iHash]; room_index_hash[iHash] = room; } /* * if nothing was moved, or if the area is proto, dont change this */ if( r_area->r_room != NULL && !area_is_proto ) { area->low_r_vnum = r_area->low_room; area->hi_r_vnum = r_area->hi_room; } pager_printf( ch, "(Mobs) Renumbering...\r\n" ); mob_list = NULL; for( r_data = r_area->r_mob; r_data; r_data = r_data->next ) { if( verbose ) pager_printf( ch, "(Mobs) %d -> %d\r\n", r_data->old_vnum, r_data->new_vnum ); mob = get_mob_index( r_data->old_vnum ); if( !mob ) { bug( "renumber_area: NULL mob %d", r_data->old_vnum ); continue; } /* * fix references to this mob from shops while renumbering this mob */ if( mob->pShop ) { if( verbose ) pager_printf( ch, "(Mobs) Fixing shop for mob %d -> %d\r\n", r_data->old_vnum, r_data->new_vnum ); mob->pShop->keeper = r_data->new_vnum; } if( mob->rShop ) { if( verbose ) pager_printf( ch, "(Mobs) Fixing repair shop for mob %d -> %d\r\n", r_data->old_vnum, r_data->new_vnum ); mob->rShop->keeper = r_data->new_vnum; } /* * remove it from the hash list */ iHash = r_data->old_vnum % MAX_KEY_HASH; if( mob_index_hash[iHash] == mob ) mob_index_hash[iHash] = mob->next; else { for( mob_prev = mob_index_hash[iHash]; mob_prev && mob_prev->next != mob; mob_prev = mob_prev->next ) ; if( mob_prev == NULL ) { bug( "renumber_area: Couldn't find a mob in the hash table! Skipping it.\r\n" ); continue; } mob_prev->next = mob->next; mob->next = NULL; } /* * change the vnum */ mob->vnum = r_data->new_vnum; /* * move to private list */ mob->next = mob_list; mob_list = mob; } for( mob = mob_list; mob; mob = mob_next ) { mob_next = mob->next; /* * add it to the hash list again */ iHash = mob->vnum % MAX_KEY_HASH; mob->next = mob_index_hash[iHash]; mob_index_hash[iHash] = mob; } if( r_area->r_mob && !area_is_proto ) { area->low_m_vnum = r_area->low_mob; area->hi_m_vnum = r_area->hi_mob; } pager_printf( ch, "(Objs) Renumbering...\r\n" ); obj_list = NULL; for( r_data = r_area->r_obj; r_data; r_data = r_data->next ) { if( verbose ) pager_printf( ch, "(Objs) %d -> %d\r\n", r_data->old_vnum, r_data->new_vnum ); obj = get_obj_index( r_data->old_vnum ); if( !obj ) { bug( "renumber_area: NULL obj %d", r_data->old_vnum ); continue; } /* * remove it from the hash list */ iHash = r_data->old_vnum % MAX_KEY_HASH; if( obj_index_hash[iHash] == obj ) obj_index_hash[iHash] = obj->next; else { for( obj_prev = obj_index_hash[iHash]; obj_prev && obj_prev->next != obj; obj_prev = obj_prev->next ) ; if( obj_prev == NULL ) { bug( "renumber_area: Couldn't find an obj in the hash table! Skipping it.\r\n" ); continue; } obj_prev->next = obj->next; obj->next = NULL; } /* * change the vnum */ obj->vnum = r_data->new_vnum; /* * to our list */ obj->next = obj_list; obj_list = obj; } for( obj = obj_list; obj; obj = obj_next ) { obj_next = obj->next; /* * add it to the hash list again */ iHash = obj->vnum % MAX_KEY_HASH; obj->next = obj_index_hash[iHash]; obj_index_hash[iHash] = obj; } if( r_area->r_obj && !area_is_proto ) { area->low_o_vnum = r_area->low_obj; area->hi_o_vnum = r_area->hi_obj; } pager_printf( ch, "Fixing references...\r\n" ); pager_printf( ch, "... fixing objvals...\r\n" ); translate_objvals( ch, area, r_area, verbose ); pager_printf( ch, "... fixing exits...\r\n" ); translate_exits( ch, area, r_area, verbose ); pager_printf( ch, "... fixing resets...\r\n" ); for( room = area->first_room; room; room = room->next_aroom ) { for( preset = room->first_reset; preset; preset = preset->next ) { translate_reset( preset, r_area ); for( treset = preset->first_reset; treset; treset = preset->next_reset ) translate_reset( treset, r_area ); } } if( verbose ) { pager_printf( ch, "Searching progs for references to renumbered vnums...\r\n" ); warn_progs( ch, low, high, area, r_area ); } }
void do_shopset( CHAR_DATA *ch, char *argument ) { SHOP_DATA *shop; MOB_INDEX_DATA *mob, *mob2; char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; int vnum; int value; argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); if ( arg1[0] == '\0' || arg2[0] == '\0' ) { send_to_char( "Usage: shopset <mob vnum> <field> value\n\r", ch ); send_to_char( "\n\rField being one of:\n\r", ch ); send_to_char( " buy0 buy1 buy2 buy3 buy4 buy sell open close keeper\n\r", ch ); return; } vnum = atoi( arg1 ); if ( (mob = get_mob_index(vnum)) == NULL ) { send_to_char( "Mobile not found.\n\r", ch ); return; } if ( !can_medit(ch, mob) ) return; if ( !mob->pShop ) { send_to_char( "This mobile doesn't keep a shop.\n\r", ch ); return; } shop = mob->pShop; value = atoi( argument ); if ( !str_cmp( arg2, "buy0" ) ) { if ( !is_number(argument) ) value = get_otype(argument); if ( value < 0 || value > MAX_ITEM_TYPE ) { send_to_char( "Invalid item type!\n\r", ch ); return; } shop->buy_type[0] = value; send_to_char( "Done.\n\r", ch ); return; } if ( !str_cmp( arg2, "buy1" ) ) { if ( !is_number(argument) ) value = get_otype(argument); if ( value < 0 || value > MAX_ITEM_TYPE ) { send_to_char( "Invalid item type!\n\r", ch ); return; } shop->buy_type[1] = value; send_to_char( "Done.\n\r", ch ); return; } if ( !str_cmp( arg2, "buy2" ) ) { if ( !is_number(argument) ) value = get_otype(argument); if ( value < 0 || value > MAX_ITEM_TYPE ) { send_to_char( "Invalid item type!\n\r", ch ); return; } shop->buy_type[2] = value; send_to_char( "Done.\n\r", ch ); return; } if ( !str_cmp( arg2, "buy3" ) ) { if ( !is_number(argument) ) value = get_otype(argument); if ( value < 0 || value > MAX_ITEM_TYPE ) { send_to_char( "Invalid item type!\n\r", ch ); return; } shop->buy_type[3] = value; send_to_char( "Done.\n\r", ch ); return; } if ( !str_cmp( arg2, "buy4" ) ) { if ( !is_number(argument) ) value = get_otype(argument); if ( value < 0 || value > MAX_ITEM_TYPE ) { send_to_char( "Invalid item type!\n\r", ch ); return; } shop->buy_type[4] = value; send_to_char( "Done.\n\r", ch ); return; } if ( !str_cmp( arg2, "buy" ) ) { if ( value <= (shop->profit_sell+5) || value > 1000 ) { send_to_char( "Out of range.\n\r", ch ); return; } shop->profit_buy = value; send_to_char( "Done.\n\r", ch ); return; } if ( !str_cmp( arg2, "sell" ) ) { if ( value < 0 || value >= (shop->profit_buy-5) ) { send_to_char( "Out of range.\n\r", ch ); return; } shop->profit_sell = value; send_to_char( "Done.\n\r", ch ); return; } if ( !str_cmp( arg2, "open" ) ) { if ( value < 0 || value > 23 ) { send_to_char( "Out of range.\n\r", ch ); return; } shop->open_hour = value; send_to_char( "Done.\n\r", ch ); return; } if ( !str_cmp( arg2, "close" ) ) { if ( value < 0 || value > 23 ) { send_to_char( "Out of range.\n\r", ch ); return; } shop->close_hour = value; send_to_char( "Done.\n\r", ch ); return; } if ( !str_cmp( arg2, "keeper" ) ) { if ( (mob2 = get_mob_index(vnum)) == NULL ) { send_to_char( "Mobile not found.\n\r", ch ); return; } if ( !can_medit(ch, mob) ) return; if ( mob2->pShop ) { send_to_char( "That mobile already has a shop.\n\r", ch ); return; } mob->pShop = NULL; mob2->pShop = shop; shop->keeper = value; send_to_char( "Done.\n\r", ch ); return; } do_shopset( ch, "" ); return; }
// Added by SinaC 2003 for Circle style void load_mob_circle( FILE *fp ) { MOB_INDEX_DATA *pMobIndex; log_stringf(" MOBILES"); if ( !area_last ) { /* OLC */ bug( "Load_mob_circle: no #AREA seen yet."); exit( 1 ); } for ( ; ; ) { int vnum; char letter; int iHash; letter = fread_letter( fp ); if ( letter != '#' ) { bug( "Load_mob_circle: # not found."); exit( 1 ); } vnum = fread_number( fp ); if ( vnum == 0 ) break; fBootDb = FALSE; if ( get_mob_index( vnum ) != NULL ) { bug( "Load_mob_circle: vnum %d duplicated.", vnum ); exit( 1 ); } fBootDb = TRUE; // pMobIndex = (MOB_INDEX_DATA*) alloc_perm( sizeof(*pMobIndex) ); pMobIndex = new_mob_index(); pMobIndex->vnum = vnum; pMobIndex->area = area_last; /* OLC */ pMobIndex->new_format = TRUE; newmobs++; pMobIndex->player_name = fread_string( fp ); pMobIndex->short_descr = fread_string( fp ); pMobIndex->long_descr = fread_string_upper( fp ); pMobIndex->description = fread_string_upper( fp ); // Added by SinaC 2003 pMobIndex->classes = 0; pMobIndex->act = fread_flag_circle( fp ); pMobIndex->affected_by = fread_flag_circle( fp ); // Added by SinaC 2003 pMobIndex->affected2_by = 0; pMobIndex->pShop = NULL; // Added by SinaC 2003 pMobIndex->align.etho = 0; pMobIndex->align.alignment = fread_number( fp ); letter = fread_letter( fp ); // mobile type S or E pMobIndex->group = 0; pMobIndex->level = fread_number( fp ); // Added by SinaC 2003 if ( pMobIndex->level < pMobIndex->area->low_range ) pMobIndex->area->low_range = pMobIndex->level; if ( pMobIndex->level > pMobIndex->area->high_range ) pMobIndex->area->high_range = pMobIndex->level; fread_number( fp ); // thac0 not used pMobIndex->ac[AC_PIERCE] = fread_number( fp ); // ac pMobIndex->ac[AC_BASH] = pMobIndex->ac[AC_PIERCE]; pMobIndex->ac[AC_SLASH] = pMobIndex->ac[AC_PIERCE]; pMobIndex->ac[AC_EXOTIC] = pMobIndex->ac[AC_PIERCE]; /* read hit dice */ pMobIndex->hit[DICE_NUMBER] = fread_number( fp ); /* 'd' */ fread_letter( fp ); pMobIndex->hit[DICE_TYPE] = fread_number( fp ); /* '+' */ fread_letter( fp ); pMobIndex->hit[DICE_BONUS] = fread_number( fp ); pMobIndex->mana[DICE_NUMBER]= 0; pMobIndex->mana[DICE_TYPE] = 0; pMobIndex->mana[DICE_BONUS] = 0; pMobIndex->psp[DICE_NUMBER] = 0; pMobIndex->psp[DICE_TYPE] = 0; pMobIndex->psp[DICE_BONUS] = 0; /* read damage dice */ pMobIndex->damage[DICE_NUMBER] = fread_number( fp ); fread_letter( fp ); pMobIndex->damage[DICE_TYPE] = fread_number( fp ); fread_letter( fp ); pMobIndex->damage[DICE_BONUS] = fread_number( fp ); //pMobIndex->wealth = fread_number( fp ) * 100; *100 was not needed pMobIndex->wealth = fread_number( fp ); fread_number(fp); // Xp not used pMobIndex->start_pos = fread_number(fp); pMobIndex->default_pos = fread_number(fp); pMobIndex->sex = fread_number(fp); if ( letter != 'S' && letter != 'E' ) { bug("Invalid letter (%c) for mob (%d), valid letter are S or E", letter, pMobIndex->vnum ); exit(-1); } pMobIndex->race = 0; pMobIndex->hitroll = 0; pMobIndex->res_flags = 0; pMobIndex->imm_flags = 0; pMobIndex->vuln_flags = 0; if ( letter == 'E' ) { // complex mob while(1) { char *ln = fread_line( fp ); if ( ln[0] == 'E' ) break; } } while(1) { letter = fread_letter( fp ); if ( letter == 'T' ) { // Script int scriptVnum = fread_number( fp ); char buf[MAX_STRING_LENGTH]; sprintf( buf, "mob%d", vnum ); pMobIndex->program = hash_get_prog(buf); if (!pMobIndex->program) bug("Can't find program for mob vnum %d.", pMobIndex->vnum); else { if ( get_root_class( pMobIndex->program ) != default_mob_class ) { bug("program for mob vnum %d is not a mob program.", pMobIndex->vnum); pMobIndex->program = NULL; } else if ( pMobIndex->program->isAbstract ) bug("program for mob vnum %d is an ABSTRACT class.", pMobIndex->vnum ); } } else { ungetc(letter,fp); break; } } convert_mob_circle( pMobIndex ); iHash = vnum % MAX_KEY_HASH; pMobIndex->next = mob_index_hash[iHash]; mob_index_hash[iHash] = pMobIndex; top_vnum_mob = top_vnum_mob < vnum ? vnum : top_vnum_mob; /* OLC */ assign_area_vnum( vnum ); /* OLC */ kill_table[URANGE(0, pMobIndex->level, MAX_LEVEL-1)].number++; } return; }
/* * Snarf a shop section. */ void load_shops_circle( FILE *fp ) { SHOP_DATA *pShop; log_stringf(" SHOPS"); bool OLD = TRUE; for ( ; ; ) { MOB_INDEX_DATA *pMobIndex; int iTrade = 0; pShop = new_shop(); // log_stringf("====START"); bool stop = FALSE; while (1) { char c = fread_letter(fp); // log_stringf("=>[%c]", c ); if ( c == '0' ) { // If shopvnum is 0: end of shop section stop = TRUE; break; } else if ( c == '#' ) { const char *s = fread_string(fp); // log_stringf("->[%s]", s ); break; } else if ( c < '0' || c > '9' ) { // File starts with a string ungetc(c,fp); const char *s = fread_string(fp); if ( !str_prefix("CircleMUD v3.0 Shop File",s) ) OLD = FALSE; log_stringf("))[%s] [%d]", s, !str_prefix( "CircleMUD v3.0 Shop File", s ) ); } else { int x = fread_number(fp); // should never happens // log_stringf(">>>[%d]", x ); break; } } if (stop) break; log_stringf("OLD: %s", OLD?"yes":"no"); // Skips infinite obj vnum int count = 0; while (1) { int tmp = fread_number(fp); if ( tmp == -1 ) break; count++; if ( count >= 5 && OLD ) break; } pShop->profit_buy = (int)(fread_float( fp )*100.0); pShop->profit_sell = (int)(fread_float( fp )*100.0); // Read item type while (1) { //int tmp = fread_number(fp); fread_to_eol(fp); // skips end of line (special ShopV3 format) int tmp = 0; char letter = fread_letter(fp); if ( ( letter >= '0' && letter <= '9' ) || letter == '-' ) { // if we read a number -> item_type ungetc(letter,fp); tmp = fread_number(fp); } else // else -> skips fread_to_eol(fp); if ( tmp == -1 ) break; if ( iTrade < MAX_TRADE ) pShop->buy_type[iTrade++] = item_type_circle(tmp); else log_stringf("Too many item type, [%d] not stored", tmp ); if ( iTrade >= 5 && OLD ) break; } // Skips 7 string for ( int i = 0; i < 7; i++ ) { const char *s = fread_string(fp); } fread_number(fp); // skips temper fread_number(fp); // skips shop bitvector pShop->keeper = fread_number( fp ); // get shop mob vnum fread_number(fp); // skips with who bitvector // skips shop room vnum while (1) { int tmp = fread_number(fp); if ( tmp == -1 ) break; if ( OLD ) // only one shop vnum for OLD format break; } pShop->open_hour = URANGE(0,fread_number( fp ),23); // get opening hour pShop->close_hour = URANGE(0,fread_number( fp ),23); fread_number(fp); // skips second opening hour fread_number(fp); // " pMobIndex = get_mob_index( pShop->keeper ); pMobIndex->pShop = pShop; if ( shop_first == NULL ) shop_first = pShop; if ( shop_last != NULL ) shop_last->next = pShop; shop_last = pShop; pShop->next = NULL; } return; }
void do_repairset( CHAR_DATA *ch, char *argument ) { REPAIR_DATA *repair; MOB_INDEX_DATA *mob, *mob2; char arg1[MAX_INPUT_LENGTH]; char arg2[MAX_INPUT_LENGTH]; int vnum; int value; argument = one_argument( argument, arg1 ); argument = one_argument( argument, arg2 ); if ( arg1[0] == '\0' || arg2[0] == '\0' ) { send_to_char( "Usage: repairset <mob vnum> <field> value\n\r", ch ); send_to_char( "\n\rField being one of:\n\r", ch ); send_to_char( " fix0 fix1 fix2 profit type open close keeper\n\r", ch ); return; } vnum = atoi( arg1 ); if ( (mob = get_mob_index(vnum)) == NULL ) { send_to_char( "Mobile not found.\n\r", ch ); return; } if ( !can_medit(ch, mob) ) return; if ( !mob->rShop ) { send_to_char( "This mobile doesn't keep a repair shop.\n\r", ch ); return; } repair = mob->rShop; value = atoi( argument ); if ( !str_cmp( arg2, "fix0" ) ) { if ( !is_number(argument) ) value = get_otype(argument); if ( value < 0 || value > MAX_ITEM_TYPE ) { send_to_char( "Invalid item type!\n\r", ch ); return; } repair->fix_type[0] = value; send_to_char( "Done.\n\r", ch ); return; } if ( !str_cmp( arg2, "fix1" ) ) { if ( !is_number(argument) ) value = get_otype(argument); if ( value < 0 || value > MAX_ITEM_TYPE ) { send_to_char( "Invalid item type!\n\r", ch ); return; } repair->fix_type[1] = value; send_to_char( "Done.\n\r", ch ); return; } if ( !str_cmp( arg2, "fix2" ) ) { if ( !is_number(argument) ) value = get_otype(argument); if ( value < 0 || value > MAX_ITEM_TYPE ) { send_to_char( "Invalid item type!\n\r", ch ); return; } repair->fix_type[2] = value; send_to_char( "Done.\n\r", ch ); return; } if ( !str_cmp( arg2, "profit" ) ) { if ( value < 1 || value > 1000 ) { send_to_char( "Out of range.\n\r", ch ); return; } repair->profit_fix = value; send_to_char( "Done.\n\r", ch ); return; } if ( !str_cmp( arg2, "type" ) ) { if ( value < 1 || value > 2 ) { send_to_char( "Out of range.\n\r", ch ); return; } repair->shop_type = value; send_to_char( "Done.\n\r", ch ); return; } if ( !str_cmp( arg2, "open" ) ) { if ( value < 0 || value > 23 ) { send_to_char( "Out of range.\n\r", ch ); return; } repair->open_hour = value; send_to_char( "Done.\n\r", ch ); return; } if ( !str_cmp( arg2, "close" ) ) { if ( value < 0 || value > 23 ) { send_to_char( "Out of range.\n\r", ch ); return; } repair->close_hour = value; send_to_char( "Done.\n\r", ch ); return; } if ( !str_cmp( arg2, "keeper" ) ) { if ( (mob2 = get_mob_index(vnum)) == NULL ) { send_to_char( "Mobile not found.\n\r", ch ); return; } if ( !can_medit(ch, mob) ) return; if ( mob2->rShop ) { send_to_char( "That mobile already has a repair shop.\n\r", ch ); return; } mob->rShop = NULL; mob2->rShop = repair; repair->keeper = value; send_to_char( "Done.\n\r", ch ); return; } do_repairset( ch, "" ); return; }