I'm running SWR v1.0, and I added the command pinfo (stands for player information). I added the necessary lines in tables.c under the correct case things
case 'p':
if ( !str_cmp( name, "do_pager" )) return do_pager;
if ( !str_cmp( name, "do_pardon" )) return do_pardon;
if ( !str_cmp( name, "do_password" )) return do_password;
if ( !str_cmp( name, "do_peace" )) return do_peace;
if ( !str_cmp( name, "do_pick" )) return do_pick;
if ( !str_cmp( name, "do_pickshiplock" )) return do_pickshiplock;
if ( !str_cmp( name, "do_pinfo" )) return do_pinfo;
and
if ( skill == do_owhere ) return "do_owhere";
if ( skill == do_pager ) return "do_pager";
if ( skill == do_pardon ) return "do_pardon";
if ( skill == do_password ) return "do_password";
if ( skill == do_peace ) return "do_peace";
if ( skill == do_pick ) return "do_pick";
if ( skill == do_pinfo ) return "do_pinfo";
I added the thing to command.dat
#COMMAND
Name pinfo~
Code do_pinfo
Position 0
Level 0
Log 0
End
Right now, it shows up if I type 'commands', it shows up. If I type 'pinfo', however, it says 'Huh?'. If I type cmdtable, it shows up and it counts the number of times I have typed 'pinfo'. Any help/suggestions?
What you have described works with normal SMAUG - I just tried it. You have a minor bug that I don't think would cause your problem, you should really have a %s in the line:
If you add the command to commands.dat it should be before the final #END line, however if it shows up in pinfo that should be correct.
Unless the SWR command parser is different from the normal one it doesn't seem possible for it to count the command without going past the part that says "Huh".
However having said that there seem to be around 113 places where it sends the string "Huh?" - a brute-force approach would be to edit each of those and change them slightly (eg. Huh (1)) in case it is failing some other test that isn't obvious.
A fairly neat way of doing that would be to simply replace each call which does:
send_to_char ("Huh?\n\r", ch);
with a macro (HUH) that expands out to:
#define HUH \
ch_printf (ch, "Huh? At line %i of file %s\n\r", \
__LINE__, __FILE__)
Then when you have it debugged just change the macro back to remove the debugging stuff.
If this doesn't work, use a program like UltraEdit that has a "replace in multiple files" function.
There are a couple of variants of the Huh? line (extra space here and there). The perl line above should catch all of them, except about four, which look different:
bash-2.05a$ grep Huh *.c
act_comm.c: ch_printf(ch, "Huh?\n\r");
act_wiz.c: ch_printf(ch, "Huh?\n\r");
boards.c: send_to_char( "Huh? Type 'help note' for usage.\n\r", ch );
boards.c: send_to_char( "Huh? Type 'help note' for usage.\n\r", ch );
comments.c: send_to_char( "Huh? Type 'help comment' for usage (i hope!).\n\r", ch );
Fix those up manually (you can ignore the last two because they look different anyway).
Once you have done that, do a make and it should work. Try connecting and typing some nonsense ...
I've done a lot of editing with SWR 1.0 and you did everything right. The only thing I saw that wasn't done is the function needs the return on it. Make it look like this:
I'm not completely sure this would influence anything, but all commands return, to note when the do loop/function has ended. Anyways, if thats whats holding it up then yay. Otherwise, make sure your did a make(complied) and reboot the mud. Not sure what else to say.
Well it turns out I did everything right except for one thing. I'm too used to smaug's exe compiling into the correct folder. However, the version of SWR I have outputs the make file to the src directory, but it needs to be in the src directory to function properly. That said, I was wondering if there was something I could change in order to have it create the executable in the area folder automatically. Makefile is below.
CC = gcc
PROF =
NOCRYPT = -DNOCRYPT
#Uncomment the next line if you want request support
#DBUGFLG = -DREQUESTS
C_FLAGS = -g3 -Wall $(PROF) $(NOCRYPT) $(DBUGFLG)
L_FLAGS = $(PROF)
Thanks to Nick Gammon (or how should I refer to you?), I got the executable to output into the area folder. Now, I have yet another question, but this time it concerns the actual pinfo function. Right now, I have:
//Command for getting player info
void do_pinfo(CHAR_DATA * ch, char *argument)
{
CHAR_DATA *victim;
if (IS_NPC(ch))
{
ch_printf(ch, "\n\r NPC's don't have Player Infos\n\r");
return;
}
set_char_color(AT_SCORE, ch);
send_to_char("+--------------------------------------------------------------------------+\n\r", ch);
ch_printf(ch,"|Name: %s |\n\r", victim->name );
/*ch_printf(ch,"|Gender: %s |\n\r", victim->sex );
ch_printf(ch,"|Age: %s |\n\r", get_age(victim) );
ch_printf(ch,"|Align: %s |\n\r", victim->alignment );
send_to_char("+--------------------------------------------------------------------------+\n\r", ch);
*/// ch_printf(ch,"|Personality: %s |\n\r", victim->personality );
// send_to_char("+--------------------------------------------------------------------------+\n\r", ch);
/* ch_printf(ch,"|History: %s |\n\r", victim->history );
send_to_char("+--------------------------------------------------------------------------+\n\r", ch);
ch_printf(ch,"|Position: ");
switch (ch->position)
{
case POS_DEAD:
ch_printf(ch, "%s is slowly decomposing. |", victim->name );
break;
case POS_MORTAL:
ch_printf(ch,"%s is mortally wounded. |", victim->name );
break;
case POS_INCAP:
ch_printf(ch,"%s is incapacitated. |", victim->name );
break;
case POS_STUNNED:
ch_printf(ch,"%s is stunned. |", victim->name );
break;
case POS_SLEEPING:
ch_printf(ch,"%s is sleeping. |", victim->name );
break;
case POS_RESTING:
ch_printf(ch,"%s is resting. |", victim->name );
break;
case POS_STANDING:
ch_printf(ch,"%s is standing. |", victim->name );
break;
case POS_FIGHTING:
ch_printf(ch,"%s is fighting. |", victim->name );
break;
case POS_MOUNTED:
ch_printf(ch,"%s is fighting. |", victim->name );
break;
case POS_SITTING:
ch_printf(ch,"%s is sitting. |", victim->name );
break;
}*/
send_to_char("+--------------------------------------------------------------------------+\n\r", ch);
send_to_char("\n\r", ch);
return;
}
If you notice, there's quite a bit commented out. I was trying to find what was wrong with it, and apparently the flaw is when the function first makes a reference to the "victim"'s name variable. If I run the swr file and type in "pinfo," the MUD crashes and says something about transferring data to swr.exe.stackdump. That file's contents after the crash are as follows:
Here's the problem. You have CHAR_DATA *victim; declared, but you're not setting 'victim' to anything before using it. So, when the mud makes an attempt to access that variable, there's nothing to access, which is a bad thing and the mud crashes. As good as computers are, they're not very skilled at reading your mind or making assumptions, and are quite picky.
I would assume that you want 'pinfo' to display info on the char that is typing the command. If that's the case, everywhere you have 'victim' replace it with 'char', and recompile. You should be good to go.
Another faster fix, would be to change:
'CHAR_DATA *victim;' to 'CHAR_DATA *victim = ch;'
I would reccommend the first however, as then you're just wasting memory.
Actually, I want it to be a command where the victim is another player. Meaning you type say... 'pinfo bob' (without quotes) where bob is the name of the player you want the info about.
If that's the case, then you need to set the 'victim' to *something*. A decent function to use would be get_char_world() or get_char_room() This returns a CHAR_DATA variable based on the argument you give it. It'll return NULL if a char wasn't found.
Adding this somewhere BEFORE you use victim should do teh trick.
if( (victim = get_char_world(ch, argument)) == NULL)
{
send_to_char("No such player online.\n\r", ch);
return;
}
Thanks Boborak, your addition made the command work. I have another question for this command regarding formatting, however. If you notice, the print has something like:
|Name: %s [a certain number of spaces] |
However, the location of the last | varies depending on how long the name (or whatever variable) is. Is there a way to fix this? And while I'm on that topic, I have the history data which is basically like a description. It's entered in the same way too. Is there a way to make a box which expands according to the length of that data (like the number of lines and such)?
Another question. I finished adding the history by itself, and that worked. Now I added yet another char field called 'personality'. I uncommented/commented each addition in and out, and I found that the problem was located at clear_char function in db.c
I basically took the history char field (which works if I take out the personality field), and copied each line and put it in the correct spot. On save.c, I did make sure to put it under the case 'P': as well. If I include this, the compilation is clean, but upon booting up the server, I receive another dumping stack trace like the access violation error posted above.
The deleting/remaking of the files seemed to dispose of the crash. However, I'm still faced with the problem of the formatting. Basically, It'd work if I could find out how many lines there were in the history (which is created the same way a desc is. Any help?
Now I'm pretty new at coding (March of this year) but I do know that the -x in between the % and the s forces it out 20 spaces. I think if you do a normal number inside, something like %20s it'll line up the word(s) to the left instead of the right hand side of the column. And negative numbers produce the opposite. But I've never used em as a positive so without testing I can't really be sure. Hope this helps somewhat...
Greyson
Legacy of the Sith
lots.wolfpaw.net 3000
http://www.swreality.org
The line formatting from Greyson worked for the Name, Gender, Age, and Align. However, it did not work for the history, which is a text buffer thing (I copied it from the code for description). Any suggestions for the formatting there?
Edit: Also, I want to remove the wanted for murder flag when someone is killed in a battle with the spaceships. Only the spaceships. Normal killing still has murder flag, any tips here?
Unfortunately, there is no handy dandy trick-of-the-trade to format the output of strings created by the editor. It relys on the user to format it the way they want it.
As for the wanted flag, a quick fix would be to search the destroy_ship function for refrences to raw_kill and change any refrence that looks like this:
raw_kill(ch, rch);
to this:
raw_kill(rch, rch);
This causes the function raw_kill to think the player killed themselves, and hence won't give anyone a 'wanted' flag.
This of course assumes you have stock SWR and haven't downloaded one of a variety of other compilations of SWR that may or may not have changed the destroy_ship functionality.
A little question not exactly related to the coding part. More like building. How do the new starsystems work? Is it easier to manually code the new "space" in, and if so, how would I go about doing this?
Edit: Once again, another question. On the who list, I want it to be something like:
[Name] [Title] [Clan if possible]
Right now, I'm having a hard time just understanding what's going on. Actually, I can't even put someone in a clan properly. I put someone into a clan I manually coded called "Phoenix," and they show up as the leader (which I set) for the clan when I type 'clan.' However, if I type 'who phoenix,' it says 0 players are online even though that character is in the clan file. I used setclan phoenix leader [player name] to put them in the clan. Am I doing something wrong here?
First, it would be easier to create and set both clans and starsystems online, using the commands 'setclan' and 'setstarsystem' respectively. They're pretty easy to figure out, so I I won't go into detail.
Secondly, how did you go about setting the player in the clan? Simply setting the player as the leader won't cut it. You also have to make sure the player is set to the clan. Sounds redundant (which it is), but that's the way it works. do a 'mset (player) clan phoenix' and you should be good. If not, I'd point fingers at do_who. I personally snipped out the clan part of the code long ago :-\
Thanks, the setclan worked, but I'm still not understanding some of the components of setstarsystem. Can someone explain the x/y to me a little bit?
Also, I want to remove a majority of the spells/skills. Is there any way to do this? I realized (the hard way), that simply deleting the spells from skills.dat doesn't work.
In addition to the skills.dat file entries you would need to remove the spells/skills from every class. Needless to say, this is an insanely time consuming ordeal.
You would also need to remove the appropriate lines from db.c that assigns the skills a GSN. I don't think the Smaug authors ever intended to make it easy to remove skills/spells. It may be best to just disable the skills instead of removing them. Setting the skills code to 'skill_null' and removing any affects it may have, would do the trick.
Yet another question regarding commands. For withdraw/deposit/donate, it says that I need to have a bank. I stripped down most of the areas which I deemed unnecessary (they weren't needed to compile properly). I was wondering how to make a bank? makebank doesn't seem to work...Any help?
EDIT: Nevermind, I found out that bank is nothing more than a roomflag.
Is this relevant to the subject "Adding Commands to SWR"? If not can you please start a new subject? Tacking questions onto the end of a different thread - in this case started in June 2003 - is just confusing.