forget.c

skylib_mudos_v1/mudlib/cmds/guild-race/magic/forget.c · 2.0 KB

From the archive skylib_mudos_v1.tar.gz

Download the archive   « Back to the archive contents

#define REMEMBER_EFFECT "magic.mentalism.remembered.locations"

inherit COMMAND_BASE;

int cmd( string words ) {
   mapping spells;
   int position;
   int enum;

   if ( !words || ( words == "" ) )
      return notify_fail( "Forget what?\n" );
   spells = (mapping)this_player()->query_spells();
   if(sscanf(words, "%d", position) == 1 || 
      sscanf(words, "location %d", position) == 1) {
      if(sizeof(TP->effects_matching(REMEMBER_EFFECT)) > 0) {
         enum = TP->effects_matching(REMEMBER_EFFECT)[0];
         if(position > sizeof(TP->arg_of(enum))|| position < 1) {
           return notify_fail("You do not know a location by that number!\n");
         }
         TP->set_arg_of(enum,
           delete(TP->arg_of(enum), ((position*2)-2), 2));
         if(sizeof(TP->arg_of(enum)) > 0) {
            tell_object(TP, "You forget that location!\n");
         }
         else {
            TP->delete_effect(enum);
         }
         return 1;
      }
   }
   if ( !spells[ words ] )
      return notify_fail( "You do not know \""+ words +"\".\n" );
   if ( !catch( spells[ words ][ 0 ]->force_load() ) )
      if ( !spells[ words ][ 0 ]->query_magic_spell() )
         return notify_fail( "You can only forget magic spells.\n" );
   this_player()->remove_spell( words );
   write( "You forget "+ words +".\n" );
   say( (string)this_player()->one_short() +
         " concentrates for a moment.\n" );
   return 1;
} /* cmd() */

int teach( object thing ) {
   thing->add_known_command( "forget" );
   return 1;
} /* teach() */

string help() {
   return "Syntax: forget <spell>\nforget [location] <number>\n"
         "This command allows you to forget magic spells that you no "
         "longer wish to know.\nIt also allows you to forget locations "
         "that you are remembering.\n\n"
         "Example:\n\n"
         "> forget Ethereal Light\n"
         "You forget Ethereal Light.\n"
         "> forget location 1\n"
         "You forget the location you were remembering!\n\n"
         "See also:\n"
         "  remember\n";
} /* help() */

Site Stats

Snippets: 1791
Codebases: 571