Register forum user name Search FAQ

Gammon Forum

Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the password reset link.

Due to spam on this forum, all posts now need moderator approval.

 Entire forum ➜ SMAUG ➜ SMAUG coding ➜ Perhaps someone can help me with 2 things.

Perhaps someone can help me with 2 things.

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by BHawk   (6 posts)  Bio
Date Wed 22 Oct 2003 02:21 PM (UTC)
Message
First thing, how would i go about switching the order in which you choose race and class in? I guess its a minor thing so if its complicated i wont even bother, but id really like players to choose their race to instead of their class first.

The second thing id like to do is group commands. What i mean is instead of having players go to a shot and type "buy", id rather have them type "shop buy". And all other shop related commands would need to be used through "shop". Same thing with bank (ie: "bank balance", etc). That way commands are sort of grouped together and finding help is easier (ie: players just type "help shop" and get a all the help involving shops).

If anyone can help id much appreciate it! thanx.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #1 on Wed 22 Oct 2003 04:10 PM (UTC)
Message
In comm.c you should find a function called "nanny" that handles a whole bunch of connection states: CON_*. You'd want to look for the place where the player is assigned CON_GET_CLASS, and make that CON_GET_RACE instead; and then inside the handler for CON_GET_RACE, make the next step be CON_GET_CLASS; and finally, make the next step for CON_GET_CLASS be whatever used to be next for CON_GET_RACE.

Note that you'll also have to move around things like class restrictions based on race. That may be just copy and paste or it may be more complicated.

As for grouping commands, take a look at things like mset or most any of the building/immortal commands. Those give pretty good examples how to group commands like that; it's basically just a bunch of if statements that branch the function off into little sub parts depending on the command.

I hope this helps. :)

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Rob Harper   (108 posts)  Bio
Date Reply #2 on Wed 22 Oct 2003 04:16 PM (UTC)
Message
1) The first thing is easy go into comm.c and cut the whole section relating to race out then scroll up above class and paste it above it and your set.

2) The second thing is pretty easy too, heh, I'm not sure eactly what you want to do, but if you players to just type "shop" and have a list of possible commnads pop up, just make a shop command and have it print out all the possible commands you can use with shop. Then cedit all the current commands like, for instance remove buy via "cedit buy delete" then it would become shopbuy via "cedit shopbuy create do_buy". Or you can do it..I guess the less half assed way and make the shop commands work off of arguments much like how mset works..well not eactly like mset works but you get the point I hope. Then you would add all the shop commands under the new shop command, and delete all the old ones.


I think that made since, I'm
note sure if not let me know
I'll clearify.
Top

Posted by Rob Harper   (108 posts)  Bio
Date Reply #3 on Wed 22 Oct 2003 04:18 PM (UTC)
Message
Heh while I was typing up my response you beat me to it Ksilyan.
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #4 on Wed 22 Oct 2003 04:23 PM (UTC)

Amended on Wed 22 Oct 2003 04:25 PM (UTC) by David Haley

Message
No, actually, cutting and pasting the race thing and moving it before the class thing actually won't help you at all, because the connection state is handled in a switch statement, and the order in which they are evaluated makes no difference whatsoever. You have to actually change the order in which incoming connections are assigned the different connection states.

There's a pretty big difference between the "shopbuy" and "shop buy" methods. In the first, shopbuy, you're actually creating separate commands, and therefore you will need separate corresponding functions - do_shopbuy and do_shop for instance - whereas in the second you'd be branching off to sub-commands inside the do_shop function. mset does this, basically, except that the "command" is the third argument, not the second (mset mob hp). It actually is more similar to redit, in which the second command really is what you're trying to do.


[edit to add:]
Rob: what can you say, I type faster than my shadow! *blows the smoke off his keyboard* :P

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by Rob Harper   (108 posts)  Bio
Date Reply #5 on Wed 22 Oct 2003 04:29 PM (UTC)
Message
Early on when I actually had both class and races, I simply moved it around and it worked, then again, I probably did some other stuff as well if I got errors who knows, and as for the "shop buy" and "shopbuy" I gave 2 separate answers.

As for fast I'll be that fast oneday I just gotta stop typing so much first. :)
Top

Posted by BHawk   (6 posts)  Bio
Date Reply #6 on Thu 23 Oct 2003 12:40 AM (UTC)
Message
Ok i got the shop thing, i think. Ill just create a do_shop function that takes in 2 arguments. The first argument will be the one that redirects the do_shop to some other function (ie: do_buy) and the second argument will be the item thats being handled. That i think i can do on my own now.

Now as for the race before class thing, thats what i really need help in because im not sure i understand the code that handles that. Maybe someone can go somewhat more indepth as to what i should do? in the meantime ill keep studying the code...
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #7 on Thu 23 Oct 2003 12:52 AM (UTC)
Message
SMAUG uses what are called "connection states" to know where the player's input is supposed to go. These should all be defined in mud.h. Examples are CON_GET_NAME, CON_GET_RACE, CON_PLAYING, CON_EDITING... etc.

There are three main groups, as I remember. Playing, editing, and everything else. Playing is pretty simple, if your connection state is playing, then anything you type is sent to the interpret function. If your connection state is editing, then what you type is sent to the editor buffer controller.

The third group, the "everything else", is mostly used during the initial connection phase. For example, when you first log on, the game needs to know what your name is so that it can log you in. Therefore, your connection state will be CON_GET_NAME or something like that.

From here, if you enter "new", it'll redirect you to CON_GET_NEW_NAME, otherwise, it'll ask you for your password, and redirect to CON_GET_PASSWORD.


So, basically, at one point in the character creation process, the user will be given the connection state CON_GET_CLASS. From that point onwards, the game will expect to receive the class text.

What you want to do is find that point at which the user is asked to enter their class, and when their con_state is switched to CON_GET_CLASS. Instead, there, you would ask them for their race, by setting their con_state CON_GET_RACE. Inside the CON_GET_RACE handler, look for the point at which it advances to CON_(something) (I can't remember what it is) and then make that CON_GET_CLASS. Then in your CON_GET_CLASS function, when the user normally is directed to enter a race, direct them to whatever it was you changed to CON_GET_CLASS in the race handler.

You'll have to do some extra work concerning racial class restrictions, i.e. so races can't be some classes. So you'll want to limit the choices available in CON_GET_CLASS to whatever their race allows them.


This is actually fairly easy to mess up. I'd be very careful with this, and test it very well.


By the way, I haven't looked at normal SMAUG for a long time, so I may have the names and all that wrong. However, I believe the general idea (and even most of the names) are the same.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

Posted by BHawk   (6 posts)  Bio
Date Reply #8 on Thu 23 Oct 2003 01:52 AM (UTC)
Message
Well, amazingly, i figured Id cut the race selection and paste it before the class selection and amazingly it worked! Now all i need to do is make the restrictions. Anyone know how i can do that??
Top

Posted by David Haley   USA  (3,881 posts)  Bio
Date Reply #9 on Thu 23 Oct 2003 01:54 AM (UTC)

Amended on Thu 23 Oct 2003 01:55 AM (UTC) by David Haley

Message
Did you include the
case CON_GET_RACE:
code in your cut/paste? Or did you just grab the code between the case statement and the break statement?

If you just grabbed the code in between, then yes, it would work, but that is extremely bad code style, because what the code is doing is not what your case says it does. If it says CON_GET_RACE, it should be getting the race, not the class. Then again, hey, it's your code...

edited to add:
To do the restrictions, just look at how it works and reproduce the same thing the other way around, e.g. you know the race, so you can only have these classes, instead of knowing the class and limiting to these races.

David Haley aka Ksilyan
Head Programmer,
Legends of the Darkstone

http://david.the-haleys.org
Top

The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).

To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.


29,602 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.