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; }
void fread_pfile( FILE * fp, time_t tdiff, char *fname, bool count ) { const char *word; char *name = NULL; char *clan = NULL; char *deity = NULL; short level = 0; short file_ver = 0; EXT_BV pact; bool fMatch; for( ;; ) { word = feof( fp ) ? "End" : fread_word( fp ); fMatch = FALSE; switch ( UPPER( word[0] ) ) { case '*': fMatch = TRUE; fread_to_eol( fp ); break; case 'A': KEY( "Act", pact, fread_bitvector( fp ) ); break; case 'C': KEY( "Clan", clan, fread_string( fp ) ); break; case 'D': KEY( "Deity", deity, fread_string( fp ) ); break; case 'E': if( !strcmp( word, "End" ) ) goto timecheck; break; case 'L': KEY( "Level", level, fread_number( fp ) ); break; case 'N': KEY( "Name", name, fread_string( fp ) ); break; case 'V': KEY( "Version", file_ver, fread_number( fp ) ); break; } if( !fMatch ) fread_to_eol( fp ); } timecheck: if( count == FALSE && !xIS_SET( pact, PLR_EXEMPT ) ) { if( level < 10 && tdiff > sysdata.newbie_purge ) { if( unlink( fname ) == -1 ) perror( "Unlink" ); else { days = sysdata.newbie_purge; snprintf( log_buf, MAX_STRING_LENGTH, "Player %s was deleted. Exceeded time limit of %d days.", name, days ); log_string( log_buf ); #ifdef AUTO_AUTH remove_from_auth( name ); #endif deleted++; return; } } if( level < LEVEL_IMMORTAL && tdiff > sysdata.regular_purge ) { if( level < LEVEL_IMMORTAL ) { if( unlink( fname ) == -1 ) perror( "Unlink" ); else { days = sysdata.regular_purge; snprintf( log_buf, MAX_STRING_LENGTH, "Player %s was deleted. Exceeded time limit of %d days.", name, days ); log_string( log_buf ); #ifdef AUTO_AUTH remove_from_auth( name ); #endif deleted++; return; } } } } if( clan != NULL ) { CLAN_DATA *guild = get_clan( clan ); if( guild ) guild->members++; } if( deity != NULL ) { DEITY_DATA *god = get_deity( deity ); if( god ) god->worshippers++; } if( clan ) STRFREE( clan ); if( name ) STRFREE( name ); if( deity ) STRFREE( deity ); return; }