Lengthening short arguments for hidden doors

  • Sapphire
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
7 months 1 week ago #8038 by Sapphire
So, I have hidden doors in my mud and these are doors that are at the end of quest chains through analyzing room descriptions, mob conversations, etc to learn the name of the door. I would like to keep shortened arguments intact within the game with the exception of hidden doors. Can someone point me to where that portion of the code is in TBA or SunTzu?

To be more specific, I like having a Cityguard where you can type, "Kill cit," as it is in the code already. I like having a normal Drawbridge being opened with, "Open dr." I just need to change this up for 1 aspect of the mud.

Codebase is an ultra-modified (like 10+ years of work) SunTzu, but I have discovered with the Circle3.1 links between TBA that if I can find it in TBA, I can usually find it in SunTzu or something similar enough where I can mod it up in the code. Anyone know where to find that portion in the code?

Thanks in advance!
~Sapphire

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

More
7 months 1 week ago #8039 by thomas
The check you are looking for is here : github.com/tbamud/tbamud/blob/master/src/act.movement.c#L419 (and a couple of lines higher up)
  if (*dir) {			/* a direction was specified */
    if ((door = search_block(dir, dirs, FALSE)) == -1) { /* Partial Match */
      if ((door = search_block(dir, autoexits, FALSE)) == -1) { /* Check 'short' dirs too */
        send_to_char(ch, "That's not a direction.\r\n");
        return (-1);
      }
    }
    if (EXIT(ch, door)) {	/* Braces added according to indent. -gg */
      if (EXIT(ch, door)->keyword) {
        if (is_name(type, EXIT(ch, door)->keyword))  // <--- this need changing
          return (door);
        else {
          send_to_char(ch, "I see no %s there.\r\n", type);
          return (-1);
        }
      } else
	return (door);
    } else {
      send_to_char(ch, "I really don't see how you can %s anything there.\r\n", cmdname);
      return (-1);
    }
  } else {			/* try to locate the keyword */
    if (!*type) {
      send_to_char(ch, "What is it you want to %s?\r\n", cmdname);
      return (-1);
    }
    for (door = 0; door < DIR_COUNT; door++)
    {
      if (EXIT(ch, door))
      {
        if (EXIT(ch, door)->keyword)
        {
          if (isname(type, EXIT(ch, door)->keyword))  // <--- and this
          {
            if ((!IS_NPC(ch)) && (!PRF_FLAGGED(ch, PRF_AUTODOOR)))

This is some really hairy code, if you ask me. Definitely high cyclomatic complexity.

But what you want to do here is add a check:
          if ((IS_SET(EXIT(ch, door)->exit_info, EX_HIDDEN)) ? is_name(type, EXIT(ch, door)->keyword) : isname(type, EXIT(ch, door)->keyword))  
It's not really readable like this, and a refactor would move this to a nicely named function. But what we're doing is using is_name() for hidden exits and isname() for non-hidden. is_name() does not allow abbreviations.

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

  • Sapphire
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
7 months 1 week ago #8041 by Sapphire
Replied by Sapphire on topic Lengthening short arguments for hidden doors
Thanks for taking a moment to answer my questions. The morts on my game will be dinging me hard if I can't get this right for them because they love puzzles! My code snippet looks slightly different than yours and I'm wondering how to approach it given these differences. Here's a copy/paste of the find_door function.

int find_door(struct char_data *ch, const char *type, char *dir, const char *cmdname)
{
int door;

if (*dir) { /* a direction was specified */
if ((door = search_block(dir, dirs, FALSE)) < 0 &&
(door = search_block(dir, abbr_dirs, FALSE)) < 0) { /* Partial Match */
send_to_char(ch, "That's not a direction.\r\n");
return (-1);
}
if (EXIT(ch, door)) { /* Braces added according to indent. -gg */
if (EXIT(ch, door)->keyword) {
if (isname(type, EXIT(ch, door)->keyword))
return (door);
else {
send_to_char(ch, "I see no %s there.\r\n", type);
return (-1);
}
} else
return (door);
} else {
send_to_char(ch, "I really don't see how you can %s anything there.\r\n", cmdname);
return (-1);
}
} else { /* try to locate the keyword */
if (!*type) {
send_to_char(ch, "What is it you want to %s?\r\n", cmdname);
return (-1);
}
for (door = 0; door < NUM_OF_DIRS; door++)
if (EXIT(ch, door))
if (EXIT(ch, door)->keyword)
if (isname(type, EXIT(ch, door)->keyword))
return (door);

send_to_char(ch, "There doesn't seem to be %s %s here.\r\n", AN(type), type);
return (-1);
}
}

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

  • Sapphire
  • Topic Author
  • Offline
  • Fresh Boarder
  • Fresh Boarder
More
7 months 1 week ago #8042 by Sapphire
Replied by Sapphire on topic Lengthening short arguments for hidden doors
Thomas... cancel that, once I actually followed your instructions to a T it was a drag and drop into the right place. Very appreciative of your help! Thank you so much!

*HUG*

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

Time to create page: 1.607 seconds