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 ➜ Player Description System (Advice Needed)

Player Description System (Advice Needed)

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


Posted by Xinphinity   USA  (26 posts)  Bio
Date Tue 03 Jun 2003 03:47 PM (UTC)
Message
I am going ahead with modifying the 'desc' verb, essentially I am eliminating the ability for players to type any description they like. In favor of this, I am 'trying' to create a player description module that initially starts within the nanny function, but also can be called later by 'specialty mobs' that will allow for character description look changes.

My tenative approach is to directly modify the code in player.c that handles do_description, to simply point to a new module in a file called player_desc.c .

What I am trying to figure out first though, how would I call a function in this file from nanny so that I can return a string containing the players choices? It's menu driven, so all the players arguments will be single char choices, but ideally, on case CON_GET_PLAYER_DESC, nanny would call this function, and the function would return a string like '0422020102' that would basically represent the players choices - and this would detranslated and then get written to the players file under a new members of the struct for the properties hair color, hair length, hair style, eye color, eye shape, facial type, etc.

Anyway, I think I have posted enough to get the point across of what I am trying to accomplish, and I'm certainly not looking for anyone to 'write' the code here, but any pointers on how to proceed would be fabulous.

~Xin
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #1 on Tue 03 Jun 2003 09:41 PM (UTC)
Message
What is the question here? How do you call a function in another file? Or something else?

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Xinphinity   USA  (26 posts)  Bio
Date Reply #2 on Tue 03 Jun 2003 10:09 PM (UTC)
Message
Well sort of, but some pointers on how to approach doing this at all might be helpful. For instance, I'm wondering if it's such a great idea to even tackle this in nanny or write a separate module to do it.

And yeah, how to call a function from nanny that lives in another file and occurs after class selection would be cool too.

Xin
Top

Posted by Xinphinity   USA  (26 posts)  Bio
Date Reply #3 on Tue 03 Jun 2003 10:41 PM (UTC)
Message
Gonna put a little bit more data in here.


I've modified the engine in some pretty core ways, though the changes fundamentally were not that drastic (thanks to Merc for pointing out my need to read up on c vs. scripting - that really helped).

I changed the class selection so that it doesnt happen at all. Players will arrive as 'newcomers'. I'm trying to write a sort of 'classless' modification which I know will take time and effort so for now I just nuked that part of nanny and forced the class assignment.

I modified the racial selection code to run off of do_help so I could make a more descriptive process for selecting the race that I can edit it offline quickly.

I modified the newbie starting room to be racially dependent and set by entries in the sysdata file so that new races get sent to different cities.

I added struct changes to char_data for lastname, and a char playerdescmap, and I am hoping to accomplish two things with that - 1, choose a last name, and 2, the descmap is basically a char containing a serial that describes the players features (eyes, hair, face, tattoo, etc).

Where I am stuck is in getting the last name chosen - I think I have that figured out though, and then finally, leading the player through a case driven module where they select eye color, eye shape, hair color, hair length, hair style, face shape, nose shape, etc.

Once they are done, I want to use the selections to write out this 'descmap' to their file, then use a modified version of the do_desc command to parse that map, create the desc on the fly and save it. Obviously, I'm taking the players ability to change this description.

Anyway, I know that the worth of this is in debate in some circles - I understand that, but for my purposes, I'm just hoping that readers of this post can point me in the right direction in getting this descmap functionality complete.

What I dont know is, how do i redirect away from nanny to this exterior description function, then back to nanny, how do i write that map out based on their choices, etc.

Really I'm just looking for a thread on this.


Sorry for being obtuse,

Xin
Top

Posted by Boborak   USA  (228 posts)  Bio
Date Reply #4 on Wed 04 Jun 2003 01:19 AM (UTC)
Message
Personally, I'm still a bit lost on what you're trying to do. As I understand it, you want to go from nanny() to another function, in which that function handles reading in the players choices for their appearance, which is then passed back to nanny and is saved to the char. Am I close? Ok, let's assume I'm close at least.

As was discussed in a previous thread, modifing nanny is akin to giving yourself a root canal. What you're trying to do, although noble, is a pretty complicated task. First and foremost, calling a player interactive function outside of nanny is something I would highly reccommend against. If you haven't quite figured out the way nanny works and what CON_STATES do, I think you need to take a few steps back and slow down a bit. It's bad enough you're trying to re-invent the wheel, but you don't seem to understand how the wheel works yet.

IF I were to try something similar to this, I think I would find it much easier to extend nanny's functionality then to call an outside function. The 'descmap' idea is a few steps ahead of the current issue. You should probably figure out the basics of reading player input and dealing with that input before moving on to something such as that.

Again, I would do my best to figure out how nanny works before moving on. What you're asking IS possible if I understand it right, but it's by far not the easiest or most efficiant way.

I know this isn't the answer you're looking for, but it's my honest opinion on the matter.
Top

Posted by Xinphinity   USA  (26 posts)  Bio
Date Reply #5 on Wed 04 Jun 2003 01:48 AM (UTC)
Message
Okay well first of all I do understand the wheel somewhat. And, although, no, that isnt exactly the answer I'm looking for, thats totally ok, and please don't sweat it - ;).

Inside nanny, outside, I dont really care. I have already modified nanny considerably, but, this particular set of functions is string intensive with a lot of choices, sub choices and returns to a 'main' selection screen where the player would indicate that they are 'done' making selections.

It would be great to understand more about how nanny interacts and operates, I admit I am still coming up to speed on it, I do know that it interacts with the 'connection' before it has become a 'player' and so I am wary of the potential of screwing things up.

Right now I allow nanny to pass through the name check, the password and the sex. Once it does, I have altered it to expand the race choice portion and taken out the class selection choice, ultimately just setting the class to the newcomer class.

Mind you, this and the alteration of the character structures did take some doing, and I fully expect to encounter more challenges taking this approach.

Any posts you can point me to also regarding how nanny processes input/output from the player would also be a big help, but I am starting to get it.


Got tips?

!unwillingTo(listen, feedback);,

Xin ;)
Top

Posted by Nick Gammon   Australia  (23,162 posts)  Bio   Forum Administrator
Date Reply #6 on Wed 04 Jun 2003 06:37 AM (UTC)
Message
I'll assume for argument's sake your question is really, "how do I make nanny a bit more modular by moving some code elsewhere?".

Basically nanny is called with two arguments:

void nanny( DESCRIPTOR_DATA *d, char *argument ) ;

You could make it more modular by making each selector a different function, eg.


    switch ( d->connected )
    {

    default:
        bug( "Nanny: bad d->connected %d.", d->connected );
        close_socket( d, TRUE );
        return;

    case CON_GET_NAME:
         nanny_get_name (d, argument); 
         return;

    case CON_GET_OLD_PASSWORD:
          nanny_get_old_password (d, argument);
          return;

// and so on

     }  // end of switch


Then handle the code for each case in a separate function, which could be in another file (nanny.c for instance).

This would be a lot neater, so you are on the right track.

The only thing you need to do to avoid compiler warnings, and possibly worse, is to "prototype" the functions before the nanny declaration.

eg.


void nanny_get_name( DESCRIPTOR_DATA *d, char *argument ) ;
void nanny_get_old_password( DESCRIPTOR_DATA *d, char *argument ) ;

// and so on


Doing that tells the compiler that the functions will be written elsewhere, and what they will look like.




- Nick Gammon

www.gammon.com.au, www.mushclient.com
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.


22,428 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.