| Posted by
| Nick Gammon
Australia (23,173 posts) Bio
Forum Administrator |
| Message
| In mud.h file is an enum of all the "states" that player can be in:
/*
* Connected state for a channel.
*/
typedef enum
{
CON_GET_NAME = -99,
CON_GET_OLD_PASSWORD, CON_CONFIRM_NEW_NAME,
CON_GET_NEW_PASSWORD, CON_CONFIRM_NEW_PASSWORD,
CON_GET_NEW_SEX, CON_GET_NEW_CLASS, CON_READ_MOTD,
CON_GET_NEW_RACE, CON_GET_EMULATION,
CON_GET_WANT_RIPANSI, CON_TITLE, CON_PRESS_ENTER,
CON_WAIT_1, CON_WAIT_2, CON_WAIT_3,
CON_ACCEPTED, CON_GET_PKILL, CON_READ_IMOTD,
/* Uncomment this if using Samson's Reroll code */
/* CON_ROLL_STATS, */
CON_COPYOVER_RECOVER, CON_PLAYING = 0,
/* Uncomment this if using Samson's delete code */
/* CON_DELETE, */
/* Uncomment this if using Mudworld's Oasis OLC port */
/* CON_OEDIT, CON_MEDIT, CON_REDIT, */
/* Uncomment this section if using Samson's Shell Code */
/* CON_FORKED, CON_IAFORKED, */
CON_EDITING
} connection_types;
When a new player connects they start off in CON_GET_NAME state, where any input from them is considered to be their name. There is a switch statement in the nanny routine in comm.c, which switches control to the appropriate handler for the current state.
Eventually they end up in CON_PLAYING state, which is the normal state where they enter commands.
You would need to add new states (eg. CON_MODIFY_STATS, CON_MODIFY_STAT_AMOUNT), and then slot them into the state machine handler. For example, in the handler for CON_GET_NEW_RACE it finishes by switching the state to CON_GET_WANT_RIPANSI.
That might be a good spot to add your new state CON_MODIFY_STATS instead. Then you ask them what stats they want to change, and when they choose one change the state to CON_MODIFY_STAT_AMOUNT. Then keep switching back and forth until they have finished modifying stats. Then you can go back to the normal sequence (eg. CON_GET_WANT_RIPANSI).
If you aren't sure what I am talking about, take a careful look at how the other questions are handled, that should give you plenty of clues about how to add your new stuff.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | | Top |
|