The Dawn Of Time
The Official Forums for the Dawn Of Time Mud Codebase
 
Log in Register FAQ Memberlist Search The Dawn Of Time Forum Index Goto the Official Dawn Website

Short self command for mortals

 
Post new topic   Reply to topic    The Dawn Of Time Forum Index » Configuration/Online Editing
View previous topic :: View next topic  
Author Message
Atrayeus



Joined: 28 Jan 2007
Posts: 6

PostPosted: Mon Jan 29, 2007 12:40 pm    Post subject: Short self command for mortals Reply with quote

I am new to coding, so go easy on me.

I have found that the "Short" command only works for Immortals, i have went through trying to figure out how to make this command work for mortals. so i set the comedit down to 1, but this gave mortals the ability to change their own and everyone under their level. So i had to change it back.

I need a quick help, or a push in the right direction. Can i create a command with out trying to hard code it in? I have a feeling i wont be able to, but like a stated I am new to coding, so an example would be nice, if possible. Thank you in advance for any help offered.


Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger
Sliver



Joined: 13 Jan 2007
Posts: 30
Location: Oklahoma, U.S.A.

PostPosted: Mon Jan 29, 2007 4:37 pm    Post subject: RE: Short command for mortals. Reply with quote

The best place to start, to implement something like that which you are requesting would be to read the code pertaining to "void do_short" located in the file "act_wiz.cpp".

Everything you need to add such is already there, just pretty much change the name of the command to something such as "pshort" and add in the proper lines to interp.cpp and interp.h

Also, you'll have to change the arguments so that it only calls for the new short being requested, instead of looking for an argument that calls for a player name and a second argument asking for the new short.

Hope this helps some.

- Sliver



_________________
C.L.o.W.
Host: bacchus.brotay.net
Port: 5300
Back to top
View user's profile Send private message AIM Address Yahoo Messenger
Atrayeus



Joined: 28 Jan 2007
Posts: 6

PostPosted: Mon Jan 29, 2007 4:47 pm    Post subject: Reply with quote

Wow... you lost me sorta, I'll go in there and look though thanks, like i said I'm new to coding. but i'll understand a bit better if you went a bit slower. Thank you though.


Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger
Alturin



Joined: 03 Dec 2004
Posts: 138

PostPosted: Tue Jan 30, 2007 1:55 am    Post subject: Reply with quote

The most neat solution, would be to check out interp.cpp.
There you will find a line like this
Code:
 { "short",         do_short,         POS_DEAD,      L7,   LOG_ALWAYS,      1 },


The meaning of this line is "when the command 'short' is input, run the function 'do_short(char_data* ch, char* argument)', the character has to be at least in POS_DEAD to do this, and their level has to be at least 'L7'.
(Which is defined as '#define L7 MAX_LEVEL - 7 // angel')

In other words, only imms of level 93 and above can do it.

What you're wanting to do, is write something similar to do_short, which works for players only.
The "goody" part would be, to make it so that if you're an immortal >93, the do_short would be run, and if you're a player, your newly written function (let's call it 'do_pshort', why not) is run.

If you're still with me, you could do this like thus. Add a line -below- the do_short one (this is crucial, otherwise the do_pshort will always be executed). It doesn't matter much how far below, as long as it's within the table. For ease, I suggest just placing it directly below.

This would lead to the following code:
Code:
   { "short",          do_short,           POS_DEAD,       L7, LOG_ALWAYS,     1 },
   { "short",          do_pshort,          POS_DEAD,       0,  LOG_ALWAYS,     1 },


Now, in order for this to even compile, you will need to open up interp.h, and add
Code:
DECLARE_DO_FUN( do_pshort );

to the file, preferably down at the bottom.

If you hit compile now, interp.cpp will compile just fine, but when you hit build, you'll get an error about do_pshort not being defined. Which makes sense, since you still have to write it!

Open up some .cpp file you feel should contain your command, I suggest act_com.cpp, and add something like this:
Code:

/**************************************************************************/
/// Shameless hack of do_short
void do_pshort( char_data *ch, char *argument)
{
   if(IS_NULLSTR(argument)){
      ch->println("Syntax: short <your short description>");
      ch->println("This command is used to set short descriptions.");
      return;
   }

    // make sure first char is lowercase, if the short description isn't the name
    /** Alturin sais: You can leave this out if you don't want the decapitalisation to happen */
   if(str_cmp(argument, ch->name)){
      argument[0] = LOWER(argument[0]);
   }
   /** Till here */

    /** Alturin sais: If you don't want this message to apear, delete this bit. */
    if (str_len(argument)>55)
    {
        /** If you don't want to allow this, uncomment this block */
        // ch->println("Short too long, not set!");
        // return;
        /** Till here */

        ch->wrapln( "That short descriptions is LONG... it has been set anyway..."
            "but consider the length when setting a short." );
    }
    /** Till here */

    // questing wiznet
    /** Alturin sais: If you don't want it to appear on wiznet, remove this part */
    if (TRUE_CH(ch))
    {
        char qbuf[MSL];
        sprintf (qbuf, "`mQUEST> %s short %s`x\r\n",
            TRUE_CH(ch)->name, argument);
        wiznet(qbuf,ch,NULL,WIZ_QUESTING,0,LEVEL_IMMORTAL);
    }
    /** Till here */

    // inform them and the room they are in
    ch->wraplnf("You have changed your short description from '%s' to '%s'.",
        ch->short_descr, argument);

    act( "$n is now known as '$T'", ch, NULL, argument, TO_ROOM );

    // change the short
    replace_string(ch->short_descr, argument);

    save_char_obj( ch );
   return;
}


It compiles and builds, I give no guarantee that it won't crash your mud or eat all the cookies in your house Razz.



_________________
Sverre Rabbelier
Back to top
View user's profile Send private message
Atrayeus



Joined: 28 Jan 2007
Posts: 6

PostPosted: Tue Jan 30, 2007 6:44 am    Post subject: Reply with quote

Thank you, your alot of help.


Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger
Daos



Joined: 29 Jan 2003
Posts: 1224
Location: United States

PostPosted: Tue Jan 30, 2007 8:07 am    Post subject: Reply with quote

Hi -

This is a quick suggestion - I think a more efficient and quick way to handle your inquiry would be to add a condition to do_short() which checks for the use of the "self" argument:

Code:
if (str_cmp(arg, "self") && !IS_IMMORTAL(ch)){
   ch->printlnf("Only immortals can change other people's short descriptions.");
   ch->printlnf("Type `#`Yshort self <your short>`^ to set your own short description.");
   return;
}


Feel free to add additional code to clean it up.



_________________
- Daos

http://www.dawnoftime.org
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Atrayeus



Joined: 28 Jan 2007
Posts: 6

PostPosted: Tue Jan 30, 2007 5:22 pm    Post subject: Reply with quote

Okay to me both seem to look just fine, i tried both to see. but neither is working. I think it is a compiling error. i am running cygwin. and when ever i try to compile it halts at connection.cpp.

When i tested. i first kept short at level 93 test character can't use it, and then i set it to 1 so that mortals can use it, I am still getting the issue of them having the ability to change others shorts. Is there something i must do after i save this argument? Or am I just that bad with this... >.<


Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger
Alturin



Joined: 03 Dec 2004
Posts: 138

PostPosted: Tue Jan 30, 2007 11:25 pm    Post subject: Reply with quote

It would help if you told us exactly what errors it's giving you.
Just copy / paste the compiler's output in a
Code:
[code]
output here
[/code]


block.



_________________
Sverre Rabbelier
Back to top
View user's profile Send private message
Daos



Joined: 29 Jan 2003
Posts: 1224
Location: United States

PostPosted: Wed Jan 31, 2007 6:53 am    Post subject: Reply with quote

Hi -

If it halts at connection.cpp - I would assume that you have IPV6 enabled in your config.h file. If this is the case, IPV6 is not entirely supported with dawn on cygwin platforms. Go into config.h - comment out IPV6_SUPPORT_ENABLED which is near the bottom of the header file. Do a full compile and see if that helps.



_________________
- Daos

http://www.dawnoftime.org
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Atrayeus



Joined: 28 Jan 2007
Posts: 6

PostPosted: Wed Jan 31, 2007 11:07 am    Post subject: Reply with quote

Thanks alot, the compile works now, but now i find that the only argument you can add is self, changing your short to that so would it be right to make instead of argument being "self" maybe the target to be "self"? and how would this be coded correctly.

like this?

Code:
if (str_cmp(victim, "self") && !IS_IMMORTAL(ch))


sorry for all the trouble.

Also what would you suggest for reading material to learn the coding, I feel quite, unintelligent at times whn i look at the coding, I understand some, but i would like more.


Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger
Alturin



Joined: 03 Dec 2004
Posts: 138

PostPosted: Wed Jan 31, 2007 12:09 pm    Post subject: Reply with quote

That's strange, are you using the original do_short()?
Also, you should add Daos' fix -below-

Code:
argument = one_argument( argument, arg );



_________________
Sverre Rabbelier
Back to top
View user's profile Send private message
Atrayeus



Joined: 28 Jan 2007
Posts: 6

PostPosted: Wed Jan 31, 2007 12:15 pm    Post subject: Reply with quote

yes using right from download. And the correction seems liek it is already in there. maybe i just put the code in it wrong, here is the code...

Code:
void do_short( char_data *ch, char *argument)
{
   char_data *victim;
   char arg[MIL];
   char oarg[MSL];

   sprintf( oarg,"%s", argument);
   
   argument = one_argument( argument, arg );
   
   if(IS_NULLSTR(arg)){
      ch->println("Syntax: short <playername> a short description for the player");
      ch->println("This command is used to set short descriptions.");
      return;
   }

     // Player use of "short" Command
     if (str_cmp(arg, "self") && !IS_IMMORTAL(ch)){
                ch->printlnf("Only immortals can change other people's short descriptions.");
                ch->printlnf("Type `#`Yshort self <your short>`^ to set your own short description.");
                return;
        }
   
   if(str_len(arg)<3){
      ch->println("You must use more than 2 characters to specify players name.");
      return;
   }

    if ( ( victim = get_whovis_player_world( ch, arg ) ) == NULL )
    {
      if ( ( victim = get_char_world( ch, arg ) ) == NULL )
      {
         ch->println("They aren't here.");
         return;
      }
   }

    // trim the spaces to the right of the short
    while ( !IS_NULLSTR(argument) && is_space(argument[str_len(argument)-1]))
    {
        argument[str_len(argument)-1]='\0';
    }

    // check we have a short left
    if(IS_NULLSTR(argument)){
        ch->println("You must put in a short description.");
        return;
   }

    // make sure first char is lowercase, if the short description isn't the name
   if(str_cmp(argument, victim->name)){
      argument[0] = LOWER(argument[0]);
   }

    if ((get_trust(victim)>= get_trust(ch))&& (ch != victim))
        ch->println("You can't set a short of someone a higher level or equal to you.");
    else
    {
      // questing wiznet
      if (TRUE_CH(ch))
      {
         char qbuf[MSL];
         sprintf (qbuf, "`mQUEST> %s short %s`x\r\n",
            TRUE_CH(ch)->name, oarg);
         wiznet(qbuf,ch,NULL,WIZ_QUESTING,0,LEVEL_IMMORTAL);
      }



        // inform the imm and the room victim is in
        ch->wraplnf("You have changed %s's short description from '%s' to '%s'.",
         victim->name, victim->short_descr, argument);

        act( "$n is now known as '$T'", victim, NULL, argument, TO_ROOM );

        // change the short
        replace_string(victim->short_descr, argument);
      
        victim->wraplnf("Your short description has been changed to '%s' by %s.",
         victim->short_descr, can_see_who(victim, ch)?ch->name:"a mystery imm");

        if (str_len(argument)>55){
         ch->wrapln( "That short descriptions is LONG... it has been set anyway..."
            "but consider the length when setting a short." );
      }
    }

    save_char_obj( victim );
   return;
}


Back to top
View user's profile Send private message Send e-mail AIM Address Yahoo Messenger
Daos



Joined: 29 Jan 2003
Posts: 1224
Location: United States

PostPosted: Tue Feb 06, 2007 8:04 am    Post subject: Reply with quote

Hi -

At the time I posted the suggested fix, I wasn't looking at any code. Now that I have looked at do_short(), my new suggested modification is this:

Change:

Code:
if ((get_trust(victim)>= get_trust(ch))&& (ch != victim))
        ch->println("You can't set a short of someone a higher level or equal to you.");


To:

Code:
if (!IS_IMMORTAL(ch) && (ch != victim)
   || (get_trust(victim)>= get_trust(ch))){
    ch->printlnf("Unable to modify %s's short description.", victim->name);


That will basically check to see if the player using the short command is an immortal and if they are their own target with the additional trust condition code included in the if check. My original suggestion, you can omit from your code. Let me know how that works for you.



_________________
- Daos

http://www.dawnoftime.org
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    The Dawn Of Time Forum Index » Configuration/Online Editing All times are GMT + 13 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001-2005 phpBB Group
Theme created by Vjacheslav Trushkin