Added bury, dig and drain commands.

Signed-off-by: Polonkai Gergely <polesz@w00d5t0ck.info>
This commit is contained in:
Polonkai Gergely 2012-03-05 10:34:54 +01:00
parent e5f990fe3c
commit 3509974c90
4 changed files with 200 additions and 2 deletions

View File

@ -24,6 +24,19 @@
#include "house.h"
#include "constants.h"
const char *digbury_msgs[][2] = {
{ "You start to break some floor boards when you dig.", "$n starts to break some floor boards as $e starts digging." },
{ "You wonder if this is a good place after all, with all the gravel.", "$n breaks a sweat digging up all the gravel here." },
{ "You make a nice hold while digging up a lot of dirt.", "$n digs a hole and goes about $s business." },
{ "You seem to be hitting a lot of roots when you dig.", "$n looks like $e is trying to dig up a tree." },
{ "You dig up more clay than dirt here.", "$n seems to be digging up a lot of clay." },
{ "You start to chip away the rock here.", "$n bangs away at the side of the mountain." },
{ "You can't dig in the water!", NULL },
{ "You can't dig in the water!", NULL },
{ "You can't dig up air!", NULL },
{ "If you see this, please tell a Prophet!", NULL }
};
/* extern variables */
extern struct spell_info_type spell_info[];
extern const char *class_abbrevs[];
@ -65,6 +78,9 @@ ACMD(do_wimpy);
ACMD(do_display);
ACMD(do_gen_write);
ACMD(do_gen_tog);
ACMD(do_bury);
ACMD(do_dig);
ACMD(do_drain);
ACMD(do_quit)
@ -972,3 +988,177 @@ ACMD(do_gen_tog)
return;
}
ACMD(do_bury)
{
struct obj_data *obj;
char buf[MAX_INPUT_LENGTH], arg[MAX_INPUT_LENGTH];
half_chop(argument, arg, buf);
if (!*arg)
{
send_to_char(ch, "What do you want to %s?\r\n", CMD_NAME);
return;
}
if (!(obj = get_obj_in_list_vis(ch, arg, NULL, ch->carrying)))
{
send_to_char(ch, "You don't have %s %s\r\n", AN(arg), arg);
return;
}
/*
** find the sector types that you don't want people
** to be able to dig or bury in.
*/
if (
(world[IN_ROOM(ch)].sector_type == SECT_WATER_SWIM)
|| (world[IN_ROOM(ch)].sector_type == SECT_WATER_NOSWIM)
|| (world[IN_ROOM(ch)].sector_type == SECT_UNDERWATER)
|| (world[IN_ROOM(ch)].sector_type == SECT_FLYING)
)
{
/* display the messages if available */
if (digbury_msgs[world[IN_ROOM(ch)].sector_type][0] != NULL)
send_to_char(ch, "%s\r\n", digbury_msgs[world[IN_ROOM(ch)].sector_type][0]);
if (digbury_msgs[world[IN_ROOM(ch)].sector_type][1] != NULL)
act(digbury_msgs[world[IN_ROOM(ch)].sector_type][1], TRUE, ch, NULL, NULL, TO_ROOM);
return;
}
/* set a wait state */
WAIT_STATE(ch, 10 RL_SEC);
if(digbury_msgs[world[IN_ROOM(ch)].sector_type][0] != NULL)
send_to_char(ch, "%s\r\n", digbury_msgs[world[IN_ROOM(ch)].sector_type][0]);
if(digbury_msgs[world[IN_ROOM(ch)].sector_type][1] != NULL)
act(digbury_msgs[world[IN_ROOM(ch)].sector_type][1], TRUE, ch, NULL, NULL, TO_ROOM);
act("You bury $a $o here.\r\n", TRUE, ch, obj, NULL, TO_CHAR);
act("$n buries $a $o here.\r\n", TRUE, ch, obj, NULL, TO_ROOM);
obj_from_char(obj);
SET_BIT(GET_OBJ_EXTRA(obj), ITEM_BURIED);
obj_to_room(obj, IN_ROOM(ch));
}
ACMD(do_dig)
{
struct obj_data *obj;
int found_item = 0;
/*
** find the sector types that you don't want people
** to be able to dig or bury in.
*/
if (
(world[IN_ROOM(ch)].sector_type == SECT_WATER_SWIM)
|| (world[IN_ROOM(ch)].sector_type == SECT_WATER_NOSWIM)
|| (world[IN_ROOM(ch)].sector_type == SECT_UNDERWATER)
|| (world[IN_ROOM(ch)].sector_type == SECT_FLYING)
)
{
/* display the messages if available */
if (digbury_msgs[world[IN_ROOM(ch)].sector_type][0] != NULL)
send_to_char(ch, "%s\r\n", digbury_msgs[world[IN_ROOM(ch)].sector_type][0]);
if (digbury_msgs[world[IN_ROOM(ch)].sector_type][1] != NULL)
act(digbury_msgs[world[IN_ROOM(ch)].sector_type][1], TRUE, ch, NULL, NULL, TO_ROOM);
return;
}
/* set a wait state */
WAIT_STATE(ch, 10 RL_SEC);
/*
** Now that we have established that we can dig lets go
** ahead and do it!
*/
if (digbury_msgs[world[IN_ROOM(ch)].sector_type][0] != NULL)
send_to_char(ch, "%s\r\n", digbury_msgs[world[IN_ROOM(ch)].sector_type][0]);
if (digbury_msgs[world[IN_ROOM(ch)].sector_type][1] != NULL)
act(digbury_msgs[world[IN_ROOM(ch)].sector_type][1], TRUE, ch, NULL, NULL,TO_ROOM);
/*
** search for an object in the room that has a ITEM_BURIED flag
*/
obj = world[IN_ROOM(ch)].contents;
while (obj != NULL)
{
if (IS_BURIED(obj))
{
/* Remove the buried bit so the player can see it. */
REMOVE_BIT(GET_OBJ_EXTRA(obj), ITEM_BURIED);
if(CAN_SEE_OBJ(ch, obj))
{
found_item = 1; /* player found something */
act("You found $a $o buried here.\r\n", TRUE, ch, obj, NULL, TO_CHAR);
act("$n has found $a $o buried here.\r\n", TRUE, ch, obj, NULL,TO_ROOM);
obj_from_room(obj);
obj_to_char(obj, ch);
}
else
{
/* add the bit back becuase the player can't unbury what
** what he can't find... */
SET_BIT(GET_OBJ_EXTRA(obj), ITEM_BURIED);
}
}
/* go to the next obj */
obj = obj->next;
}
/* if the player didn't find anything */
if (!found_item)
send_to_char(ch, "Sorry! You didn't find anything.\r\n");
}
ACMD(do_drain)
{
char arg[MAX_INPUT_LENGTH];
struct obj_data *obj;
int HIT = 0,
MANA = 0,
MOVE = 0;
one_argument(argument, arg);
if (!*arg)
{
send_to_char(ch, "Drain what?\r\n");
return;
}
if (!(obj = get_obj_in_list_vis(ch, arg, NULL, world[ch->in_room].contents)))
{
send_to_char(ch, "That object is not here.\r\n");
return;
}
act("$n bends down and touches $p which slowly disappears.\r\n", FALSE, ch, obj, NULL, TO_ROOM);
act("You bend down and drain $p.\r\n", FALSE, ch, obj, NULL, TO_ROOM);
HIT = rand() % GET_LEVEL(ch) * 2 + 1;
MANA = rand() % GET_LEVEL(ch) + 1;
MOVE = rand() % 15 + 1;
GET_HIT(ch) = GET_HIT(ch) + HIT;
GET_MANA(ch) = GET_MANA(ch) + MANA;
GET_MOVE(ch) = GET_MOVE(ch) + MOVE;
extract_obj(obj);
}

View File

@ -70,6 +70,7 @@ ACMD(do_at);
ACMD(do_backstab);
ACMD(do_ban);
ACMD(do_bash);
ACMD(do_bury);
ACMD(do_cast);
ACMD(do_color);
ACMD(do_commands);
@ -78,7 +79,9 @@ ACMD(do_credits);
ACMD(do_date);
ACMD(do_dc);
ACMD(do_diagnose);
ACMD(do_dig);
ACMD(do_display);
ACMD(do_drain);
ACMD(do_drink);
ACMD(do_drop);
ACMD(do_eat);
@ -233,6 +236,7 @@ cpp_extern const struct command_info cmd_info[] = {
{ "brb" , POS_RESTING , do_action , 0, 0 },
{ "brief" , POS_DEAD , do_gen_tog , 0, SCMD_BRIEF },
{ "burp" , POS_RESTING , do_action , 0, 0 },
{ "bury" , POS_STANDING, do_bury , 0, 0 },
{ "buy" , POS_STANDING, do_not_here , 0, 0 },
{ "bug" , POS_DEAD , do_gen_write, 0, SCMD_BUG },
@ -264,8 +268,10 @@ cpp_extern const struct command_info cmd_info[] = {
{ "dc" , POS_DEAD , do_dc , LVL_GOD, 0 },
{ "deposit" , POS_STANDING, do_not_here , 1, 0 },
{ "diagnose" , POS_RESTING , do_diagnose , 0, 0 },
{ "dig" , POS_STANDING, do_dig , 0, 0 },
{ "display" , POS_DEAD , do_display , 0, 0 },
{ "donate" , POS_RESTING , do_drop , 0, SCMD_DONATE },
{ "drain" , POS_STANDING, do_drain , 0, 0 },
{ "drink" , POS_RESTING , do_drink , 0, SCMD_DRINK },
{ "drop" , POS_RESTING , do_drop , 0, SCMD_DROP },
{ "drool" , POS_RESTING , do_action , 0, 0 },

View File

@ -314,6 +314,7 @@
#define ITEM_PEN 21 /* Item is a pen */
#define ITEM_BOAT 22 /* Item is a boat */
#define ITEM_FOUNTAIN 23 /* Item is a fountain */
#define ITEM_BURIED 24 /* Item is buried */
/* Take/Wear flags: used by obj_data.obj_flags.wear_flags */

View File

@ -400,6 +400,7 @@ void update_pos(struct char_data *victim);
GET_OBJ_VAL((obj), 3) == 1)
#define CAN_WEAR(obj, part) OBJWEAR_FLAGGED((obj), (part))
#define IS_BURIED(obj) (IS_SET(GET_OBJ_EXTRA((obj)), ITEM_BURIED))
/* compound utilities and other macros **********************************/
@ -452,10 +453,10 @@ void update_pos(struct char_data *victim);
(!obj->worn_by || CAN_SEE(sub, obj->worn_by)))
#define MORT_CAN_SEE_OBJ(sub, obj) \
(LIGHT_OK(sub) && INVIS_OK_OBJ(sub, obj) && CAN_SEE_OBJ_CARRIER(sub, obj))
(LIGHT_OK(sub) && INVIS_OK_OBJ(sub, obj) && CAN_SEE_OBJ_CARRIER(sub, obj) )
#define CAN_SEE_OBJ(sub, obj) \
(MORT_CAN_SEE_OBJ(sub, obj) || (!IS_NPC(sub) && PRF_FLAGGED((sub), PRF_HOLYLIGHT)))
((MORT_CAN_SEE_OBJ(sub, obj) && !IS_BURIED(obj)) || (!IS_NPC(sub) && PRF_FLAGGED((sub), PRF_HOLYLIGHT)))
#define CAN_CARRY_OBJ(ch,obj) \
(((IS_CARRYING_W(ch) + GET_OBJ_WEIGHT(obj)) <= CAN_CARRY_W(ch)) && \