void build_save() { int a; char filename[255]; char buf[MAX_STRING_LENGTH]; for (a=0;a<CurLoops && saving_area>0;a++) { if ( saving_area== START_SAVING) { CurrentSaving=(CurrentSaving+1) % SAVEQUEUESIZE; CurSaveArea=SaveQ[CurrentSaving].area; CurSaveChar=SaveQ[CurrentSaving].ch; CurLoops=SaveQ[CurrentSaving].loops; send_to_char("Starting Save.\n",CurSaveChar); sprintf(filename,"%s.new",CurSaveArea->filename); SaveFile=fopen(filename,"w"); if (SaveFile==NULL) { if (CurrentSaving==ToBeSaved) saving_area=NOT_SAVING; send_to_char("Can not open file for saving.\n",CurSaveChar); return; } /* Open second file for saving in envy format */ sprintf( buf, "Starting to save %s", CurSaveArea->filename ); monitor_chan( buf, MONITOR_AREA_SAVING ); Section=1; offset=CurSaveArea->offset; saving_area=AM_SAVING; Pointer=NULL; ResetPointer=NULL; } switch (Section) { case BUILD_SEC_AREA: build_save_area(); break; case BUILD_SEC_HELP: build_save_help(); break; case BUILD_SEC_ROOMS: build_save_rooms(); break; case BUILD_SEC_MOBILES: build_save_mobs(); break; case BUILD_SEC_MOBPROGS: build_save_mobprogs(); break; case BUILD_SEC_OBJECTS: build_save_objects(); break; case BUILD_SEC_SHOPS: build_save_shops(); break; case BUILD_SEC_RESETS: build_save_resets(); break; case BUILD_SEC_SPECIALS: build_save_specs(); break; case BUILD_SEC_OBJFUNS: build_save_objfuns(); break; case BUILD_SEC_END: build_save_end(); break; } } return; }
char *take_best_coins( MONEY_TYPE * money, int cost ) { /* best fits a money to a base cost, returns a buf with change val as first arg, then the coin string in keyword format to take */ int still_needs = cost; int unit_level, cnt, can_take_this, change; char takecatbuf[MSL], debug_moneybuf[MSL], takebuf[MSL]; static char returnbuf[MSL]; MONEY_TYPE *transaction = new MONEY_TYPE; MONEY_TYPE *debug_money; unit_level = 0; /* start at smallest currency unit */ change = 0; for ( cnt = 0; cnt < MAX_CURRENCY; cnt++ ) transaction->cash_unit[cnt] = money->cash_unit[cnt]; takebuf[0] = '\0'; for ( ; still_needs > 0; ) { /* * take smallest unit, see what happens */ can_take_this = transaction->cash_unit[unit_level] * currency_table[unit_level].exchange_val; if ( can_take_this >= still_needs ) { short how_many; how_many = ( still_needs / currency_table[unit_level].exchange_val ) + ( ( still_needs % currency_table[unit_level].exchange_val != 0 ) ? 1 : 0 ); change = change + ( how_many * currency_table[unit_level].exchange_val ) - still_needs; still_needs = 0; snprintf( takecatbuf, MSL, " %d %s", how_many, currency_table[unit_level].keyword ); strncat( takebuf, takecatbuf, MSL - 1 ); break; } else { snprintf( takecatbuf, MSL, " %d %s", transaction->cash_unit[unit_level], currency_table[unit_level].keyword ); strncat( takebuf, takecatbuf, MSL - 1 ); transaction->cash_unit[unit_level] = 0; still_needs -= can_take_this; unit_level++; } } change = change + ( 0 - still_needs ); debug_money = round_money( cost, TRUE ); snprintf( debug_moneybuf, MSL, "%s", money_string( debug_money ) ); snprintf( log_buf, (2 * MIL), "Buy: cost: %d ( %s )\r\n, money has %s\r\n, wants to take %s\r\n, change %d.", cost, debug_moneybuf, money_string( money ), takebuf, change ); monitor_chan( log_buf, MONITOR_DEBUG ); delete transaction; delete debug_money; snprintf( returnbuf, MSL, "%d %s", change, takebuf ); return returnbuf; }
void send_email( const char * m_address, const char * m_subject, const char * mfilename ) { FILE *mailfp; char mailbuf[MSL]; char mailfpbuf[MSL]; char delbuf[MSL]; char dbbuf[MSL]; int forkval; sprintf( mailbuf, "mail -s \"%s\" %s <%s%s", m_subject, m_address, MAIL_DIR, capitalize( mfilename ) ); signal( SIGCHLD, SIG_IGN ); if ( ( forkval = fork() ) > 0 ) { sprintf( dbbuf, "Just sent email: %s", mailbuf ); monitor_chan( NULL, dbbuf, MONITOR_SYSTEM ); return; } else if ( forkval < 0 ) { sprintf( dbbuf, "Error in fork for sent email: %s", mailbuf ); monitor_chan( NULL, dbbuf, MONITOR_SYSTEM ); return; } sprintf( mailfpbuf, "%s%s", MAIL_DIR, mfilename ); if ( ( mailfp = fopen( mailfpbuf, "r" ) ) == NULL ) { fpReserve = fopen( NULL_FILE, "r" ); kill( getpid(), SIGKILL ); /* didn't have a valid file to mail */ } fclose( mailfp ); system( mailbuf ); sprintf( delbuf, "rm %s%s", MAIL_DIR, mfilename ); system( delbuf ); kill( getpid(), SIGKILL ); return; }
/* * Return ascii name of an item type. */ char *item_type_name( OBJ_DATA *obj ) { char log[MAX_STRING_LENGTH]; switch ( obj->item_type ) { case ITEM_LIGHT: return "light"; case ITEM_AMMO: return "ammo"; case ITEM_BOMB: return "bomb"; case ITEM_BLUEPRINT: return "blueprint"; case ITEM_SUIT: return "suit"; case ITEM_MEDPACK: return "medpack"; case ITEM_WEAPON: return "weapon"; case ITEM_DRONE: return "drone"; case ITEM_ARMOR: return "armor"; case ITEM_TELEPORTER: return "teleporter"; case ITEM_IMPLANT: return "implant"; case ITEM_BOARD: return "bulletin board"; case ITEM_INSTALLATION: return "installation"; case ITEM_TOKEN: return "token"; case ITEM_MATERIAL: return "material"; case ITEM_FLAG: return "flag"; case ITEM_DART_BOARD: return "dart board"; case ITEM_ELEMENT: return "element"; case ITEM_CONTAINER: return "container"; case ITEM_WEAPON_UP: return "weapon upgrade"; case ITEM_PIECE: return "piece"; case ITEM_COMPUTER: return "computer"; case ITEM_LOCATOR: return "item locator"; case ITEM_SKILL_UP: return "skill upgrade"; case ITEM_PART: return "vehicle part"; case ITEM_DISK: return "disk"; case ITEM_TRASH: return "trash"; case ITEM_ASTEROID: return "asteroid"; case ITEM_VEHICLE_UP: return "vehicle addon"; case ITEM_TOOLKIT: return "toolkit"; case ITEM_SCAFFOLD: return "scaffold"; case ITEM_ORE: return "ore"; case ITEM_BIOTUNNEL: return "Bio Tunnel"; case ITEM_BATTERY: return "battery"; } sprintf( log, "Item_type_name: Object: %d. Unknown Type: %d", obj->pIndexData->vnum, obj->item_type ); monitor_chan( NULL, log, MONITOR_OBJ ); bug( log, 0 ); return "(unknown)"; }
void cache_check_social( ) { SOCIAL_DATA *soc; list<SOCIAL_DATA *>::iterator li; for( li = social_list.begin(); li != social_list.end(); li++ ) { soc = *li; if( --soc->cache_time <= 0 ) { snprintf( log_buf, MIL, "cache_check_social: removing file (%s) from cache, time expired", soc->name.c_str() ); monitor_chan( log_buf, MONITOR_DEBUG ); delete soc; li = social_list.erase(li); } } return; }
void build_save_end() { char filename[255]; char buf[MAX_STRING_LENGTH]; sprintf( buf, "Finished saving %s", CurSaveArea->filename ); monitor_chan( buf, MONITOR_AREA_SAVING ); fprintf(SaveFile,"#$\n"); send_to_char("Finished saving.\n",CurSaveChar); fclose(SaveFile); /* Save backup */ sprintf(filename,"%s.old",CurSaveArea->filename); rename(CurSaveArea->filename,filename); /* And rename .new to area filename */ sprintf(filename,"%s.new",CurSaveArea->filename); rename(filename,CurSaveArea->filename); Section=0; if (ToBeSaved==(CurrentSaving+1) % SAVEQUEUESIZE) saving_area=NOT_SAVING; else saving_area=START_SAVING; }
/* * The main entry point for executing commands. * Can be recursively called from 'at', 'order', 'force'. */ void interpret( CHAR_DATA *ch, char *argument ) { /* BUG with aliases: they can call themselves, which is * a Bad Thing. When an alias calls interp, we'll add * a '~' char as the first char. Checking for this will * tell us if we need to check aliases again. -S- */ bool alias_call; char command[MAX_INPUT_LENGTH]; char logline[MAX_INPUT_LENGTH]; int cmd; int trust; bool found; alias_call = FALSE; if ( ch->position == POS_WRITING ) /* if player is writing, pass argument straight to write_interpret */ { write_interpret( ch, argument ); return; } if ( ch->position == POS_BUILDING ) { if (argument[0]==':') argument++; else { build_interpret(ch,argument); return; } } /* * Strip leading spaces. */ while ( isspace(*argument) ) argument++; if ( argument[0] == '\0' ) return; if ( argument[0] == '~' ) { argument++; alias_call = TRUE; } /* * No hiding. */ REMOVE_BIT( ch->affected_by, AFF_HIDE ); /* * Implement freeze command. */ if ( !IS_NPC(ch) && IS_SET(ch->act, PLR_FREEZE) ) { send_to_char( "@@a@@fYou're totally frozen!@@N\n\r", ch ); return; } if ( ch->stunTimer > 0 ) { send_to_char( "You are too@@aSTUNNED@@N to act!\n\r", ch ); return; } /* * Grab the command word. * Special parsing so ' can be a command, * also no spaces needed after punctuation. */ strcpy( logline, argument ); if ( !isalpha(argument[0]) && !isdigit(argument[0]) ) { command[0] = argument[0]; command[1] = '\0'; argument++; while ( isspace(*argument) ) argument++; } else { argument = one_argument( argument, command ); } /* * Look for command in command table. */ found = FALSE; trust = get_trust( ch ); for ( cmd = 0; cmd_table[cmd].name[0] != '\0'; cmd++ ) { /* Stephen Mod: if level == CLAN_ONLY then for clan member only. == BOSS_ONLY have to be leader. == -3 vamp == -4 wolf */ if ( cmd_table[cmd].level == CLAN_ONLY && !IS_NPC( ch ) && ch->pcdata->clan == 0 ) continue; if ( cmd_table[cmd].level == BOSS_ONLY && !IS_NPC( ch ) && !IS_SET( ch->pcdata->pflags, PFLAG_CLAN_BOSS ) ) continue; if ( cmd_table[cmd].level == VAMP_ONLY && !IS_NPC( ch ) && !IS_VAMP( ch ) && ( ch->level != L_GOD ) ) continue; if ( cmd_table[cmd].level == WOLF_ONLY && !IS_NPC( ch ) && !IS_WOLF( ch ) && ( ch->level != L_GOD ) ) continue; if ( command[0] == cmd_table[cmd].name[0] && !str_prefix( command, cmd_table[cmd].name ) && ( cmd_table[cmd].level <= trust || MP_Commands( ch ) ) ) { found = TRUE; break; } } /* * Log and snoop. */ if ( cmd_table[cmd].log == LOG_NEVER ) strcpy( logline, "XXXXXXXX XXXXXXXX XXXXXXXX@@N"); if ( ( !IS_NPC(ch) && IS_SET(ch->act, PLR_LOG) ) || fLogAll || cmd_table[cmd].log == LOG_ALWAYS ) { sprintf( log_buf, "Log %s: %s", ch->name, logline ); log_string( log_buf ); if ( IS_SET( ch->act, PLR_LOG ) ) monitor_chan( log_buf, MONITOR_BAD ); else if ( cmd_table[cmd].level > LEVEL_HERO ) monitor_chan( log_buf, MONITOR_GEN_IMM ); else monitor_chan( log_buf, MONITOR_GEN_MORT ); } if ( ch->desc != NULL && ch->desc->snoop_by != NULL ) /* -S- Mod */ { char snp[MAX_STRING_LENGTH]; sprintf( snp, "[Snoop:%s] %s\n\r", ch->name, logline ); write_to_buffer( ch->desc->snoop_by, snp, 0 ); } if ( !found && !IS_NPC( ch ) && (!alias_call) ) { int cnt; char foo[MAX_STRING_LENGTH]; /* Check aliases -S- */ for ( cnt = 0; cnt < MAX_ALIASES; cnt++ ) { if ( !str_cmp( ch->pcdata->alias_name[cnt], command ) && str_cmp( ch->pcdata->alias_name[cnt], "<none>@@N") ) { found = TRUE; sprintf( foo, "~%s %s", ch->pcdata->alias[cnt], argument ); interpret( ch, foo ); return; } } } if ( !found ) { /* * Look for command in socials table. */ if ( !check_social( ch, command, argument ) #ifdef IMC && !imc_command_hook( ch, command, argument ) #endif ) send_to_char( "Huh?\n\r", ch ); return; } /* * Character not in position for command? */ if ( ch->position < cmd_table[cmd].position ) { switch( ch->position ) { case POS_DEAD: send_to_char( "Lie still; you are @@dDEAD@@N.\n\r", ch ); break; case POS_MORTAL: case POS_INCAP: send_to_char( "You are @@Rhurt@@N far too bad for that.\n\r", ch ); break; case POS_STUNNED: send_to_char( "You are too @@estunned@@N to do that.\n\r", ch ); break; case POS_SLEEPING: send_to_char( "Oh, go back to @@Wsleep!@@N\n\r", ch ); break; case POS_RESTING: send_to_char( "Naaaaaah... You feel too @@brelaxed@@N...\n\r", ch); break; case POS_FIGHTING: send_to_char( "Not until you @@Rstop@@N fighting!\n\r", ch); break; } return; } /* * Dispatch the command. */ if ( !IS_NPC( ch ) && ( ( ch->stance == STANCE_AMBUSH ) || ( ch->stance == STANCE_AC_BEST ) ) && ( ( str_prefix( command, "kill" ) ) && ( str_prefix( command, "murder" ) ) && ( str_prefix( command, "backstab" ) ) && ( str_prefix( command, "bs" ) ) && ( str_prefix( command, "whisper" ) ) && ( str_prefix( command, "stake" ) ) && ( str_prefix( command, "steal" ) ) ) ) { send_to_char( "You step out of the shadows.\n\r", ch ); ch->stance = STANCE_WARRIOR; ch->stance_ac_mod = 0; ch->stance_dr_mod = 0; ch->stance_hr_mod = 0; act( "$n steps out of the Shadows!", ch, NULL, NULL, TO_ROOM ); } comlog(ch, cmd, argument); (*cmd_table[cmd].do_fun) ( ch, argument ); tail_chain( ); return; }
SOCIAL_DATA *load_social( const char *social ) { SOCIAL_DATA *ret; list<SOCIAL_DATA *>::iterator li; FILE *fp; char tmp[MSL] = {'\0'}; char search[MSL] = {'0'}; const char *word; bool fMatch = false; /* Check the cache list before trying to load from file --Kline */ for( li = social_list.begin(); li != social_list.end(); li++ ) { ret = *li; if( ret->name.find(social) != string::npos ) { snprintf( log_buf, MIL, "load_social: using cached copy of (%s) which expires in (%d)", ret->name.c_str(), ret->cache_time ); monitor_chan( log_buf, MONITOR_DEBUG ); ret->cache_time = sysdata.pulse_cache; return ret; } } ret = new SOCIAL_DATA; snprintf( search, MSL, "find %s%s/ -iname %s\\*.%s -printf '%%p'", SOCIAL_DIR, initial(social), social, SOCIAL_EXT ); snprintf( tmp, MSL, "%s", _popen(search) ); fp = file_open( tmp, "r" ); snprintf( tmp, MSL, "ls -1 %s%s/%s*.%s | cut -d/ -f4 | cut -d. -f1", SOCIAL_DIR, initial(social), social, SOCIAL_EXT ); ret->name = _popen(tmp); ret->name.resize(ret->name.length()-1); /* Strip off the appended \n --Kline */ for ( ;; ) { word = feof(fp) ? "End" : fread_word(fp); fMatch = false; switch ( UPPER(word[0]) ) { case '*': fMatch = true; fread_to_eol(fp); break; case 'C': KEY("CharAuto", ret->char_auto, fread_string( fp ) ); KEY("CharFound", ret->char_found, fread_string( fp ) ); KEY("CharNoArg", ret->char_no_arg, fread_string( fp ) ); break; case 'E': if ( !str_cmp(word, "End") ) { file_close(fp); return ret; } break; case 'O': KEY("OtherAuto", ret->other_auto, fread_string( fp ) ); KEY("OtherFound", ret->other_found, fread_string( fp ) ); KEY("OtherNoArg", ret->other_no_arg, fread_string( fp ) ); break; case 'V': KEY("VictFound", ret->vict_found, fread_string( fp ) ); break; } } if ( !fMatch ) { snprintf( log_buf, (2 * MIL), "Loading in social :%s, no match for ( %s ).", social, word ); monitor_chan( log_buf, MONITOR_BAD ); fread_to_eol( fp ); } file_close(fp); return ret; }
bool sp_damage( OBJ_DATA * obj, CHAR_DATA * ch, CHAR_DATA * victim, int dam, int type, int sn, bool show_msg ) { int ch_strong, ch_weak, ch_race, ch_suscept, ch_resist, vi_strong, vi_weak, vi_race, vi_suscept, vi_resist; float dam_modifier = 1.0; float tmp = 0; bool can_reflect = TRUE; bool can_absorb = TRUE; if ( victim == NULL ) return FALSE; /* * First, check caster's strengths and weaknesses. * */ if ( IS_SET( type, NO_REFLECT ) ) { REMOVE_BIT( type, NO_REFLECT ); can_reflect = FALSE; } if ( IS_SET( type, NO_ABSORB ) ) { REMOVE_BIT( type, NO_ABSORB ); can_absorb = FALSE; } if ( obj == NULL ) { if ( ( can_reflect ) && ( skill_table[sn].target == TAR_CHAR_OFFENSIVE ) && ( IS_AFFECTED( victim, AFF_CLOAK_REFLECTION ) ) && ( ch != victim ) && ( number_percent( ) < ( victim->get_level("psuedo") - 70 ) ) ) { act( "@@N$n's @@lc@@el@@ro@@ya@@ak@@N glows brightly as $Nn's spell hits it, and the spell is reflected@@N!!", ch, victim, NULL, TO_ROOM ); act( "@@N$N's @@lc@@el@@ro@@ya@@ak@@N glows brightly, and reflects your spell back on you@@N!!", ch, NULL, victim, TO_CHAR ); act( "@@NYour @@lc@@el@@ro@@ya@@ak@@N glows brightly, and reflects the spell back on $N@@N!!!", victim, NULL, ch, TO_CHAR ); ( *skill_table[sn].spell_fun ) ( sn, 60, ch, ( void * )ch, NULL ); return FALSE; } else if ( ( can_reflect ) && ( skill_table[sn].target == TAR_CHAR_OFFENSIVE ) && ( IS_AFFECTED( victim, AFF_CLOAK_ABSORPTION ) ) && ( ch != victim ) && ( number_percent( ) < ( victim->get_level("psuedo") - 55 ) ) ) { int mana; mana = mana_cost( ch, sn ); victim->mana = UMIN( victim->max_mana, victim->mana + mana ); act( "@@N$n's @@lcloak@@N glows brightly as $N's spell hits it, then fades@@N!!", victim, NULL, ch, TO_ROOM ); act( "@@N$N's @@lcloak@@N glows brightly, and absorbs your spell@@N!!", ch, NULL, victim, TO_CHAR ); act( "@@NYour @@lcloak@@N glows brightly, and absorbs $N's spell@@N!!!", victim, NULL, ch, TO_CHAR ); return FALSE; } ch_strong = ( IS_NPC( ch ) ? ( ( ( ch->race > 0 ) && ( ch->race < MAX_RACE ) ) ? race_table[ch->race].strong_realms : ch->npcdata->strong_magic ) : race_table[ch->race].strong_realms ); ch_resist = ( IS_NPC( ch ) ? ( ( ( ch->race > 0 ) && ( ch->race < MAX_RACE ) ) ? race_table[ch->race].resist_realms : ch->npcdata->resist ) : race_table[ch->race].resist_realms ); ch_weak = ( IS_NPC( ch ) ? ( ( ( ch->race > 0 ) && ( ch->race < MAX_RACE ) ) ? race_table[ch->race].weak_realms : ch->npcdata->weak_magic ) : race_table[ch->race].weak_realms ); ch_suscept = ( IS_NPC( ch ) ? ( ( ( ch->race > 0 ) && ( ch->race < MAX_RACE ) ) ? race_table[ch->race].suscept_realms : ch->npcdata->suscept ) : race_table[ch->race].suscept_realms ); ch_race = ( IS_NPC( ch ) ? ( ( ( ch->race > 0 ) && ( ch->race < MAX_RACE ) ) ? race_table[ch->race].race_flags : ch->race_mods ) : race_table[ch->race].race_flags ); if ( IS_SET( ch_strong, type ) ) { dam_modifier += .35; } else if ( IS_SET( ch_weak, type ) ) { dam_modifier -= .35; } if ( IS_SET( ch_race, RACE_MOD_STRONG_MAGIC ) ) { dam_modifier += .25; } else if ( IS_SET( ch_race, RACE_MOD_WEAK_MAGIC ) ) { dam_modifier -= .25; } else if ( IS_SET( ch_race, RACE_MOD_NO_MAGIC ) ) { dam_modifier -= .50; } if ( ch->stance == STANCE_CASTER ) dam_modifier += .10; else if ( ch->stance == STANCE_WIZARD ) dam_modifier += .25; else if ( ch->stance == STANCE_MAGI ) dam_modifier += .30; if ( ( !IS_NPC( ch ) ) && ( !IS_SET( type, REALM_MIND ) ) ) { if ( ch->pcdata->learned[gsn_potency] > 0 ) { dam_modifier += ( get_curr_int( ch ) * ch->pcdata->learned[gsn_potency] / 5000 ); } if ( ch->pcdata->learned[gsn_thaumatergy] > 0 ) { dam_modifier += ( get_curr_int( ch ) * ch->pcdata->learned[gsn_thaumatergy] / 2500 ); } } if ( is_affected( ch, skill_lookup( "mystical focus" ) ) ) { dam_modifier += .5; } } /* obj == NULL */ else if ( obj->carried_by != NULL ) { ch = obj->carried_by; } else { snprintf( log_buf, (2 * MIL), "Error, object %s casting spell, but not carried by anyone.", obj->short_descr ); monitor_chan( log_buf, MONITOR_DEBUG ); return FALSE; } /* * Next, the victim * */ vi_strong = ( IS_NPC( victim ) ? ( ( ( victim->race > 0 ) && ( victim->race < MAX_RACE ) ) ? race_table[victim->race].strong_realms : victim->npcdata->strong_magic ) : race_table[victim->race].strong_realms ); vi_resist = ( IS_NPC( victim ) ? ( ( ( victim->race > 0 ) && ( victim->race < MAX_RACE ) ) ? race_table[victim->race].resist_realms : victim->npcdata->resist ) : race_table[victim->race].resist_realms ); vi_weak = ( IS_NPC( victim ) ? ( ( ( victim->race > 0 ) && ( victim->race < MAX_RACE ) ) ? race_table[victim->race].weak_realms : victim->npcdata->weak_magic ) : race_table[victim->race].weak_realms ); vi_suscept = ( IS_NPC( victim ) ? ( ( ( victim->race > 0 ) && ( victim->race < MAX_RACE ) ) ? race_table[victim->race].suscept_realms : victim->npcdata->suscept ) : race_table[victim->race].suscept_realms ); vi_race = ( IS_NPC( victim ) ? ( ( ( victim->race > 0 ) && ( victim->race < MAX_RACE ) ) ? race_table[victim->race].race_flags : victim->race_mods ) : race_table[victim->race].race_flags ); if ( IS_SET( vi_suscept, type ) ) { dam_modifier += .45; } else if ( IS_SET( vi_resist, type ) ) { dam_modifier -= .45; } else if ( IS_SET( vi_race, RACE_MOD_NO_MAGIC ) ) { dam_modifier -= .25; } if ( MAGIC_STANCE( ch ) ) dam_modifier += .15; if ( ( IS_SET( type, REALM_MIND ) ) && ( !HAS_MIND( victim ) ) ) dam_modifier = 0.0; else if ( ( ( IS_SET( type, REALM_IMPACT ) ) || ( IS_SET( type, REALM_ACID ) ) || ( IS_SET( type, REALM_GAS ) ) ) && ( !HAS_BODY( victim ) ) ) dam_modifier = 0.0; if ( ( IS_SET( type, REALM_POISON ) ) && ( IS_SET( vi_race, RACE_MOD_IMMUNE_POISON ) ) ) dam_modifier = 0.0; if ( ( IS_SET( type, REALM_DRAIN ) ) && ( IS_UNDEAD( victim ) ) ) dam_modifier = 0.0; tmp = dam; tmp *= dam_modifier; if ( check_charm_aff(ch, CHARM_AFF_MAGE) ) tmp *= ((100 + get_charm_bonus(ch, CHARM_AFF_MAGE)) / 100); dam = static_cast<int>(tmp); dam += number_range(static_cast<int>((dam * -0.10)), static_cast<int>((dam * 0.10))); /* Lets add a little randomness to things. --Kline */ if ( victim != ch ) { /* * Certain attacks are forbidden. * Most other attacks are returned. */ if ( is_safe( ch, victim ) ) return FALSE; if ( victim != ch->fighting ) check_killer( ch, victim ); if ( victim->position > POS_STUNNED ) { if ( victim->fighting == NULL ) set_fighting( victim, ch, FALSE ); victim->position = POS_FIGHTING; } if ( victim->position > POS_STUNNED ) { if ( ch->fighting == NULL ) { set_fighting( ch, victim, TRUE ); } /* * If victim is charmed, ch might attack victim's master. */ if ( IS_NPC( ch ) && IS_NPC( victim ) && IS_AFFECTED( victim, AFF_CHARM ) && victim->master != NULL && victim->master->in_room == ch->in_room && number_bits( 3 ) == 0 ) { stop_fighting( ch ); one_hit( ch, victim->master, TYPE_UNDEFINED ); } } /* * More charm stuff. */ if ( victim->master == ch ) stop_follower( victim ); /* * Inviso attacks ... not. */ if ( IS_AFFECTED( ch, AFF_INVISIBLE ) ) { affect_strip( ch, gsn_invis ); affect_strip( ch, gsn_mass_invis ); REMOVE_BIT( ch->affected_by, AFF_INVISIBLE ); act( "$n shimmers into existence.", ch, NULL, NULL, TO_ROOM ); } /* * Damage modifiers. */ if ( dam < 0 ) dam = 0; /* * Stop up any residual loopholes. */ if ( dam > sysdata.damcap ) { char buf[MAX_STRING_LENGTH]; snprintf( buf, MSL, "Spell: %d damage by %s, spell %s", dam, ( obj == NULL ) ? ch->get_name() : obj->short_descr, skill_table[sn].name ); if ( ch->level < 82 ) monitor_chan( buf, MONITOR_MAGIC ); log_f( "%s", buf ); dam = sysdata.damcap; } if ( ( show_msg ) && ( dam >= 0 ) ) sp_dam_message( obj, ch, victim, dam, type, sn ); } /* * Hurt the victim. * Inform the victim of his new state. */ victim->hit -= dam; if ( !IS_NPC(ch) ) { if ( dam > ch->pcdata->records->mdam_amt ) { send_to_char("@@yYou've broken your magical damage record!@@N\r\n", ch); ch->pcdata->records->mdam_amt = dam; ch->pcdata->records->mdam_gsn = sn; } } if ( !IS_NPC( victim ) ) check_adrenaline( victim, dam ); if ( !IS_NPC( victim ) && IS_WOLF( victim ) && ( dam > 350 ) ) do_rage( victim, "FORCE" ); update_pos( victim ); if ( ( IS_NPC( victim ) || !IS_VAMP( victim ) ) && !( deathmatch ) ) { switch ( victim->position ) { case POS_MORTAL: act( "$n is mortally wounded, and will die soon, if not aided.", victim, NULL, NULL, TO_ROOM ); send_to_char( "You are mortally wounded, and will die soon, if not aided.\r\n", victim ); break; case POS_INCAP: act( "$n is incapacitated and will slowly die, if not aided.", victim, NULL, NULL, TO_ROOM ); send_to_char( "You are incapacitated and will slowly die, if not aided.\r\n", victim ); break; case POS_STUNNED: act( "$n is too stunned to do anything!", victim, NULL, NULL, TO_ROOM ); send_to_char( "You are too stunned to do anything!\r\n", victim ); break; case POS_DEAD: act( "$n is DEAD!!", victim, 0, 0, TO_ROOM ); send_to_char( "You have been KILLED!!\r\n\r\n", victim ); break; default: if ( dam > victim->max_hit / 4 ) send_to_char( "That really did HURT!\r\n", victim ); if ( victim->hit < victim->max_hit / 4 ) send_to_char( "You sure are BLEEDING!\r\n", victim ); break; } } /* end of if statement */ /* * Sleep spells and extremely wounded folks. */ if ( !IS_AWAKE( victim ) ) stop_fighting( victim ); /* * Payoff for killing things. */ if ( victim->position == POS_DEAD && ( IS_NPC( victim ) || !IS_VAMP( victim ) || ( deathmatch ) ) ) { group_gain( ch, victim ); /* * Sort out kill counts..... */ if ( !IS_NPC( ch ) ) { if ( !IS_NPC( victim ) ) ch->pcdata->records->pk++; else ch->pcdata->records->mk++; } if ( !IS_NPC( victim ) ) { if ( !IS_NPC( ch ) ) victim->pcdata->records->pd++; else victim->pcdata->records->md++; } if ( !IS_NPC( victim ) || victim->act.test(ACT_INTELLIGENT) ) { snprintf( log_buf, (2 * MIL), "%s killed by %s at %d", victim->get_name(), ch->get_name(), victim->in_room->vnum ); log_string( log_buf ); notify( log_buf, 82 ); /* * As level gain is no longer automatic, a dead char loses * * 1/2 their gained exp. -S- * * Fixed my bug here too, hehe! */ if ( victim->exp > 0 ) { int lose = (victim->exp / 2); lose *= -1; victim->gain_exp(lose); } } if ( IS_NPC( ch ) ) raw_kill( victim, "" ); else { char name_buf[MAX_STRING_LENGTH]; snprintf( name_buf, MSL, "%s", ch->name.c_str() ); raw_kill( victim, name_buf ); } if ( deathmatch && !IS_NPC( victim ) ) do_quit( victim, "" ); if ( IS_NPC( ch ) && IS_NPC( victim ) && ch->act.test(ACT_INTELLIGENT) ) { do_get( ch, "all corpse" ); do_sacrifice( ch, "corpse" ); } if ( !IS_NPC( ch ) && IS_NPC( victim ) ) { if ( ch->act.test(ACT_AUTOLOOT) ) do_get( ch, "all corpse" ); else do_look( ch, "in corpse" ); if ( ch->act.test(ACT_AUTOSAC) ) do_sacrifice( ch, "corpse" ); } return FALSE; } if ( victim == ch ) return TRUE; /* * Take care of link dead people. */ if ( !IS_NPC( victim ) && victim->desc == NULL ) { if ( number_range( 0, victim->wait ) == 0 ) { do_recall( victim, "" ); return TRUE; } } /* * Wimp out? */ if ( IS_NPC( victim ) && dam > 0 ) { if ( ( victim->act.test(ACT_WIMPY) && number_bits( 1 ) == 0 && victim->hit < victim->max_hit / 2 ) || ( IS_AFFECTED( victim, AFF_CHARM ) && victim->master != NULL && victim->master->in_room != victim->in_room ) ) do_flee( victim, "" ); } if ( !IS_NPC( victim ) && victim->hit > 0 && victim->hit <= victim->wimpy && victim->wait == 0 ) do_flee( victim, "" ); return TRUE; }
void sp_dam_message( OBJ_DATA * obj, CHAR_DATA * ch, CHAR_DATA * victim, int dam, int realm, int dt ) { char buf1[MAX_STRING_LENGTH], buf2[MAX_STRING_LENGTH], buf3[MAX_STRING_LENGTH]; const char *attack; char punct; int rtype, dam_range; bool dead = FALSE; char symbuf[MSL]; char catsymbuf[MSL]; char outercol[MSL]; char innercol[MSL]; bool stress = FALSE; if ( dam >= victim->hit ) dead = TRUE; if ( sysdata.shownumbers == TRUE ) { snprintf( testerbuf, MSL, " @@l(@@W%i@@l)@@N", dam ); } else snprintf( testerbuf, MSL, "%s", "" ); for ( rtype = 0; rtype < MAX_REALM; rtype++ ) { if ( sp_dam_str[rtype].realm == realm ) break; } if ( rtype == MAX_REALM ) rtype = 0; /* notes: 2000+ stress color 1000+ normal color 0+ no backcolor 500+ stress verb 0+ normal verb each 50 is a symbol */ if ( dam > 2000 ) { dam_range = dam - 2000; } else if ( dam > 1000 ) { dam_range = dam - 1000; } else { dam_range = dam; } dam_range /= 2; if ( dam_range > 250 ) { stress = TRUE; dam_range -= 250; } punct = ( !stress ) ? '.' : '!'; snprintf( outercol, MSL, "%s%s", ( dam > 250 ? sp_dam_str[rtype].backcol : "" ), ( dam > 250 ? sp_dam_str[rtype].invertcol : sp_dam_str[rtype].basecol ) ); snprintf( innercol, MSL, "%s%s", ( dam > 250 ? sp_dam_str[rtype].backcol : "" ), ( dam > 500 ? sp_dam_str[rtype].stresscol : ( dam > 250 ? sp_dam_str[rtype].invertcol : sp_dam_str[rtype].basecol ) ) ); catsymbuf[0] = '\0'; snprintf( symbuf, MSL, "%s", " " ); for ( ; dam_range > 0; dam_range -= 50 ) { snprintf( catsymbuf, MSL, sp_dam_str[rtype].formatter, outercol, innercol, outercol ); strncat( symbuf, catsymbuf, MSL ); } strncat( symbuf, " ", MSL ); if ( dt >= 0 && dt < MAX_SKILL ) attack = skill_table[dt].noun_damage; else { bug( "Dam_message: bad dt %d.", dt ); rtype = 0; attack = "!!!!!"; } if ( obj == NULL ) { snprintf( buf1, MSL, "%s$n %s%s%s@@N $N %swith $s %s%c@@N%s", sp_dam_str[rtype].basecol, symbuf, ( stress ? sp_dam_str[rtype].vp_stress : sp_dam_str[rtype].vp ), symbuf, sp_dam_str[rtype].basecol, attack, punct, testerbuf ); snprintf( buf2, MSL, "%sYou %s%s%s@@N $N %swith your %s%c@@N%s", sp_dam_str[rtype].basecol, symbuf, ( stress ? sp_dam_str[rtype].vs_stress : sp_dam_str[rtype].vs ), symbuf, sp_dam_str[rtype].basecol, attack, punct, testerbuf ); snprintf( buf3, MSL, "%s$n %s%s%s %syou with $s %s%c@@N%s", sp_dam_str[rtype].basecol, symbuf, ( stress ? sp_dam_str[rtype].vp_stress : sp_dam_str[rtype].vp ), symbuf, sp_dam_str[rtype].basecol, attack, punct, testerbuf ); } else if ( obj != NULL ) { snprintf( buf1, MSL, "%s$p %s%s%s@@N $N %swith a %s%c@@N", sp_dam_str[rtype].basecol, symbuf, ( stress ? sp_dam_str[rtype].vp_stress : sp_dam_str[rtype].vp ), symbuf, sp_dam_str[rtype].basecol, attack, punct ); snprintf( buf3, MSL, "%s$p %s%s%s %syou with $s %s%c@@N", sp_dam_str[rtype].basecol, symbuf, ( stress ? sp_dam_str[rtype].vp_stress : sp_dam_str[rtype].vp ), symbuf, sp_dam_str[rtype].basecol, attack, punct ); } else { snprintf( log_buf, (2 * MIL), "%s", "Error in casting spell , sp_dam called with NULL obj and ch." ); monitor_chan( log_buf, MONITOR_DEBUG ); return; } if ( obj == NULL ) { act( buf1, ch, NULL, victim, TO_NOTVICT ); } else { act( buf1, NULL, ( void * )obj, victim, TO_NOTVICT ); } if ( ch->act.test(ACT_BLIND_PLAYER) ) { if ( dam < victim->max_hit / 30 ) act( "You glance $K", ch, NULL, victim, TO_CHAR ); else if ( dam < victim->max_hit / 20 ) act( "You hit $K", ch, NULL, victim, TO_CHAR ); else if ( dam < victim->max_hit / 10 ) act( "You nail $K", ch, NULL, victim, TO_CHAR ); else act( "You thwack $K", ch, NULL, victim, TO_CHAR ); } else if ( obj == NULL ) { act( buf2, ch, NULL, victim, TO_CHAR ); } if ( victim->act.test(ACT_BLIND_PLAYER) ) { if ( dam < victim->max_hit / 30 ) act( "$k glances you", ch, NULL, victim, TO_VICT ); else if ( dam < victim->max_hit / 20 ) act( "$k hits you", ch, NULL, victim, TO_VICT ); else if ( dam < victim->max_hit / 10 ) act( "$k nails you", ch, NULL, victim, TO_VICT ); else act( "$k thwacks you", ch, NULL, victim, TO_VICT ); } else if ( obj == NULL ) { act( buf3, ch, NULL, victim, TO_VICT ); } else { act( buf3, NULL, ( void * )obj, victim, TO_VICT ); } if ( dead ) { sp_death_message( ch, victim, realm ); } return; }
void do_logs( CHAR_DATA *ch, char *argument ) { char bug_buf[MSL], idea_buf[MSL], typo_buf[MSL], bugs_buf[MSL]; char *this_list; int i = 0; bool validcmd=FALSE; /* Empty the three buffers */ *bug_buf = '\0'; *idea_buf = '\0'; *typo_buf = '\0'; /* Populate the 3 lists */ for (i = 0; i < totLogs; i++) { if ( !str_cmp(log_table[i].type, "bug") ) this_list = bug_buf; else if ( !str_cmp(log_table[i].type, "idea") ) this_list = idea_buf; else if ( !str_cmp(log_table[i].type, "typo") ) this_list = typo_buf; else { sprintf(bugs_buf, "Log type not recognised (%s) at log line %d", log_table[i].type, i); monitor_chan( NULL, bugs_buf, MONITOR_DEBUG); return; } if( IS_IMMORTAL(ch)) { sprintf(this_list, "%s@@d[@@y%2d@@d]@@w @@r%-9s @@e%c%-4s @@a*%-6s @@W%-55s@@N\r\n", this_list, ( i + 1 ), log_table[i].reporter, UPPER(*log_table[i].type), log_table[i].type + 1, log_table[i].date, log_table[i].log ); } else { sprintf(this_list, "%s@@d[@@y%2d@@d]@@w @@e%c%-4s @@a*%-6s @@W%-55s@@N\r\n", this_list, ( i + 1 ), UPPER(*log_table[i].type), log_table[i].type + 1, log_table[i].date, log_table[i].log ); } } if ( !str_cmp(argument, "bug") || !str_cmp(argument, "all") ) { validcmd = TRUE; if (*bug_buf) { send_to_char("\r\n@@e------------------------@@d[@@WBug List@@d]@@N\r\n", ch); send_to_char(bug_buf, ch); } else send_to_char("\r\nNo bugs logged.\r\n", ch); } if ( !str_cmp(argument, "idea") || !str_cmp(argument, "all") ) { validcmd = TRUE; if (*idea_buf) { send_to_char("\r\n@@e-----------------------@@d[@@WIdea List@@d]@@N\r\n", ch); send_to_char(idea_buf, ch); } else send_to_char("\r\nNo ideas logged.\r\n", ch); } if ( !str_cmp(argument, "typo") || !str_cmp(argument, "all") ) { validcmd = TRUE; if (*typo_buf) { send_to_char("\r\n@@e-----------------------@@d[@@WTypo List@@d]@@N\r\n", ch); send_to_char(typo_buf, ch); } else send_to_char("\r\nNo typos logged.\r\n", ch); } if (!validcmd) { send_to_char( "Syntax: logs [bug/typo/idea/all]\r\nType 'log' if you want to log a bug, typo or idea.\r\n", ch); return; } }
void mob_group_follow( CHAR_DATA * ch, CHAR_DATA * target ) { char buf[MAX_STRING_LENGTH]; CHAR_DATA *vch; int num; if ( ( ch == NULL ) || ( target == NULL ) ) { snprintf( buf, MSL, "%s", "Null ch and/or target in mob_group_follow, exiting." ); monitor_chan( buf, MONITOR_MOB ); return; } snprintf( buf, MSL, "Ok guys, let's all follow %s.", target->get_name() ); do_say( ch, buf ); for ( vch = ch->in_room->first_person; vch != NULL; vch = vch->next_in_room ) { if ( ( ch != vch ) && ( AI_MOB( vch ) ) && ( is_same_group( ch, vch ) ) ) { if ( vch->position != POS_STANDING ) do_stand( vch, "" ); num = number_percent( ); // WAIT_STATE( vch, 275 ); if ( num > 85 ) do_say( vch, "Ok boss. Whatever you say." ); else if ( num > 70 ) do_say( vch, "Alright! More people, more power!" ); else if ( num > 55 ) do_say( vch, "Whoo Hooo!" ); else if ( num > 35 ) do_say( vch, "Sure thing." ); else if ( num > 29 ) { if ( num > 32 ) snprintf( buf, MSL, "Man I don't want to join %s's group!", target->get_name() ); else snprintf( buf, MSL, "I hate big groups." ); do_say( vch, buf ); do_follow( vch, const_cast<char *>(vch->name.c_str()) ); do_say( vch, "I'm outta here." ); do_recall( vch, "" ); continue; } if ( !can_see( vch, target ) ) { vch->master = target; vch->leader = NULL; } else { do_follow( vch, const_cast<char *>(target->name.c_str()) ); } do_group( target, "all" ); } } return; }
/* i have condensed this function to just three states: MOB_FIGHTING, * MOB_RESTING/ MOB_SLEEPING, and MOB_STANDING. each of these three states * will call it's appropriate function. */ void int_group_handler( NPC_GROUP_DATA * ngroup ) { CHAR_DATA *follower = NULL; CHAR_DATA *leader = ngroup->leader; DL_LIST *follower_ptr; // short followers_want = GRP_STATE_NO_CHANGE; short leader_wants = GRP_STATE_NO_CHANGE; short group_count = 1; // start with leader char monbuf[MSL]; if ( leader == NULL ) { monitor_chan( "No Leader in NPC_GROUP", MONITOR_MOB ); return; } // check for followers needs for ( follower_ptr = ngroup->first_follower; follower_ptr; follower_ptr = follower_ptr->next ) { // check for needing healing, levelling follower = (CHAR_DATA *)follower_ptr->this_one; group_count++; continue; } // check for leader's needs if ( leader->hit < leader->max_hit * 25 / 100 ) { leader_wants = GRP_STATE_CRIT_HEAL; } else if ( leader->mana < leader->max_mana * 25 / 100 ) { leader_wants = GRP_STATE_CRIT_MANA; } else if ( leader->hit < leader->max_hit * 60 / 100 ) { leader_wants = GRP_STATE_NORM_HEAL; } else if ( leader->mana < leader->max_mana * 50 / 100 ) { leader_wants = GRP_STATE_NORM_MANA; } else if ( able_to_level( leader ) ) { leader_wants = GRP_STATE_LEVELING; } snprintf( monbuf, MSL, "NPC Group Handler, Leader is %s, state is %s", ngroup->leader->name.c_str(), group_state_table[ngroup->state] ); monitor_chan( monbuf, MONITOR_MOB ); switch ( ngroup->state ) { case GRP_STATE_CRIT_HEAL: case GRP_STATE_CRIT_MANA: case GRP_STATE_NORM_HEAL: case GRP_STATE_NORM_MANA: { bool everyone_ready = TRUE; bool room_ready = FALSE; // ready_heal_room( leader ); if ( ( leader->mana < leader->max_mana * 85 / 100 ) || ( leader->hit < leader->max_hit * 85 / 100 ) ) { everyone_ready = FALSE; if ( ( ( room_ready = ready_heal_room( leader ) ) == TRUE ) || ( leader->mana < leader->max_mana * 20 / 100 ) ) { do_sleep( leader, "" ); } } else { do_stand( leader, "" ); } for ( follower_ptr = ngroup->first_follower; follower_ptr; follower_ptr = follower_ptr->next ) { follower = (CHAR_DATA *)follower_ptr->this_one; if ( ( follower->mana < follower->max_mana * 75 / 100 ) || ( follower->hit < follower->max_hit * 75 / 100 ) ) { everyone_ready = FALSE; do_sleep( follower, "" ); } else { do_stand( follower, "" ); } } if ( everyone_ready == TRUE ) { ngroup->state = GRP_STATE_IDLE; } break; } case GRP_STATE_FIGHT: { // violence_update will handle if ( ( leader_wants < GRP_STATE_HUNTING ) || ( leader->fighting == NULL ) ) { bool someone_still_fighting = FALSE; ngroup->state = GRP_STATE_FLEE; for ( follower_ptr = ngroup->first_follower; follower_ptr; follower_ptr = follower_ptr->next ) { follower = (CHAR_DATA *)follower_ptr->this_one; if ( follower->fighting != NULL ) { do_flee( follower, "" ); someone_still_fighting = TRUE; } } if ( someone_still_fighting == FALSE ) { ngroup->state = GRP_STATE_REFORM; } if ( leader->fighting != NULL ) { do_flee( leader, "" ); } } break; } case GRP_STATE_FLEE: { bool someone_still_fighting = FALSE; for ( follower_ptr = ngroup->first_follower; follower_ptr; follower_ptr = follower_ptr->next ) { follower = (CHAR_DATA *)follower_ptr->this_one; if ( follower->fighting != NULL ) { do_flee( follower, "" ); someone_still_fighting = TRUE; } } if ( leader->fighting != NULL ) { do_flee( leader, "" ); someone_still_fighting = TRUE; } if ( someone_still_fighting == FALSE ) { ngroup->state = GRP_STATE_REFORM; } break; } case GRP_STATE_IDLE: { // check_re_equip( leader ); // check_rewield( leader ); if ( leader_wants < GRP_STATE_NO_CHANGE ) { ngroup->state = leader_wants; break; } else if ( number_percent( ) < 40 ) { select_target( ngroup->leader ); ngroup->state = GRP_STATE_HUNTING; break; } } case GRP_STATE_HUNTING: { // poll followers later short move_dir; if ( leader->fighting != NULL ) { ngroup->state = GRP_STATE_FIGHT; break; } if ( leader->hunting == NULL ) { // snprintf( monbuf, MSL, "Leader %s not hunting anything in GRP_STATE_HUNTING", // leader->name ); // monitor_chan( monbuf, MONITOR_MOB ); select_target( ngroup->leader ); break; } if ( leader->in_room == leader->hunting->in_room ) { ngroup->state = GRP_STATE_FIGHT; one_hit( leader, leader->hunting, TYPE_UNDEFINED ); break; } move_dir = h_find_dir( leader->in_room, leader->hunting->in_room, HUNT_WORLD | HUNT_OPENDOOR | HUNT_UNLOCKDOOR | HUNT_PICKDOOR ); if ( move_dir < 0 ) // can't get there from here { ngroup->state = GRP_STATE_LOST; break; } hunt_move( leader, move_dir ); break; } case GRP_STATE_LEVELING: { char_from_room( leader ); char_to_room( leader, get_room_index( 3758 ) ); if ( able_to_level( leader ) ) { gain_level( leader ); } for ( follower_ptr = ngroup->first_follower; follower_ptr; follower_ptr = follower_ptr->next ) { follower = (CHAR_DATA *)follower_ptr->this_one; if ( able_to_level( follower ) ) { gain_level( follower ); } } ngroup->state = GRP_STATE_IDLE; break; } case GRP_STATE_REFORM: { bool all_are_here = TRUE; for ( follower_ptr = ngroup->first_follower; follower_ptr; follower_ptr = follower_ptr->next ) { follower = (CHAR_DATA *)follower_ptr->this_one; if ( follower->in_room != leader->in_room ) { short move_dir; all_are_here = FALSE; move_dir = h_find_dir( follower->in_room, leader->in_room, HUNT_WORLD | HUNT_OPENDOOR | HUNT_UNLOCKDOOR | HUNT_PICKDOOR ); if ( move_dir < 0 ) // can't get there from here { ngroup->state = GRP_STATE_LOST; break; } hunt_move( follower, move_dir ); } } if ( all_are_here == TRUE ) { ngroup->state = GRP_STATE_IDLE; } break; } } }
char * str_mod( char * mod_string, char *argument ) { char arg1 [ MAX_INPUT_LENGTH ]; char buf [ MAX_STRING_LENGTH ]; char *buf2; char *buf3 = NULL; char *word; char temp[MSL]; int i = 0; bool multiple = FALSE; if ( !str_cmp( argument, "" ) ) { sprintf( bug_buf, "Unknown reason for return, argument is -%s-", argument ); monitor_chan( NULL, bug_buf, MONITOR_DEBUG ); return mod_string; } if ( argument[0] == '+' || argument[0] == '-' ) { buf[0] = '\0'; smash_tilde( argument ); if ( argument[0] == '+' ) { argument++; if ( mod_string ) safe_strcat( MSL, buf, mod_string ); while ( isspace( *argument ) ) argument++; if ( !str_infix( argument, mod_string ) ) { return mod_string; } safe_strcat( MSL, buf, argument ); safe_strcat( MSL, buf, " " ); } if ( argument[0] == '-' ) { argument++; if ( argument[0] == '\'' ) multiple = TRUE; one_argument( argument, arg1 ); if ( multiple ) { sprintf( temp, "\'%s\'", arg1 ); sprintf( arg1, "%s", temp ); } if ( arg1 ) { buf2 = str_dup( mod_string ); buf3 = buf2; if ( (word = strstr( buf2, arg1 ) ) == NULL ) { free_string( buf2 ); return mod_string; } else { while ( buf2 != word ) buf[i++] = *(buf2++); while ( ( !isspace ( *(buf2++) ) ) || ( ( multiple ) && ( ( buf2[0] != '\'' ) && ( buf2[0] != '\0' ) ) ) ); buf[i] = '\0'; safe_strcat ( MSL, buf, buf2 ); } } } free_string( buf3 ); word = buf2 = buf3 = NULL; free_string( mod_string ); mod_string = str_dup( buf ); } return mod_string; }
short char_data::get_level( const char *what ) { short i = 0, max = 0;; if ( what == '\0' ) return level; if ( !str_prefix(what, "maxmortal") ) { for ( i = 0; i < MAX_CLASS; i++ ) if ( lvl[i] > max ) max = lvl[i]; return max; } if ( !str_prefix(what, "maxremortal") ) { for ( i = 0; i < MAX_CLASS; i++ ) if ( lvl2[i] > max ) max = lvl2[i]; return max; } if ( !str_prefix(what, "mortal") ) return (lvl[CLS_MAG] + lvl[CLS_CLE] + lvl[CLS_THI] + lvl[CLS_WAR] + lvl[CLS_PSI]); if ( !str_prefix(what, "remortal") ) return (lvl2[CLS_SOR] + lvl2[CLS_MON] + lvl2[CLS_ASS] + lvl2[CLS_KNI] + lvl2[CLS_NEC]); if ( !str_prefix(what, "psuedo") ) { if ( IS_NPC(this) ) return get_level(); else { if ( (get_level("remortal") / 4) > 0 ) return (get_level() + (get_level("remortal") / 4)); else return get_level(); } } if ( !str_prefix(what, "adept") ) return IS_NPC(this) ? get_level() / 7 : pcdata->adept_level; if ( !str_prefix(what, "mage") ) return lvl[CLS_MAG]; if ( !str_prefix(what, "cleric") ) return lvl[CLS_CLE]; if ( !str_prefix(what, "thief") ) return lvl[CLS_THI]; if ( !str_prefix(what, "warrior") ) return lvl[CLS_WAR]; if ( !str_prefix(what, "psionicist") ) return lvl[CLS_PSI]; if ( !str_prefix(what, "sorcerer") ) return lvl2[CLS_SOR]; if ( !str_prefix(what, "monk") ) return lvl2[CLS_MON]; if ( !str_prefix(what, "assassin") ) return lvl2[CLS_ASS]; if ( !str_prefix(what, "knight") ) return lvl2[CLS_KNI]; if ( !str_prefix(what, "necromancer") ) return lvl2[CLS_NEC]; snprintf(log_buf, (2 * MIL), "char_data::get_level(): Received invalid request for '%s'.", what); monitor_chan(log_buf, MONITOR_DEBUG); return level; }