Added autodoor and autokey toggles, and all auto toggle commands

This commit is contained in:
JamDog 2009-05-21 10:15:21 +00:00
parent 13d58bc333
commit 85ea93c818
7 changed files with 152 additions and 42 deletions

View file

@ -210,17 +210,19 @@ ACMD(do_gen_tog);
#define SCMD_CLS 17
#define SCMD_BUILDWALK 18
#define SCMD_AFK 19
#define SCMD_COLOR 20
#define SCMD_SYSLOG 21
#define SCMD_WIMPY 22
#define SCMD_PAGELENGTH 23
#define SCMD_AUTOLOOT 24 /**< Placeholder, currently unused */
#define SCMD_AUTOGOLD 25 /**< Placeholder, currently unused */
#define SCMD_AUTOSPLIT 26 /**< Placeholder, currently unused */
#define SCMD_AUTOSAC 27 /**< Placeholder, currently unused */
#define SCMD_AUTOASSIST 28 /**< Placeholder, currently unused */
#define SCMD_SCREENWIDTH 29
#define SCMD_AUTOMAP 30
#define SCMD_AUTOLOOT 20
#define SCMD_AUTOGOLD 21
#define SCMD_AUTOSPLIT 22
#define SCMD_AUTOSAC 23
#define SCMD_AUTOASSIST 24
#define SCMD_AUTOMAP 25
#define SCMD_AUTOKEY 26
#define SCMD_AUTODOOR 27
#define SCMD_COLOR 28
#define SCMD_SYSLOG 29
#define SCMD_WIMPY 30
#define SCMD_PAGELENGTH 31
#define SCMD_SCREENWIDTH 32
/* do_gen_write */
ACMD(do_gen_write);

View file

@ -1895,6 +1895,12 @@ ACMD(do_toggle)
{"automap", PRF_AUTOMAP, 1,
"You will no longer see the mini-map.\r\n",
"You will now see a mini-map at the side of room descriptions.\r\n"},
{"autokey", PRF_AUTOKEY, 0,
"You will now have to unlock doors manually before opening.\r\n",
"You will now automatically unlock doors when opening them (if you have the key).\r\n"},
{"autodoor", PRF_AUTODOOR, 0,
"You will now need to specify a door direction when opening, closing and unlocking.\r\n",
"You will now find the next available door when opening, closing or unlocking.\r\n"},
{"\n", 0, -1, "\n", "\n"} /* must be last */
};
@ -1972,6 +1978,8 @@ ACMD(do_toggle)
" Screenwidth: %-3d "
" AFK: %-3s\r\n"
" Autokey: %-3s "
" Autodoor: %-3s "
" Color: %s \r\n ",
ONOFF(PRF_FLAGGED(ch, PRF_DISPHP)),
@ -2006,6 +2014,8 @@ ACMD(do_toggle)
GET_SCREEN_WIDTH(ch),
ONOFF(PRF_FLAGGED(ch, PRF_AFK)),
ONOFF(PRF_FLAGGED(ch, PRF_AUTOKEY)),
ONOFF(PRF_FLAGGED(ch, PRF_AUTODOOR)),
types[COLOR_LEV(ch)]);
return;
}

View file

@ -412,12 +412,48 @@ static int find_door(struct char_data *ch, const char *type, char *dir, const ch
return (-1);
}
for (door = 0; door < NUM_OF_DIRS; door++)
{
if (EXIT(ch, door))
{
if (EXIT(ch, door)->keyword)
if (is_name(type, EXIT(ch, door)->keyword))
return (door);
{
if (isname(type, EXIT(ch, door)->keyword))
{
if ((!IS_NPC(ch)) && (!PRF_FLAGGED(ch, PRF_AUTODOOR)))
return door;
else if (is_abbrev(cmdname, "open"))
{
if (IS_SET(EXIT(ch, door)->exit_info, EX_CLOSED))
return door;
else if (IS_SET(EXIT(ch, door)->exit_info, EX_LOCKED))
return door;
}
else if ((is_abbrev(cmdname, "close")) && (!(IS_SET(EXIT(ch, door)->exit_info, EX_CLOSED))) )
return door;
else if ((is_abbrev(cmdname, "lock")) && (!(IS_SET(EXIT(ch, door)->exit_info, EX_LOCKED))) )
return door;
else if ((is_abbrev(cmdname, "unlock")) && (IS_SET(EXIT(ch, door)->exit_info, EX_LOCKED)) )
return door;
else if ((is_abbrev(cmdname, "pick")) && (IS_SET(EXIT(ch, door)->exit_info, EX_LOCKED)) )
return door;
}
}
}
}
if ((!IS_NPC(ch)) && (!PRF_FLAGGED(ch, PRF_AUTODOOR)))
send_to_char(ch, "There doesn't seem to be %s %s here.\r\n", AN(type), type);
else if (is_abbrev(cmdname, "open"))
send_to_char(ch, "There doesn't seem to be %s %s that can be opened.\r\n", AN(type), type);
else if (is_abbrev(cmdname, "close"))
send_to_char(ch, "There doesn't seem to be %s %s that can be closed.\r\n", AN(type), type);
else if (is_abbrev(cmdname, "lock"))
send_to_char(ch, "There doesn't seem to be %s %s that can be locked.\r\n", AN(type), type);
else if (is_abbrev(cmdname, "unlock"))
send_to_char(ch, "There doesn't seem to be %s %s that can be unlocked.\r\n", AN(type), type);
else
send_to_char(ch, "There doesn't seem to be %s %s that can be picked.\r\n", AN(type), type);
return (-1);
}
}
@ -620,6 +656,16 @@ ACMD(do_gen_door)
else if (!(DOOR_IS_LOCKED(ch, obj, door)) &&
IS_SET(flags_door[subcmd], NEED_LOCKED))
send_to_char(ch, "Oh.. it wasn't locked, after all..\r\n");
else if (!(DOOR_IS_UNLOCKED(ch, obj, door)) && IS_SET(flags_door[subcmd], NEED_UNLOCKED) && (PRF_FLAGGED(ch, PRF_AUTOKEY)) && (has_key(ch, keynum)) )
{
send_to_char(ch, "It is locked, but you have the key.\r\n");
send_to_char(ch, "*Click*\r\n");
do_doorcmd(ch, obj, door, subcmd);
}
else if (!(DOOR_IS_UNLOCKED(ch, obj, door)) && IS_SET(flags_door[subcmd], NEED_UNLOCKED) && (PRF_FLAGGED(ch, PRF_AUTOKEY)) && (!has_key(ch, keynum)) )
{
send_to_char(ch, "It is locked, and you do not have the key!\r\n");
}
else if (!(DOOR_IS_UNLOCKED(ch, obj, door)) &&
IS_SET(flags_door[subcmd], NEED_UNLOCKED) &&
(GET_LEVEL(ch) < LVL_IMMORT || !PRF_FLAGGED(ch, PRF_NOHASSLE)))

View file

@ -795,7 +795,23 @@ ACMD(do_gen_tog)
{"Buildwalk Off.\r\n",
"Buildwalk On.\r\n"},
{"AFK flag is now off.\r\n",
"AFK flag is now on.\r\n"}
"AFK flag is now on.\r\n"},
{"Autoloot disabled.\r\n",
"Autoloot enabled.\r\n"},
{"Autogold disabled.\r\n",
"Autogold enabled.\r\n"},
{"Autosplit disabled.\r\n",
"Autosplit enabled.\r\n"},
{"Autosacrifice disabled.\r\n",
"Autosacrifice enabled.\r\n"},
{"Autoassist disabled.\r\n",
"Autoassist enabled.\r\n"},
{"Automap disabled.\r\n",
"Automap enabled.\r\n"},
{"Autokey disabled.\r\n",
"Autokey enabled.\r\n"},
{"Autodoor disabled.\r\n",
"Autodoor enabled.\r\n"}
};
if (IS_NPC(ch))
@ -873,6 +889,30 @@ ACMD(do_gen_tog)
send_to_char(ch, "You have mail waiting.\r\n");
}
break;
case SCMD_AUTOLOOT:
result = PRF_TOG_CHK(ch, PRF_AUTOLOOT);
break;
case SCMD_AUTOGOLD:
result = PRF_TOG_CHK(ch, PRF_AUTOGOLD);
break;
case SCMD_AUTOSPLIT:
result = PRF_TOG_CHK(ch, PRF_AUTOSPLIT);
break;
case SCMD_AUTOSAC:
result = PRF_TOG_CHK(ch, PRF_AUTOSAC);
break;
case SCMD_AUTOASSIST:
result = PRF_TOG_CHK(ch, PRF_AUTOASSIST);
break;
case SCMD_AUTOMAP:
result = PRF_TOG_CHK(ch, PRF_AUTOMAP);
break;
case SCMD_AUTOKEY:
result = PRF_TOG_CHK(ch, PRF_AUTOKEY);
break;
case SCMD_AUTODOOR:
result = PRF_TOG_CHK(ch, PRF_AUTODOOR);
break;
default:
log("SYSERR: Unknown subcmd %d in do_gen_toggle.", subcmd);
return;

View file

@ -226,6 +226,8 @@ const char *preference_bits[] = {
"AUTOSAC",
"AUTOASSIST",
"AUTOMAP",
"AUTOKEY",
"AUTODOOR",
"\n"
};

View file

@ -82,6 +82,14 @@ cpp_extern const struct command_info cmd_info[] = {
{ "attach" , "attach" , POS_DEAD , do_attach , LVL_BUILDER, 0 },
{ "auction" , "auc" , POS_SLEEPING, do_gen_comm , 0, SCMD_AUCTION },
{ "autoexits" , "autoex" , POS_DEAD , do_gen_tog , 0, SCMD_AUTOEXIT },
{ "autoassist","autoass" , POS_DEAD , do_gen_tog , 0, SCMD_AUTOASSIST },
{ "autodoor" , "autodoor", POS_DEAD , do_gen_tog , 0, SCMD_AUTODOOR },
{ "autogold" , "autogold", POS_DEAD , do_gen_tog , 0, SCMD_AUTOGOLD },
{ "autokey" , "autokey" , POS_DEAD , do_gen_tog , 0, SCMD_AUTOKEY },
{ "autoloot" , "autoloot", POS_DEAD , do_gen_tog , 0, SCMD_AUTOLOOT },
{ "automap" , "automap" , POS_DEAD , do_gen_tog , 0, SCMD_AUTOMAP },
{ "autosac" , "autosac" , POS_DEAD , do_gen_tog , 0, SCMD_AUTOSAC },
{ "autosplit", "autospl" , POS_DEAD , do_gen_tog , 0, SCMD_AUTOSPLIT },
{ "backstab" , "ba" , POS_STANDING, do_backstab , 1, 0 },
{ "ban" , "ban" , POS_DEAD , do_ban , LVL_GRGOD, 0 },

View file

@ -250,8 +250,10 @@
#define PRF_AUTOSAC 29 /**< Sacrifice a corpse */
#define PRF_AUTOASSIST 30 /**< Auto-assist toggle */
#define PRF_AUTOMAP 31 /**< Show map at the side of room descs */
#define PRF_AUTOKEY 32 /**< Automatically unlock locked doors when opening */
#define PRF_AUTODOOR 33 /**< Use the next available door */
/** Total number of available PRF flags */
#define NUM_PRF_FLAGS 32
#define NUM_PRF_FLAGS 34
/* Affect bits: used in char_data.char_specials.saved.affected_by */
/* WARNING: In the world files, NEVER set the bits marked "R" ("Reserved") */