nskills.c

skylib_mudos_v1/mudlib/cmds/lord/nskills.c · 2.9 KB

From the archive skylib_mudos_v1.tar.gz

Download the archive   « Back to the archive contents

#include <skills.h>

inherit COMMAND_BASE;

int new_skill_value(int sk) {
    float f = 1000.0;
    float k = 0.3;

    if( sk == 0 )
        return 0;

    return to_int(f * log( 1.0 + sk/(f + sk * k) ) + 0.5);

} /* new_skill_value() */

string rec_list( mixed *args, string path, int all, int lvl,
                 int only_leaf, object pl ) {
   int i, sk, o_l;
   string str, tp, tmp;

   str = "";
   for ( i = 0 ; i < sizeof( args ) ; i += SKILL_ARR_SIZE ) {
      o_l = 0;
      tp = path +"."+ args[ i ];
      sk = (int)pl->query_skill( tp );
      if(tp[0..14] != ".general.language" && tp[0..13] != "general.language") {
        sk = new_skill_value(sk);
      }

      reset_eval_cost();
      if (lvl == 1 && SKILL_OB->query_only_leaf(tp))
        o_l = 1;
      if (!(only_leaf || o_l) || (!sizeof(args[i+SKILL_BIT]) &&
                                  (sk > 0 || all)))
        str += sprintf( "%*'| 's%*'.'-s %4d %4d\n", ( lvl-1 ) * 2, "",
              20 - ( ( lvl - 1 ) * 2 ), args[ i ], sk,
              (int)new_skill_value(pl->query_skill_bonus( tp )) );
      if ( sizeof( args[ i + SKILL_BIT ] ) && ( only_leaf || o_l || all 
                                                || ( sk > 5 * lvl ) ) ) {
         tmp = rec_list( args[ i + SKILL_BIT ], path +"."+ args[i],
                         all, lvl + 1, only_leaf || o_l, pl );
         if ((only_leaf || o_l) && (tmp != "" || (!all && lvl == 1)))
           str += sprintf( "%*'| 's%*'.'-s    -    -\n", ( lvl-1 ) * 2, "",
                           20 - ( ( lvl - 1 ) * 2 ), args[ i ]) + tmp;
         else
           str += tmp;
      }
   }
   return str;
} /* rec_list() */

int cmd( object *players, string word ) {
   int i, cols;
   string result, *bits;
   object pl;
   mixed *args;

   // Only do the first player.
   pl = players[0];
   result = "";
   bits = ({ });
   cols = (int)TP->query_cols();

   if( word ) {
       args = (mixed *)SKILL_OB->query_skills();
       if( ( i = member_array( word, args ) ) == -1 )
           return notify_fail( "Usage: "+ query_verb() +" <skill>\n");
       args = args[ i + SKILL_BIT ];
       result = sprintf("%'='*-s\n", cols, "=======SKILLS=======Level/Bonus")+
                sprintf("%#*-s\n", cols, rec_list(args, word, 1, 1, 0, pl ) );
       TP->more_string( result, "Skills" );
       return 1;
   }

   TCRE("sandoz", sprintf("Players : %O", players ) );

   args = (mixed *)SKILL_OB->query_skills();
   result += sprintf( "%'='*-s\n", cols, "=======SKILLS=======Level/Bonus");
   result += sprintf( "%#*-s\n", cols, rec_list( args, "",
       ( member_array( "all", bits ) != -1 ), 1, 0, pl ) );
   result += "New guild level: "+STD_GUILD_OBJ->query_new_level(pl)+"\n";

   TP->more_string( result, "Skills" );
   return 1;

} /* cmd() */

mixed query_patterns() {
  return ({ "<indirect:any-living> <string>", (: cmd( $1, $4[1] ) :),
            "<indirect:any-living>", (: cmd( $1, 0 ) :) });
} /* query_pattern() */

Site Stats

Snippets: 1791
Codebases: 571