Welcome to the Builder Academy

Question Ideas for traps/detecting/removing

More
23 Jul 2017 00:25 #6807 by JTP
I also tried to add it when looking in a direction...works when there is a direction. But If there is only an exit South, and i try to look north. Game crashes. See attached file for that code, and see If you Can see why i crash.
Attachments:

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

More
23 Jul 2017 07:08 #6808 by JTP
Backtrace file
Attachments:

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

More
30 Jul 2017 21:21 #6809 by thomas
The crash happens because going_to is never checked for validity before bring used.

First off, move the initialization beneath the first if statement. Then add "going_to != NOWHERE &&" at the beginning of the trap check.

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

More
31 Jul 2017 06:05 #6810 by zusuk
Just noticed you have your parenthesis a little off in that code....
Code:
case ITEM_TRAP: if (GET_OBJ_TYPE(obj) == ITEM_TRAP && GET_SKILL(ch, SKILL_SENSE_TRAP > 0)) { send_to_char(ch, "You sense a trap."); } else send_to_char(ch, "You see nothing special.."); break;

You probably want this?
Code:
GET_SKILL(ch, SKILL_SENSE_TRAP) > 0

Website
www.luminariMUD.com

Main Game Port
luminariMUD.com:4100

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

More
31 Jul 2017 10:29 #6811 by JTP
Tried what you said Thomas, got a bunch of errors.
Code:
static void look_in_direction(struct char_data *ch, int dir) { if (EXIT(ch, dir)) { room_rnum going_to != NOWHERE && EXIT(ch, dir)->to_room; 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 if (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"); } else send_to_char(ch, "Nothing special there...\r\n"); }


act.informative.c: In function ‘look_in_direction’:
act.informative.c:619: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘!=’ token
act.informative.c:619: error: expected expression before ‘!=’ token
act.informative.c:629: error: ‘going_to’ undeclared (first use in this function)
act.informative.c:629: error: (Each undeclared identifier is reported only once
act.informative.c:629: error: for each function it appears in.)

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

More
31 Jul 2017 12:21 #6812 by thomas
I'm afraid my communcation was lacking - it obviously wasn't clear enough.
What I mean was:
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 (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 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"); } else send_to_char(ch, "Nothing special there...\r\n"); }
Note - it is WAY easier to answer this post because the code was pasted there, than it was when it was an image.

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

Time to create page: 0.306 seconds