Welcome to the Builder Academy

Question Questions about look_in_direction

More
07 Sep 2020 17:03 #9608 by cry1004
Can the look_in_direction not show the general_description, but show the information of that room like typing a look command?

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

More
07 Sep 2020 17:19 - 07 Sep 2020 17:19 #9609 by cry1004
I don't know if it's correct, but it got the desired result.
Code:
room_rnum return_room = ch-> in_room; room_rnum look_room = EXIT(ch, dir)->to_room; char_from_room (ch); char_to_room (ch, look_room); look_at_room (ch, 1); char_from_room (ch); char_to_room (ch, return_room);
Last edit: 07 Sep 2020 17:19 by cry1004.

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

More
07 Sep 2020 22:46 #9619 by Vatiken
I would look at adding the information you are hoping to gain to look_in_direction versus the way you are handling it. In your work-around you are actually moving the character from room to room and back. This means the character will be victim to things triggered by that movement like quest triggers. This could also be abused as a means to escape combat as "send_to_room()" includes this code.
Code:
/* Stop fighting now, if we left. */ if (FIGHTING(ch) && IN_ROOM(ch) != IN_ROOM(FIGHTING(ch))) { stop_fighting(FIGHTING(ch)); stop_fighting(ch); }

tbaMUD developer/programmer
The following user(s) said Thank You: cry1004

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

More
11 Sep 2020 14:05 #9725 by cry1004
Vatiken, thank you for your comment.
I read your comments and recognized that there was a problem.

The original code is as follows:
Code:
static void look_in_direction(struct char_data *ch, int dir) { if (EXIT(ch, dir)) { if (EXIT(ch, dir)->general_description) send_to_char(ch, "%s", EXIT(ch, dir)->general_description); else send_to_char(ch, "You see nothing special.\r\n"); if (EXIT_FLAGGED(EXIT(ch, dir), EX_CLOSED) && EXIT(ch, dir)->keyword) send_to_char(ch, "The %s is closed.\r\n", fname(EXIT(ch, dir)->keyword)); else if (EXIT_FLAGGED(EXIT(ch, dir), EX_ISDOOR) && EXIT(ch, dir)->keyword) send_to_char(ch, "The %s is open.\r\n", fname(EXIT(ch, dir)->keyword)); } else send_to_char(ch, "Nothing special there...\r\n"); }

I revised the look_at_room code a little bit.

I am modifying the look_at_room code to display the information of the room that I am currently in, but the information of the room in the direction I want to see.
Code:
static void look_in_direction(struct char_data *ch, int dir) { if (EXIT(ch, dir)) { int i, title_width = 30; char buf[MAX_STRING_LENGTH]; if (!ch->desc) return; trig_data *t; room_rnum scanned_room = IN_ROOM(ch); scanned_room = world[scanned_room].dir_option[dir]->to_room; struct room_data *rm = &world[scanned_room]; if (IS_DARK(scanned_room) && !CAN_SEE_IN_DARK(ch)) { send_to_char(ch, "It is pitch black...\r\n"); return; } else if (AFF_FLAGGED(ch, AFF_BLIND) && GET_LEVEL(ch) < LVL_IMMORT) { send_to_char(ch, "You see nothing but infinite darkness...\r\n"); return; } send_to_char(ch, "\r\n\r\n%s", CCWHT(ch, C_SPR)); if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_SHOWVNUMS)) { title_width = strlen(world[scanned_room].name) / 2; sprintbitarray(ROOM_FLAGS(scanned_room), room_bits, RF_ARRAY_MAX, buf); send_to_char(ch, "%s[%s%5d%s] ", CBBLK(ch, C_SPR), CCYEL(ch, C_SPR), GET_ROOM_VNUM(scanned_room), CBBLK(ch, C_SPR)); send_to_char(ch, "%s%s %s[%s %s%s]%s",CCGRN(ch, C_SPR), world[scanned_room].name, CBBLK(ch, C_SPR), CCCYN(ch, C_SPR), buf, CBBLK(ch, C_SPR), CCWHT(ch, C_SPR)); if (SCRIPT(rm)) { send_to_char(ch, "%s[%sT%s",CBBLK(ch, C_SPR), CCMAG(ch, C_SPR), CBMAG(ch, C_SPR)); for (t = TRIGGERS(SCRIPT(rm)); t; t = t->next) send_to_char(ch, " %d", GET_TRIG_VNUM(t)); send_to_char(ch, "%s]%s",CBBLK(ch, C_SPR),CCWHT(ch, C_SPR)); } } else { if (!PRF_FLAGGED(ch, PRF_BRIEF)) { /* 간략모드 */ for (i = 0; i < (title_width - ((int)strlen(world[scanned_room].name) / 2)); i++) send_to_char(ch, " "); send_to_char(ch, "%s--=oOo< %s %s%s", CCGRN(ch, C_SPR), world[scanned_room].name, ">oOo=--\r\n", CCWHT(ch, C_SPR)); /* 방 제목 */ } else send_to_char(ch, "%s[ %s%s %s]\r\n", CCWHT(ch, C_SPR), CCGRN(ch, C_SPR), world[scanned_room].name, CCWHT(ch, C_SPR)); /* 방 제목 */ } /* 빈줄숨김 */ if (!PRF_FLAGGED(ch, PRF_COMPACT)) { send_to_char(ch, "\r\n"); } if (!PRF_FLAGGED(ch, PRF_COMPACT) && PRF_FLAGGED(ch, PRF_SHOWVNUMS)) { send_to_char(ch, "\r\n"); } if ((!IS_NPC(ch) && !PRF_FLAGGED(ch, PRF_BRIEF)) || ROOM_FLAGGED(scanned_room, ROOM_DEATH)) { if(!IS_NPC(ch)) send_to_char(ch, "%s", world[scanned_room].description); } /* autoexits */ if (!IS_NPC(ch) && PRF_FLAGGED(ch, PRF_AUTOEXIT)) do_auto_exits(ch); /* now list characters & objects */ list_obj_to_char(world[scanned_room].contents, ch, SHOW_OBJ_LONG, FALSE); list_char_in_room(world[scanned_room].people, ch, 0, FALSE); } else send_to_char(ch, "Nothing special there...\r\n"); }

I am not familiar with programming yet, so I can modify the code a little like this.
With this modification, it seems that the monster and I do not have to fight the monster.

Thanks again for pointing out the problem in the code I wrote.

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

More
11 Sep 2020 23:31 #9729 by Vatiken
You may be able to compact the code by simply altering the character's IN_ROOM() then calling look_at_room() and then switching it back. Different then how you did before by not actually calling char_to_room() but just changing the IN_ROOM() variable temporarily in look_in_direction().
Code:
static void look_in_direction(struct char_data *ch, int dir) { if (EXIT(ch, dir)) { if (EXIT(ch, dir)->general_description) send_to_char(ch, "%s", EXIT(ch, dir)->general_description); else send_to_char(ch, "You see nothing special.\r\n"); if (EXIT_FLAGGED(EXIT(ch, dir), EX_CLOSED) && EXIT(ch, dir)->keyword) send_to_char(ch, "The %s is closed.\r\n", fname(EXIT(ch, dir)->keyword)); else if (EXIT_FLAGGED(EXIT(ch, dir), EX_ISDOOR) && EXIT(ch, dir)->keyword) send_to_char(ch, "The %s is open.\r\n", fname(EXIT(ch, dir)->keyword)); /* Store our current room # */ current_room = IN_ROOM(ch) /* Swap our current room_rnum for the exit room's */ IN_ROOM(ch) = EXIT(ch, dir)->to_room /* Display the room to the character */ look_at_room(ch, 1) /* Reset our character's room */ IN_ROOM(ch) = current_room } else send_to_char(ch, "Nothing special there...\r\n"); }

tbaMUD developer/programmer
The following user(s) said Thank You: cry1004

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

More
12 Sep 2020 00:05 #9731 by cry1004
It scratches an itch. Thanks!

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

Time to create page: 0.228 seconds