Welcome to the Builder Academy

Question Ideas for traps/detecting/removing

More
04 Aug 2017 12:47 #6819 by JTP
What you wrote compiles.

But samt problem, if you dont have the skill. And look in an existing direction, no message comes.

But looking in what ever direction that doesnt exists, says Nothing special there.

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

More
04 Aug 2017 19:14 #6820 by thomas
Aah - now I understand what you mean. Well, yes, that is what this code does. If the exit exists, you will never get to the "nothing special here" case. So, to preserve that particular functionality, we need to do some racking of whether or not something is special in that direction:
Code:
static void look_in_direction(struct char_data *ch, int dir) { int anything_special = FALSE; if (EXIT(ch, dir)) { if (EXIT(ch, dir)->general_description && anything_special = TRUE) send_to_char(ch, "%s", EXIT(ch, dir)->general_description); if (EXIT_FLAGGED(EXIT(ch, dir), EX_CLOSED) && EXIT(ch, dir)->keyword && anything_special = TRUE) 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 && anything_special = TRUE) send_to_char(ch, "The %s is open.\r\n", fname(EXIT(ch, dir)->keyword)); room_rnum going_to = EXIT(ch, dir)->to_room; if (going_to != NOWHERE && ROOM_FLAGGED(going_to, ROOM_DEATH) && GET_SKILL(ch, SKILL_SENSE_TRAP) > 95 && anything_special = TRUE) send_to_char(ch, "You sense that a trap might be there.\r\n"); } if (!anything_special) send_to_char(ch, "Nothing special there...\r\n"); }

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

More
05 Aug 2017 15:53 #6821 by JTP
Code:
static void look_in_direction(struct char_data *ch, int dir) { int anything_special = FALSE; if (EXIT(ch, dir)) { if (EXIT(ch, dir)->general_description && anything_special = TRUE) send_to_char(ch, "%s", EXIT(ch, dir)->general_description); if (EXIT_FLAGGED(EXIT(ch, dir), EX_CLOSED) && EXIT(ch, dir)->keyword && anything_special = TRUE) 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 && anything_special = TRUE) send_to_char(ch, "The %s is open.\r\n", fname(EXIT(ch, dir)->keyword)); room_rnum going_to = EXIT(ch, dir)->to_room; if (going_to != NOWHERE && ROOM_FLAGGED(going_to, ROOM_DEATH) && GET_SKILL(ch, SKILL_SENSE_TRAP) > 95 && anything_special = TRUE) send_to_char(ch, "You sense that a trap might be there.\r\n"); } if (!anything_special) send_to_char(ch, "Nothing special there...\r\n"); }


act.informative.c: In function ‘look_in_direction’:
act.informative.c:622: error: invalid lvalue in assignment
act.informative.c:625: error: invalid lvalue in assignment
act.informative.c:627: error: invalid lvalue in assignment
act.informative.c:632: error: invalid lvalue in assignment


The errors is in all 4 lines where anything_special is used ?

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

More
05 Aug 2017 21:08 #6822 by thomas
My bad. The statements are being interpreted as "a && b && c = d" and everyone can see that "a && b && c" isn't a valid l-value. However, if you add some parenthesis:
Code:
static void look_in_direction(struct char_data *ch, int dir) { int anything_special = FALSE; if (EXIT(ch, dir)) { if (EXIT(ch, dir)->general_description && (anything_special = TRUE)) send_to_char(ch, "%s", EXIT(ch, dir)->general_description); if (EXIT_FLAGGED(EXIT(ch, dir), EX_CLOSED) && EXIT(ch, dir)->keyword && (anything_special = TRUE)) 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 && (anything_special = TRUE)) send_to_char(ch, "The %s is open.\r\n", fname(EXIT(ch, dir)->keyword)); room_rnum going_to = EXIT(ch, dir)->to_room; if (going_to != NOWHERE && ROOM_FLAGGED(going_to, ROOM_DEATH) && GET_SKILL(ch, SKILL_SENSE_TRAP) > 95 && (anything_special = TRUE)) send_to_char(ch, "You sense that a trap might be there.\r\n"); } if (!anything_special) send_to_char(ch, "Nothing special there...\r\n"); }
That is the problem with browser code - long feedback cycles.

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

More
05 Aug 2017 22:32 - 05 Aug 2017 22:37 #6824 by JTP
Yea browser code is hard.

It compiled but didnt show room name when looking in a possible direction :(

Only gives right message is there is no exit where your trying to look.

Hope we can solve this...It would be cool if it was possible for a player with sense trap to both get the room name and trap message.

And players without sense trap just the room name.


Looking at a closed direction Works, so why not the room name...
If i remove the trap part. It Works like it should with room name.
Last edit: 05 Aug 2017 22:37 by JTP.

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

More
05 Aug 2017 22:42 #6825 by JTP
Code:
static void look_in_direction(struct char_data *ch, int dir) { if (EXIT(ch, dir)) { room_rnum going_to = EXIT(ch, dir)->to_room; if (going_to != NOWHERE && ROOM_FLAGGED(going_to, ROOM_DEATH) && GET_SKILL(ch, SKILL_SENSE_TRAP) > 95) send_to_char(ch, "You sense that a trap might be there.\r\n"); if (EXIT(ch, dir)->general_description) send_to_char(ch, "%s", EXIT(ch, dir)->general_description); 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"); }


This worked for my imp with sense trap up until a test char without sense trap tryed to look in a direction.
Then after that it didnt Work for my imp either..

Something is messed up with the trap part just dont know what.

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

Time to create page: 0.286 seconds