Пример #1
0
void do_mpmset( CHAR_DATA * ch, const char *argument )
{
	char arg1[MAX_INPUT_LENGTH];
	char arg2[MAX_INPUT_LENGTH];
	char arg3[MAX_INPUT_LENGTH];
	char buf[MAX_STRING_LENGTH];
	char log_buf[MAX_STRING_LENGTH];
	char outbuf[MAX_STRING_LENGTH];
	CHAR_DATA *victim;
	int value, v2;
	int minattr, maxattr;

	/*
	 * A desc means switched.. too many loopholes if we allow that.. 
	 */
	if ( !IS_NPC( ch ) || IS_AFFECTED( ch, AFF_CHARM ) || ch->desc )
	{
		send_to_char( "Huh?\r\n", ch );
		return;
	}

	smash_tilde( argument );

	argument = one_argument( argument, arg1 );
	argument = one_argument( argument, arg2 );
	mudstrlcpy( arg3, argument, MAX_INPUT_LENGTH );

	if ( !*arg1 )
	{
		progbug( "MpMset: no args", ch );
		return;
	}

	if ( ( victim = get_char_room( ch, arg1 ) ) == NULL )
	{
		progbug( "MpMset: no victim", ch );
		return;
	}

	if ( IS_IMMORTAL( victim ) )
	{
		send_to_char( "You can't do that!\r\n", ch );
		return;
	}

	if ( IS_NPC( victim ) && xIS_SET( victim->act, ACT_PROTOTYPE ) )
	{
		progbug( "MpMset: victim is proto", ch );
		return;
	}

	if ( IS_NPC( victim ) )
	{
		minattr = 1;
		maxattr = 25;
	}
	else
	{
		minattr = 3;
		maxattr = 18;
	}

	value = is_number( arg3 ) ? atoi( arg3 ) : -1;
	if ( atoi( arg3 ) < -1 && value == -1 )
		value = atoi( arg3 );

	if ( !str_cmp( arg2, "str" ) )
	{
		if ( value < minattr || value > maxattr )
		{
			progbug( "MpMset: Invalid str", ch );
			return;
		}
		victim->perm_str = value;
		return;
	}

	if ( !str_cmp( arg2, "int" ) )
	{
		if ( value < minattr || value > maxattr )
		{
			progbug( "MpMset: Invalid int", ch );
			return;
		}
		victim->perm_int = value;
		return;
	}

	if ( !str_cmp( arg2, "wis" ) )
	{
		if ( value < minattr || value > maxattr )
		{
			progbug( "MpMset: Invalid wis", ch );
			return;
		}
		victim->perm_wis = value;
		return;
	}

	if ( !str_cmp( arg2, "dex" ) )
	{
		if ( value < minattr || value > maxattr )
		{
			progbug( "MpMset: Invalid dex", ch );
			return;
		}
		victim->perm_dex = value;
		return;
	}

	if ( !str_cmp( arg2, "con" ) )
	{
		if ( value < minattr || value > maxattr )
		{
			progbug( "MpMset: Invalid con", ch );
			return;
		}
		victim->perm_con = value;
		return;
	}

	if ( !str_cmp( arg2, "cha" ) )
	{
		if ( value < minattr || value > maxattr )
		{
			progbug( "MpMset: Invalid cha", ch );
			return;
		}
		victim->perm_cha = value;
		return;
	}

	if ( !str_cmp( arg2, "lck" ) )
	{
		if ( value < minattr || value > maxattr )
		{
			progbug( "MpMset: Invalid lck", ch );
			return;
		}
		victim->perm_lck = value;
		return;
	}

	if ( !str_cmp( arg2, "sav1" ) )
	{
		if ( value < -30 || value > 30 )
		{
			progbug( "MpMset: Invalid sav1", ch );
			return;
		}
		victim->saving_poison_death = value;
		return;
	}

	if ( !str_cmp( arg2, "sav2" ) )
	{
		if ( value < -30 || value > 30 )
		{
			progbug( "MpMset: Invalid sav2", ch );
			return;
		}
		victim->saving_wand = value;
		return;
	}

	if ( !str_cmp( arg2, "sav3" ) )
	{
		if ( value < -30 || value > 30 )
		{
			progbug( "MpMset: Invalid sav3", ch );
			return;
		}
		victim->saving_para_petri = value;
		return;
	}

	if ( !str_cmp( arg2, "sav4" ) )
	{
		if ( value < -30 || value > 30 )
		{
			progbug( "MpMset: Invalid sav4", ch );
			return;
		}
		victim->saving_breath = value;
		return;
	}

	if ( !str_cmp( arg2, "sav5" ) )
	{
		if ( value < -30 || value > 30 )
		{
			progbug( "MpMset: Invalid sav5", ch );
			return;
		}
		victim->saving_spell_staff = value;
		return;
	}

	if ( !str_cmp( arg2, "sex" ) )
	{
		if ( value < 0 || value > 2 )
		{
			progbug( "MpMset: Invalid sex", ch );
			return;
		}
		victim->sex = value;
		return;
	}

	if ( !str_cmp( arg2, "class" ) )
	{
		if ( IS_NPC( victim ) )	/* Broken by Haus... fixed by Thoric */
		{
			if ( value >= MAX_NPC_CLASS || value < 0 )
			{
				progbug( "MpMset: Invalid npc class", ch );
				return;
			}
			victim->Class = value;
			return;
		}
		progbug( "MpMset: can't set pc class", ch );
	}

	if ( !str_cmp( arg2, "race" ) )
	{
		value = get_npc_race( arg3 );
		if ( value < 0 )
			value = atoi( arg3 );
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc race", ch );
			return;
		}
		if ( value < 0 || value >= MAX_NPC_RACE )
		{
			progbug( "MpMset: Invalid npc race", ch );
			return;
		}
		victim->race = value;
		return;
	}

	if ( !str_cmp( arg2, "armor" ) )
	{
		if ( value < -300 || value > 300 )
		{
			send_to_char( "AC range is -300 to 300.\r\n", ch );
			return;
		}
		victim->armor = value;
		return;
	}

	if ( !str_cmp( arg2, "level" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc level", ch );
			return;
		}

		if ( value < 0 || value > LEVEL_AVATAR + 5 )
		{
			progbug( "MpMset: Invalid npc level", ch );
			return;
		}
		victim->level = value;
		return;
	}

	if ( !str_cmp( arg2, "numattacks" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc numattacks", ch );
			return;
		}

		if ( value < 0 || value > 20 )
		{
			progbug( "MpMset: Invalid npc numattacks", ch );
			return;
		}
		victim->numattacks = value;
		return;
	}

	if ( !str_cmp( arg2, "gold" ) )
	{
		victim->gold = value;
		return;
	}

	if ( !str_cmp( arg2, "hitroll" ) )
	{
		victim->hitroll = URANGE( 0, value, 85 );
		return;
	}

	if ( !str_cmp( arg2, "damroll" ) )
	{
		victim->damroll = URANGE( 0, value, 65 );
		return;
	}

	if ( !str_cmp( arg2, "hp" ) )
	{
		if ( value < 1 || value > 32700 )
		{
			progbug( "MpMset: Invalid hp", ch );
			return;
		}
		victim->max_hit = value;
		return;
	}

	if ( !str_cmp( arg2, "mana" ) )
	{
		if ( value < 0 || value > 30000 )
		{
			progbug( "MpMset: Invalid mana", ch );
			return;
		}
		victim->max_mana = value;
		return;
	}

	if ( !str_cmp( arg2, "move" ) )
	{
		if ( value < 0 || value > 30000 )
		{
			progbug( "MpMset: Invalid move", ch );
			return;
		}
		victim->max_move = value;
		return;
	}

	if ( !str_cmp( arg2, "practice" ) )
	{
		if ( value < 0 || value > 100 )
		{
			progbug( "MpMset: Invalid practice", ch );
			return;
		}
		victim->practice = value;
		return;
	}

	if ( !str_cmp( arg2, "align" ) )
	{
		if ( value < -1000 || value > 1000 )
		{
			progbug( "MpMset: Invalid align", ch );
			return;
		}
		victim->alignment = value;
		return;
	}

/* non-functional for now -- Blod
    if ( !str_cmp( arg2, "quest" ) )
    {
	if ( IS_NPC(victim) )
	{
	    progbug("MpMset: can't set npc quest", ch);
	    return;
	}

	if ( value < 0 || value > 500 )
	{
	    progbug("MpMset: Invalid pc quest", ch);
	    return;
	}

	victim->pcdata->quest = value;
	return;
    }
*/

	if ( !str_cmp( arg2, "questplus" ) )
	{
		if ( IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set npc qp", ch );
			return;
		}

		if ( value < 0 || value > 5000 )
		{
			progbug( "MpMset: Invalid pc qp", ch );
			return;
		}
		snprintf( log_buf, MAX_STRING_LENGTH, "%s raising glory of %s by %d ...", ch->name, victim->name, value );
		log_string( log_buf );
		victim->pcdata->quest_curr += value;
		victim->pcdata->quest_accum += value;
		return;
	}

	if ( !str_cmp( arg2, "favor" ) )
	{
		if ( IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set npc favor", ch );
			return;
		}

		if ( value < -2500 || value > 2500 )
		{
			progbug( "MpMset: Invalid pc favor", ch );
			return;
		}

		victim->pcdata->favor = value;
		return;
	}

	if ( !str_cmp( arg2, "mentalstate" ) )
	{
		if ( value < -100 || value > 100 )
		{
			progbug( "MpMset: Invalid mentalstate", ch );
			return;
		}
		victim->mental_state = value;
		return;
	}

	if ( !str_cmp( arg2, "emotion" ) )
	{
		if ( value < -100 || value > 100 )
		{
			progbug( "MpMset: Invalid emotion", ch );
			return;
		}
		victim->emotional_state = value;
		return;
	}

	if ( !str_cmp( arg2, "thirst" ) )
	{
		if ( IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set npc thirst", ch );
			return;
		}

		if ( value < 0 || value > 100 )
		{
			progbug( "MpMset: Invalid pc thirst", ch );
			return;
		}

		victim->pcdata->condition[COND_THIRST] = value;
		return;
	}

	if ( !str_cmp( arg2, "drunk" ) )
	{
		if ( IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set npc drunk", ch );
			return;
		}

		if ( value < 0 || value > 100 )
		{
			progbug( "MpMset: Invalid pc drunk", ch );
			return;
		}

		victim->pcdata->condition[COND_DRUNK] = value;
		return;
	}

	if ( !str_cmp( arg2, "full" ) )
	{
		if ( IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set npc full", ch );
			return;
		}

		if ( value < 0 || value > 100 )
		{
			progbug( "MpMset: Invalid pc full", ch );
			return;
		}

		victim->pcdata->condition[COND_FULL] = value;
		return;
	}

	if ( !str_cmp( arg2, "blood" ) )
	{
		if ( IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set npc blood", ch );
			return;
		}

		if ( value < 0 || value > MAX_LEVEL + 10 )
		{
			progbug( "MpMset: Invalid pc blood", ch );
			return;
		}

		victim->pcdata->condition[COND_BLOODTHIRST] = value;
		return;
	}

	if ( !str_cmp( arg2, "name" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc name", ch );
			return;
		}

		STRFREE( victim->name );
		victim->name = STRALLOC( arg3 );
		return;
	}

	if ( !str_cmp( arg2, "deity" ) )
	{
		DEITY_DATA *deity;

		if ( IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set npc deity", ch );
			return;
		}

		if ( arg3[0] == '\0' )
		{
			STRFREE( victim->pcdata->deity_name );
			victim->pcdata->deity_name = STRALLOC( "" );
			victim->pcdata->deity = NULL;
			return;
		}

		deity = get_deity( arg3 );
		if ( !deity )
		{
			progbug( "MpMset: Invalid deity", ch );
			return;
		}
		STRFREE( victim->pcdata->deity_name );
		victim->pcdata->deity_name = QUICKLINK( deity->name );
		victim->pcdata->deity = deity;
		return;
	}

	if ( !str_cmp( arg2, "short" ) )
	{
		STRFREE( victim->short_descr );
		victim->short_descr = STRALLOC( arg3 );
		return;
	}

	if ( !str_cmp( arg2, "long" ) )
	{
		STRFREE( victim->long_descr );
		mudstrlcpy( buf, arg3, MAX_STRING_LENGTH );
		mudstrlcat( buf, "\r\n", MAX_STRING_LENGTH );
		victim->long_descr = STRALLOC( buf );
		return;
	}

	if ( !str_cmp( arg2, "title" ) )
	{
		if ( IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set npc title", ch );
			return;
		}

		set_title( victim, arg3 );
		return;
	}

	if ( !str_cmp( arg2, "spec" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc spec", ch );
			return;
		}

		if ( !str_cmp( arg3, "none" ) )
		{
			victim->spec_fun = NULL;
			return;
		}

		if ( ( victim->spec_fun = spec_lookup( arg3 ) ) == 0 )
		{
			progbug( "MpMset: Invalid spec", ch );
			return;
		}
		return;
	}

	if ( !str_cmp( arg2, "flags" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc flags", ch );
			return;
		}

		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpMset: no flags", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_actflag( arg3 );
			if ( value < 0 || value >= MAX_BITS )
				progbug( "MpMset: Invalid flag", ch );
			else
			{
				if ( value == ACT_PROTOTYPE )
					progbug( "MpMset: can't set prototype flag", ch );
				else if ( value == ACT_IS_NPC )
					progbug( "MpMset: can't remove npc flag", ch );
				else
					xTOGGLE_BIT( victim->act, value );
			}
		}
		return;
	}

	if ( !str_cmp( arg2, "affected" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't modify pc affected", ch );
			return;
		}

		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpMset: no affected", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_aflag( arg3 );
			if ( value < 0 || value >= MAX_BITS )
				progbug( "MpMset: Invalid affected", ch );
			else
				xTOGGLE_BIT( victim->affected_by, value );
		}
		return;
	}

	/*
	 * save some more finger-leather for setting RIS stuff
	 * Why there's can_modify checks here AND in the called function, Ill
	 * never know, so I removed them.. -- Alty
	 */
	if ( !str_cmp( arg2, "r" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s resistant %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		return;
	}
	if ( !str_cmp( arg2, "i" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s immune %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		return;
	}
	if ( !str_cmp( arg2, "s" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s susceptible %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		return;
	}
	if ( !str_cmp( arg2, "ri" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s resistant %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		snprintf( outbuf, MAX_STRING_LENGTH, "%s immune %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		return;
	}

	if ( !str_cmp( arg2, "rs" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s resistant %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		snprintf( outbuf, MAX_STRING_LENGTH, "%s susceptible %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		return;
	}
	if ( !str_cmp( arg2, "is" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s immune %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		snprintf( outbuf, MAX_STRING_LENGTH, "%s susceptible %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		return;
	}
	if ( !str_cmp( arg2, "ris" ) )
	{
		snprintf( outbuf, MAX_STRING_LENGTH, "%s resistant %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		snprintf( outbuf, MAX_STRING_LENGTH, "%s immune %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		snprintf( outbuf, MAX_STRING_LENGTH, "%s susceptible %s", arg1, arg3 );
		do_mpmset( ch, outbuf );
		return;
	}

	if ( !str_cmp( arg2, "resistant" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc resistant", ch );
			return;
		}
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpMset: no resistant", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_risflag( arg3 );
			if ( value < 0 || value > 31 )
				progbug( "MpMset: Invalid resistant", ch );
			else
				TOGGLE_BIT( victim->resistant, 1 << value );
		}
		return;
	}

	if ( !str_cmp( arg2, "immune" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc immune", ch );
			return;
		}
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpMset: no immune", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_risflag( arg3 );
			if ( value < 0 || value > 31 )
				progbug( "MpMset: Invalid immune", ch );
			else
				TOGGLE_BIT( victim->immune, 1 << value );
		}
		return;
	}

	if ( !str_cmp( arg2, "susceptible" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc susceptible", ch );
			return;
		}
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpMset: no susceptible", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_risflag( arg3 );
			if ( value < 0 || value > 31 )
				progbug( "MpMset: Invalid susceptible", ch );
			else
				TOGGLE_BIT( victim->susceptible, 1 << value );
		}
		return;
	}

	if ( !str_cmp( arg2, "part" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc part", ch );
			return;
		}
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpMset: no part", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_partflag( arg3 );
			if ( value < 0 || value > 31 )
				progbug( "MpMset: Invalid part", ch );
			else
				TOGGLE_BIT( victim->xflags, 1 << value );
		}
		return;
	}

	if ( !str_cmp( arg2, "attack" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc attack", ch );
			return;
		}
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpMset: no attack", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_attackflag( arg3 );
			if ( value < 0 )
				progbug( "MpMset: Invalid attack", ch );
			else
				xTOGGLE_BIT( victim->attacks, value );
		}
		return;
	}

	if ( !str_cmp( arg2, "defense" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc defense", ch );
			return;
		}
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpMset: no defense", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_defenseflag( arg3 );
			if ( value < 0 || value >= MAX_BITS )
				progbug( "MpMset: Invalid defense", ch );
			else
				xTOGGLE_BIT( victim->defenses, value );
		}
		return;
	}

	if ( !str_cmp( arg2, "pos" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc pos", ch );
			return;
		}
		if ( value < 0 || value > POS_STANDING )
		{
			progbug( "MpMset: Invalid pos", ch );
			return;
		}
		victim->position = value;
		return;
	}

	if ( !str_cmp( arg2, "defpos" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc defpos", ch );
			return;
		}
		if ( value < 0 || value > POS_STANDING )
		{
			progbug( "MpMset: Invalid defpos", ch );
			return;
		}
		victim->defposition = value;
		return;
	}

	if ( !str_cmp( arg2, "speaks" ) )
	{
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpMset: no speaks", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_langflag( arg3 );
			v2 = get_langnum( arg3 );
			if ( value == LANG_UNKNOWN )
				progbug( "MpMset: Invalid speaks", ch );
			else if ( !IS_NPC( victim ) )
			{
				if ( !( value &= VALID_LANGS ) )
				{
					progbug( "MpMset: Invalid player language", ch );
					continue;
				}
				if ( v2 == -1 )
					ch_printf( ch, "Unknown language: %s\r\n", arg3 );
				else
					TOGGLE_BIT( victim->speaks, 1 << v2 );
			}
			else
			{
				if ( v2 == -1 )
					ch_printf( ch, "Unknown language: %s\r\n", arg3 );
				else
					TOGGLE_BIT( victim->speaks, 1 << v2 );
			}
		}
		if ( !IS_NPC( victim ) )
		{
			REMOVE_BIT( victim->speaks, race_table[victim->race]->language );
			if ( !knows_language( victim, victim->speaking, victim ) )
				victim->speaking = race_table[victim->race]->language;
		}
		return;
	}

	if ( !str_cmp( arg2, "speaking" ) )
	{
		if ( !IS_NPC( victim ) )
		{
			progbug( "MpMset: can't set pc speaking", ch );
			return;
		}
		if ( !argument || argument[0] == '\0' )
		{
			progbug( "MpMset: no speaking", ch );
			return;
		}
		while ( argument[0] != '\0' )
		{
			argument = one_argument( argument, arg3 );
			value = get_langflag( arg3 );
			if ( value == LANG_UNKNOWN )
				progbug( "MpMset: Invalid speaking", ch );
			else
			{
				v2 = get_langnum( arg3 );
				if ( v2 == -1 )
					ch_printf( ch, "Unknown language: %s\r\n", arg3 );
				else
					TOGGLE_BIT( victim->speaks, 1 << v2 );
			}
		}
		return;
	}

	progbug( "MpMset: Invalid field", ch );
	return;
}
Пример #2
0
void fread_fuss_mobile( FILE * fp, area_data * tarea )
{
   mob_index *pMobIndex = nullptr;
   bool oldmob = false;

   for( ;; )
   {
      const char *word = ( feof( fp ) ? "#ENDMOBILE" : fread_word( fp ) );

      if( word[0] == '\0' )
      {
         log_printf( "%s: EOF encountered reading file!", __func__ );
         word = "#ENDMOBILE";
      }

      switch ( word[0] )
      {
         default:
            log_printf( "%s: no match: %s", __func__, word );
            fread_to_eol( fp );
            break;

         case '#':
            // We can cheat here since the prog formats are identical :)
            if( !str_cmp( word, "#MUDPROG" ) )
            {
               mud_prog_data *mprg = new mud_prog_data;
               fread_afk_mudprog( fp, mprg, pMobIndex );
               pMobIndex->mudprogs.push_back( mprg );
               ++top_prog;
               break;
            }

            if( !str_cmp( word, "#ENDMOBILE" ) )
            {
               if( !oldmob )
               {
                  mob_index_table.insert( map < int, mob_index * >::value_type( pMobIndex->vnum, pMobIndex ) );
                  tarea->mobs.push_back( pMobIndex );
                  ++top_mob_index;
               }
               return;
            }
            break;

         case 'A':
            if( !str_cmp( word, "Actflags" ) )
            {
               flag_set( fp, pMobIndex->actflags, fuss_act_flags );
               break;
            }

            if( !str_cmp( word, "Affected" ) )
            {
               flag_set( fp, pMobIndex->affected_by, aff_flags );
               break;
            }

            if( !str_cmp( word, "Attacks" ) )
            {
               flag_set( fp, pMobIndex->attacks, attack_flags );
               break;
            }

            if( !str_cmp( word, "Attribs" ) )
            {
               const char *ln = fread_line( fp );
               int x1, x2, x3, x4, x5, x6, x7;

               x1 = x2 = x3 = x4 = x5 = x6 = x7 = 0;
               sscanf( ln, "%d %d %d %d %d %d %d", &x1, &x2, &x3, &x4, &x5, &x6, &x7 );

               pMobIndex->perm_str = x1;
               pMobIndex->perm_int = x2;
               pMobIndex->perm_wis = x3;
               pMobIndex->perm_dex = x4;
               pMobIndex->perm_con = x5;
               pMobIndex->perm_cha = x6;
               pMobIndex->perm_lck = x7;

               break;
            }
            break;

         case 'B':
            if( !str_cmp( word, "Bodyparts" ) )
            {
               flag_set( fp, pMobIndex->body_parts, part_flags );
               break;
            }
            break;

         case 'C':
            if( !str_cmp( word, "Class" ) )
            {
               const char *class_word = fread_flagstring( fp );
               short Class = get_fuss_npc_class( class_word );

               if( Class < 0 || Class >= MAX_NPC_CLASS )
               {
                  bug( "%s: vnum %d: Mob has invalid class: %s. Defaulting to warrior.", __func__, pMobIndex->vnum, class_word );
                  Class = get_npc_class( "warrior" );
               }

               pMobIndex->Class = Class;
               break;
            }
            break;

         case 'D':
            if( !str_cmp( word, "Defenses" ) )
            {
               flag_set( fp, pMobIndex->defenses, defense_flags );
               break;
            }

            if( !str_cmp( word, "DefPos" ) )
            {
               short position = get_npc_position( fread_flagstring( fp ) );

               if( position < 0 || position >= POS_MAX )
               {
                  bug( "%s: vnum %d: Mobile in invalid default position! Defaulting to standing.", __func__, pMobIndex->vnum );
                  position = POS_STANDING;
               }
               pMobIndex->defposition = position;
               break;
            }

            if( !str_cmp( word, "Desc" ) )
            {
               const char *desc = fread_flagstring( fp );

               if( desc && desc[0] != '\0' && str_cmp( desc, "(null)" ) )
                  pMobIndex->chardesc = STRALLOC( desc );
               break;
            }
            break;

         case 'G':
            if( !str_cmp( word, "Gender" ) )
            {
               short sex = get_npc_sex( fread_flagstring( fp ) );

               if( sex < 0 || sex > SEX_FEMALE )
               {
                  bug( "%s: vnum %d: Mobile has invalid sex! Defaulting to neuter.", __func__, pMobIndex->vnum );
                  sex = SEX_NEUTRAL;
               }
               pMobIndex->sex = sex;
               break;
            }
            break;

         case 'I':
            if( !str_cmp( word, "Immune" ) )
            {
               flag_set( fp, pMobIndex->immune, ris_flags );
               break;
            }
            break;

         case 'K':
            KEY( "Keywords", pMobIndex->player_name, fread_string( fp ) );
            break;

         case 'L':
            KEY( "Long", pMobIndex->long_descr, fread_string( fp ) );
            break;

         case 'P':
            if( !str_cmp( word, "Position" ) )
            {
               short position = get_npc_position( fread_flagstring( fp ) );

               if( position < 0 || position >= POS_MAX )
               {
                  bug( "%s: vnum %d: Mobile in invalid position! Defaulting to standing.", __func__, pMobIndex->vnum );
                  position = POS_STANDING;
               }
               pMobIndex->position = position;
               break;
            }
            break;

         case 'R':
            if( !str_cmp( word, "Race" ) )
            {
               const char *race_word = fread_flagstring( fp );
               short race = get_fuss_npc_race( race_word );

               if( race < 0 || race >= MAX_NPC_RACE )
               {
                  bug( "%s: vnum %d: Mob has invalid race: %s Defaulting to monster.", __func__, pMobIndex->vnum, race_word );
                  race = get_npc_race( "monster" );
               }

               pMobIndex->race = race;
               break;
            }

            if( !str_cmp( word, "RepairData" ) )
            {
               int iFix;
               repair_data *rShop = new repair_data;

               rShop->keeper = pMobIndex->vnum;
               for( iFix = 0; iFix < MAX_FIX; ++iFix )
                  rShop->fix_type[iFix] = fread_number( fp );
               rShop->profit_fix = fread_number( fp );
               rShop->shop_type = fread_number( fp );
               rShop->open_hour = fread_number( fp );
               rShop->close_hour = fread_number( fp );

               pMobIndex->rShop = rShop;
               repairlist.push_back( rShop );
               ++top_repair;

               break;
            }

            if( !str_cmp( word, "Resist" ) )
            {
               flag_set( fp, pMobIndex->resistant, ris_flags );
               break;
            }
            break;

         case 'S':
            // Unused - this is autocalced in mobindex.cpp
            if( !str_cmp( word, "Saves" ) )
            {
               fread_line( fp );
               break;
            }

            KEY( "Short", pMobIndex->short_descr, fread_string( fp ) );

            if( !str_cmp( word, "ShopData" ) )
            {
               int iTrade;
               shop_data *pShop = new shop_data;

               pShop->keeper = pMobIndex->vnum;
               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->profit_buy = URANGE( pShop->profit_sell + 5, pShop->profit_buy, 1000 );
               pShop->profit_sell = URANGE( 0, pShop->profit_sell, pShop->profit_buy - 5 );
               pShop->open_hour = fread_number( fp );
               pShop->close_hour = fread_number( fp );

               pMobIndex->pShop = pShop;
               shoplist.push_back( pShop );
               ++top_shop;

               break;
            }

            if( !str_cmp( word, "Speaks" ) )
            {
               flag_set( fp, pMobIndex->speaks, lang_names );

               if( pMobIndex->speaks.none(  ) )
                  pMobIndex->speaks.set( LANG_COMMON );
               break;
            }

            if( !str_cmp( word, "Speaking" ) )
            {
               string speaking, flag;
               int value;

               speaking = fread_flagstring( fp );

               speaking = one_argument( speaking, flag );
               value = get_langnum( flag );
               if( value < 0 || value >= LANG_UNKNOWN )
                  bug( "Unknown speaking language: %s", flag.c_str() );
               else
                  pMobIndex->speaking = value;

               if( !pMobIndex->speaking )
                  pMobIndex->speaking = LANG_COMMON;
               break;
            }

            if( !str_cmp( word, "Specfun" ) )
            {
               const char *temp = fread_flagstring( fp );

               if( !pMobIndex )
               {
                  bug( "%s: Specfun: Invalid mob vnum!", __func__ );
                  break;
               }
               if( !( pMobIndex->spec_fun = m_spec_lookup( temp ) ) )
               {
                  bug( "%s: Specfun: vnum %d, no spec_fun called %s.", __func__, pMobIndex->vnum, temp );
                  pMobIndex->spec_funname.clear(  );
               }
               else
                  pMobIndex->spec_funname = temp;
               break;
            }

            if( !str_cmp( word, "Stats1" ) )
            {
               const char *ln = fread_line( fp );
               int x1, x2, x3, x4, x5, x6;

               x1 = x2 = x3 = x4 = x5 = x6 = 0;
               sscanf( ln, "%d %d %d %d %d %d", &x1, &x2, &x3, &x4, &x5, &x6 );

               pMobIndex->alignment = x1;
               pMobIndex->level = x2;
               pMobIndex->mobthac0 = x3;
               pMobIndex->ac = x4;
               pMobIndex->gold = x5;
               pMobIndex->exp = -1; // Converts to AFKMud auto-calc exp

               break;
            }

            if( !str_cmp( word, "Stats2" ) )
            {
               const char *ln = fread_line( fp );
               int x1, x2, x3;
               x1 = x2 = x3 = 0;
               sscanf( ln, "%d %d %d", &x1, &x2, &x3 );

               pMobIndex->hitnodice = pMobIndex->level;
               pMobIndex->hitsizedice = 8;
               pMobIndex->hitplus = x3;

               break;
            }

            if( !str_cmp( word, "Stats3" ) )
            {
               const char *ln = fread_line( fp );
               int x1, x2, x3;
               x1 = x2 = x3 = 0;
               sscanf( ln, "%d %d %d", &x1, &x2, &x3 );

               pMobIndex->damnodice = x1;
               pMobIndex->damsizedice = x2;
               pMobIndex->damplus = x3;

               break;
            }

            if( !str_cmp( word, "Stats4" ) )
            {
               const char *ln = fread_line( fp );
               int x1, x2, x3, x4, x5;

               x1 = x2 = x3 = x4 = x5 = 0;
               sscanf( ln, "%d %d %d %d %d", &x1, &x2, &x3, &x4, &x5 );

               pMobIndex->height = x1;
               pMobIndex->weight = x2;
               pMobIndex->numattacks = x3;
               pMobIndex->hitroll = x4;
               pMobIndex->damroll = x5;

               break;
            }

            if( !str_cmp( word, "Suscept" ) )
            {
               flag_set( fp, pMobIndex->susceptible, ris_flags );
               break;
            }
            break;

         case 'V':
            if( !str_cmp( word, "Vnum" ) )
            {
               bool tmpBootDb = fBootDb;
               fBootDb = false;

               int vnum = fread_number( fp );

               list < area_data * >::iterator iarea;
               for( iarea = arealist.begin(  ); iarea != arealist.end(  ); ++iarea )
               {
                  area_data *area = *iarea;

                  if( !str_cmp( area->filename, tarea->filename ) )
                     continue;

                  bool area_conflict = check_area_conflict( area, vnum, vnum );

                  if( area_conflict )
                  {
                     log_printf( "ERROR: %s has vnum conflict with %s!", tarea->filename, ( area->filename ? area->filename : "(invalid)" ) );
                     log_printf( "%s occupies vnums   : %-6d - %-6d", ( area->filename ? area->filename : "(invalid)" ), area->low_vnum, area->hi_vnum );
                     log_printf( "%s wants to use vnum: %-6d", tarea->filename, vnum );
                     log_string( "This is a fatal error. Program terminated." );
                     exit( 1 );
                  }
               }

               if( get_mob_index( vnum ) )
               {
                  if( tmpBootDb )
                  {
                     fBootDb = tmpBootDb;
                     bug( "%s: vnum %d duplicated.", __func__, vnum );

                     // Try to recover, read to end of duplicated mobile and then bail out
                     for( ;; )
                     {
                        word = feof( fp ) ? "#ENDMOBILE" : fread_word( fp );

                        if( !str_cmp( word, "#ENDMOBILE" ) )
                           return;
                     }
                  }
                  else
                  {
                     pMobIndex = get_mob_index( vnum );
                     log_printf_plus( LOG_BUILD, sysdata->build_level, "Cleaning mobile: %d", vnum );
                     pMobIndex->clean_mob(  );
                     oldmob = true;
                  }
               }
               else
               {
                  pMobIndex = new mob_index;
                  pMobIndex->clean_mob(  );
               }
               pMobIndex->vnum = vnum;
               pMobIndex->area = tarea;
               fBootDb = tmpBootDb;

               if( fBootDb )
               {
                  if( !tarea->low_vnum )
                     tarea->low_vnum = vnum;
                  if( vnum > tarea->hi_vnum )
                     tarea->hi_vnum = vnum;
               }
               break;
            }
            break;
      }
   }
}