How do I add a new option to char_data in structs.h file?

  • cry1004
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 months 1 week ago - 7 months 1 week ago #9726 by cry1004
I'm sorry that it seems the only one me keeps asking questions.

When playing games, there are times when you want to start in a specific area as the world grows.
I want to create a new object in a specific room, and when I order it to register, the game starts in that room when I login.

At this time, if the registration cancellation command is entered, the location of the starting room is initialized to mortal_start_room and immort_start_room according to the user's level.

The following is the code I made, but it doesn't run because many places are wrong. It seems to be because I lack basic knowledge of programming.

I added it to the end of the struct char_data in the structs.h file.
struct char_data *start_room;

I didn't think I should add it to the reset_char function in the db.c file. Or it seems to be initialized with mortal_start_room and immort_start_room according to the user's level.

In the do_stat_character function of the act.wizard.c file, I can get the room name and show it.
This could be solved by knowing how to define and load a new value in char_data.

I think should initialize the starting room for void init_char(struct char_data *ch) function as well.
set_startroom(ch, r_mortal_start_room);
Again, this is a mess of code.

If the starting room is set in enter_player_game of the interpreter.c file, the character is connected to the room, and if it is not set, I can login to the room according to the level of the character.
ex) mortal_start_room and immort_start_room


I made the utils.h file to get the character's starting room, but it seems to be wrong.
#define GET_STARTROOM(ch) (ch->start_room)

I made a function that initializes the starting room in the limits.c file.
Of course it wasn't made right.
void set_startroom(struct char_data *ch, room_vnum rvnum)
{
  zone_rnum zrnum = real_zone_by_thing(rvnum);
  room_rnum rrnum = real_room(rvnum);

  if (GET_STARTROOM(ch) != NULL)
    free(GET_STARTROOM(ch));

  if (zrnum == NOWHERE || rrnum == NOWHERE) 
      GET_STARTROOM(ch) = r_mortal_start_room;
}


Is it correct to make the following when specifying the following in char_data?
struct char_data *start_room;
start_room is not an int type, it contains the room number.

I want to save and load the location of the starting room just like loading the user's level in utils.h.
#define GET_LEVEL(ch) ((ch)->player.level)


In my opinion, it doesn't seem to be called and used as below. Are there any documents that can help you learn this?
#define GET_STARTROOM(ch) (ch->start_room)

The article I wrote was using Google Translator. What I want to say may have been mistranslated into English.
Last edit: 7 months 1 week ago by cry1004.

Please Log in or Create an account to join the conversation.

  • Vatiken
  • Vatiken's Avatar
  • Offline
  • Administrator
  • Administrator
  • tbaMUD Programmer
More
7 months 1 week ago - 7 months 1 week ago #9728 by Vatiken
Please login to view the answers

tbaMUD developer/programmer
Last edit: 7 months 1 week ago by Vatiken.
The following user(s) said Thank You: cry1004

Please Log in or Create an account to join the conversation.

  • cry1004
  • Topic Author
  • Offline
  • Senior Member
  • Senior Member
More
7 months 1 week ago - 7 months 1 week ago #9730 by cry1004
Please login to view the answers
Last edit: 7 months 1 week ago by cry1004.

Please Log in or Create an account to join the conversation.

More
7 months 1 week ago #9734 by thomas
Please login to view the answers

Please Log in or Create an account to join the conversation.

Time to create page: 0.086 seconds