2006-12-19 22:56:18 +00:00
|
|
|
/* ************************************************************************
|
|
|
|
|
* File: spec_procs.c Part of CircleMUD *
|
|
|
|
|
* Usage: implementation of special procedures for mobiles/objects/rooms *
|
|
|
|
|
* *
|
|
|
|
|
* All rights reserved. See license.doc for complete information. *
|
|
|
|
|
* *
|
|
|
|
|
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
|
|
|
|
|
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
|
|
|
|
|
************************************************************************ */
|
|
|
|
|
|
|
|
|
|
#include "conf.h"
|
|
|
|
|
#include "sysdep.h"
|
|
|
|
|
#include "structs.h"
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
#include "comm.h"
|
|
|
|
|
#include "interpreter.h"
|
|
|
|
|
#include "handler.h"
|
|
|
|
|
#include "db.h"
|
|
|
|
|
#include "spells.h"
|
|
|
|
|
#include "constants.h"
|
|
|
|
|
|
|
|
|
|
/* external vars */
|
|
|
|
|
extern struct time_info_data time_info;
|
|
|
|
|
extern struct spell_info_type spell_info[];
|
|
|
|
|
|
|
|
|
|
/* extern functions */
|
|
|
|
|
ACMD(do_drop);
|
|
|
|
|
ACMD(do_gen_door);
|
|
|
|
|
ACMD(do_say);
|
|
|
|
|
ACMD(do_action);
|
|
|
|
|
|
|
|
|
|
/* local functions */
|
|
|
|
|
void sort_spells(void);
|
|
|
|
|
int compare_spells(const void *x, const void *y);
|
|
|
|
|
const char *how_good(int percent);
|
|
|
|
|
void list_skills(struct char_data *ch);
|
|
|
|
|
SPECIAL(guild);
|
|
|
|
|
SPECIAL(dump);
|
|
|
|
|
SPECIAL(mayor);
|
|
|
|
|
SPECIAL(pet_shops);
|
|
|
|
|
SPECIAL(bank);
|
|
|
|
|
|
2007-03-28 12:53:48 +00:00
|
|
|
/* Special procedures for mobiles */
|
2006-12-19 22:56:18 +00:00
|
|
|
int spell_sort_info[MAX_SKILLS + 1];
|
|
|
|
|
|
|
|
|
|
int compare_spells(const void *x, const void *y)
|
|
|
|
|
{
|
|
|
|
|
int a = *(const int *)x,
|
|
|
|
|
b = *(const int *)y;
|
|
|
|
|
|
|
|
|
|
return strcmp(spell_info[a].name, spell_info[b].name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void sort_spells(void)
|
|
|
|
|
{
|
|
|
|
|
int a;
|
|
|
|
|
|
|
|
|
|
/* initialize array, avoiding reserved. */
|
|
|
|
|
for (a = 1; a <= MAX_SKILLS; a++)
|
|
|
|
|
spell_sort_info[a] = a;
|
|
|
|
|
|
|
|
|
|
qsort(&spell_sort_info[1], MAX_SKILLS, sizeof(int), compare_spells);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *how_good(int percent)
|
|
|
|
|
{
|
|
|
|
|
if (percent < 0)
|
|
|
|
|
return " error)";
|
|
|
|
|
if (percent == 0)
|
|
|
|
|
return " (not learned)";
|
|
|
|
|
if (percent <= 10)
|
|
|
|
|
return " (awful)";
|
|
|
|
|
if (percent <= 20)
|
|
|
|
|
return " (bad)";
|
|
|
|
|
if (percent <= 40)
|
|
|
|
|
return " (poor)";
|
|
|
|
|
if (percent <= 55)
|
|
|
|
|
return " (average)";
|
|
|
|
|
if (percent <= 70)
|
|
|
|
|
return " (fair)";
|
|
|
|
|
if (percent <= 80)
|
|
|
|
|
return " (good)";
|
|
|
|
|
if (percent <= 85)
|
|
|
|
|
return " (very good)";
|
|
|
|
|
|
|
|
|
|
return " (superb)";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char *prac_types[] = {
|
|
|
|
|
"spell",
|
|
|
|
|
"skill"
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
#define LEARNED_LEVEL 0 /* % known which is considered "learned" */
|
|
|
|
|
#define MAX_PER_PRAC 1 /* max percent gain in skill per practice */
|
|
|
|
|
#define MIN_PER_PRAC 2 /* min percent gain in skill per practice */
|
|
|
|
|
#define PRAC_TYPE 3 /* should it say 'spell' or 'skill'? */
|
|
|
|
|
|
|
|
|
|
/* actual prac_params are in class.c */
|
|
|
|
|
extern int prac_params[4][NUM_CLASSES];
|
|
|
|
|
|
|
|
|
|
#define LEARNED(ch) (prac_params[LEARNED_LEVEL][(int)GET_CLASS(ch)])
|
|
|
|
|
#define MINGAIN(ch) (prac_params[MIN_PER_PRAC][(int)GET_CLASS(ch)])
|
|
|
|
|
#define MAXGAIN(ch) (prac_params[MAX_PER_PRAC][(int)GET_CLASS(ch)])
|
|
|
|
|
#define SPLSKL(ch) (prac_types[prac_params[PRAC_TYPE][(int)GET_CLASS(ch)]])
|
|
|
|
|
|
|
|
|
|
void list_skills(struct char_data *ch)
|
|
|
|
|
{
|
|
|
|
|
const char *overflow = "\r\n**OVERFLOW**\r\n";
|
|
|
|
|
int i, sortpos;
|
|
|
|
|
size_t len = 0, nlen;
|
|
|
|
|
char buf2[MAX_STRING_LENGTH];
|
|
|
|
|
|
|
|
|
|
len = snprintf(buf2, sizeof(buf2), "You have %d practice session%s remaining.\r\n"
|
|
|
|
|
"You know of the following %ss:\r\n", GET_PRACTICES(ch),
|
|
|
|
|
GET_PRACTICES(ch) == 1 ? "" : "s", SPLSKL(ch));
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
for (sortpos = 1; sortpos <= MAX_SKILLS; sortpos++) {
|
|
|
|
|
i = spell_sort_info[sortpos];
|
|
|
|
|
if (GET_LEVEL(ch) >= spell_info[i].min_level[(int) GET_CLASS(ch)]) {
|
|
|
|
|
nlen = snprintf(buf2 + len, sizeof(buf2) - len, "%-20s %s\r\n", spell_info[i].name, how_good(GET_SKILL(ch, i)));
|
|
|
|
|
if (len + nlen >= sizeof(buf2) || nlen < 0)
|
|
|
|
|
break;
|
|
|
|
|
len += nlen;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (len >= sizeof(buf2))
|
|
|
|
|
strcpy(buf2 + sizeof(buf2) - strlen(overflow) - 1, overflow); /* strcpy: OK */
|
|
|
|
|
|
|
|
|
|
page_string(ch->desc, buf2, TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SPECIAL(guild)
|
|
|
|
|
{
|
|
|
|
|
int skill_num, percent;
|
|
|
|
|
|
|
|
|
|
if (IS_NPC(ch) || !CMD_IS("practice"))
|
|
|
|
|
return (FALSE);
|
|
|
|
|
|
|
|
|
|
skip_spaces(&argument);
|
|
|
|
|
|
|
|
|
|
if (!*argument) {
|
|
|
|
|
list_skills(ch);
|
|
|
|
|
return (TRUE);
|
|
|
|
|
}
|
|
|
|
|
if (GET_PRACTICES(ch) <= 0) {
|
|
|
|
|
send_to_char(ch, "You do not seem to be able to practice now.\r\n");
|
|
|
|
|
return (TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
skill_num = find_skill_num(argument);
|
|
|
|
|
|
|
|
|
|
if (skill_num < 1 ||
|
|
|
|
|
GET_LEVEL(ch) < spell_info[skill_num].min_level[(int) GET_CLASS(ch)]) {
|
|
|
|
|
send_to_char(ch, "You do not know of that %s.\r\n", SPLSKL(ch));
|
|
|
|
|
return (TRUE);
|
|
|
|
|
}
|
|
|
|
|
if (GET_SKILL(ch, skill_num) >= LEARNED(ch)) {
|
|
|
|
|
send_to_char(ch, "You are already learned in that area.\r\n");
|
|
|
|
|
return (TRUE);
|
|
|
|
|
}
|
|
|
|
|
send_to_char(ch, "You practice for a while...\r\n");
|
|
|
|
|
GET_PRACTICES(ch)--;
|
|
|
|
|
|
|
|
|
|
percent = GET_SKILL(ch, skill_num);
|
|
|
|
|
percent += MIN(MAXGAIN(ch), MAX(MINGAIN(ch), int_app[GET_INT(ch)].learn));
|
|
|
|
|
|
|
|
|
|
SET_SKILL(ch, skill_num, MIN(LEARNED(ch), percent));
|
|
|
|
|
|
|
|
|
|
if (GET_SKILL(ch, skill_num) >= LEARNED(ch))
|
|
|
|
|
send_to_char(ch, "You are now learned in that area.\r\n");
|
|
|
|
|
|
|
|
|
|
return (TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SPECIAL(dump)
|
|
|
|
|
{
|
|
|
|
|
struct obj_data *k;
|
|
|
|
|
int value = 0;
|
|
|
|
|
|
|
|
|
|
for (k = world[IN_ROOM(ch)].contents; k; k = world[IN_ROOM(ch)].contents) {
|
|
|
|
|
act("$p vanishes in a puff of smoke!", FALSE, 0, k, 0, TO_ROOM);
|
|
|
|
|
extract_obj(k);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!CMD_IS("drop"))
|
|
|
|
|
return (FALSE);
|
|
|
|
|
|
|
|
|
|
do_drop(ch, argument, cmd, SCMD_DROP);
|
|
|
|
|
|
|
|
|
|
for (k = world[IN_ROOM(ch)].contents; k; k = world[IN_ROOM(ch)].contents) {
|
|
|
|
|
act("$p vanishes in a puff of smoke!", FALSE, 0, k, 0, TO_ROOM);
|
|
|
|
|
value += MAX(1, MIN(50, GET_OBJ_COST(k) / 10));
|
|
|
|
|
extract_obj(k);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (value) {
|
|
|
|
|
send_to_char(ch, "You are awarded for outstanding performance.\r\n");
|
|
|
|
|
act("$n has been awarded for being a good citizen.", TRUE, ch, 0, 0, TO_ROOM);
|
|
|
|
|
|
|
|
|
|
if (GET_LEVEL(ch) < 3)
|
|
|
|
|
gain_exp(ch, value);
|
|
|
|
|
else
|
|
|
|
|
GET_GOLD(ch) += value;
|
|
|
|
|
}
|
|
|
|
|
return (TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
SPECIAL(mayor)
|
|
|
|
|
{
|
|
|
|
|
char actbuf[MAX_INPUT_LENGTH];
|
|
|
|
|
|
|
|
|
|
const char open_path[] =
|
|
|
|
|
"W3a3003b33000c111d0d111Oe333333Oe22c222112212111a1S.";
|
|
|
|
|
const char close_path[] =
|
|
|
|
|
"W3a3003b33000c111d0d111CE333333CE22c222112212111a1S.";
|
|
|
|
|
|
|
|
|
|
static const char *path = NULL;
|
|
|
|
|
static int path_index;
|
|
|
|
|
static bool move = FALSE;
|
|
|
|
|
|
|
|
|
|
if (!move) {
|
|
|
|
|
if (time_info.hours == 6) {
|
|
|
|
|
move = TRUE;
|
|
|
|
|
path = open_path;
|
|
|
|
|
path_index = 0;
|
|
|
|
|
} else if (time_info.hours == 20) {
|
|
|
|
|
move = TRUE;
|
|
|
|
|
path = close_path;
|
|
|
|
|
path_index = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (cmd || !move || (GET_POS(ch) < POS_SLEEPING) ||
|
|
|
|
|
(GET_POS(ch) == POS_FIGHTING))
|
|
|
|
|
return (FALSE);
|
|
|
|
|
|
|
|
|
|
switch (path[path_index]) {
|
|
|
|
|
case '0':
|
|
|
|
|
case '1':
|
|
|
|
|
case '2':
|
|
|
|
|
case '3':
|
|
|
|
|
perform_move(ch, path[path_index] - '0', 1);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'W':
|
|
|
|
|
GET_POS(ch) = POS_STANDING;
|
|
|
|
|
act("$n awakens and groans loudly.", FALSE, ch, 0, 0, TO_ROOM);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'S':
|
|
|
|
|
GET_POS(ch) = POS_SLEEPING;
|
|
|
|
|
act("$n lies down and instantly falls asleep.", FALSE, ch, 0, 0, TO_ROOM);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'a':
|
|
|
|
|
act("$n says 'Hello Honey!'", FALSE, ch, 0, 0, TO_ROOM);
|
|
|
|
|
act("$n smirks.", FALSE, ch, 0, 0, TO_ROOM);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'b':
|
|
|
|
|
act("$n says 'What a view! I must get something done about that dump!'",
|
|
|
|
|
FALSE, ch, 0, 0, TO_ROOM);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'c':
|
|
|
|
|
act("$n says 'Vandals! Youngsters nowadays have no respect for anything!'",
|
|
|
|
|
FALSE, ch, 0, 0, TO_ROOM);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'd':
|
|
|
|
|
act("$n says 'Good day, citizens!'", FALSE, ch, 0, 0, TO_ROOM);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'e':
|
|
|
|
|
act("$n says 'I hereby declare the bazaar open!'", FALSE, ch, 0, 0, TO_ROOM);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'E':
|
|
|
|
|
act("$n says 'I hereby declare Midgaard closed!'", FALSE, ch, 0, 0, TO_ROOM);
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'O':
|
|
|
|
|
do_gen_door(ch, strcpy(actbuf, "gate"), 0, SCMD_UNLOCK); /* strcpy: OK */
|
|
|
|
|
do_gen_door(ch, strcpy(actbuf, "gate"), 0, SCMD_OPEN); /* strcpy: OK */
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case 'C':
|
|
|
|
|
do_gen_door(ch, strcpy(actbuf, "gate"), 0, SCMD_CLOSE); /* strcpy: OK */
|
|
|
|
|
do_gen_door(ch, strcpy(actbuf, "gate"), 0, SCMD_LOCK); /* strcpy: OK */
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
case '.':
|
|
|
|
|
move = FALSE;
|
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
path_index++;
|
|
|
|
|
return (FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#define PET_PRICE(pet) (GET_LEVEL(pet) * 300)
|
|
|
|
|
SPECIAL(pet_shops)
|
|
|
|
|
{
|
|
|
|
|
char buf[MAX_STRING_LENGTH], pet_name[256];
|
|
|
|
|
room_rnum pet_room;
|
|
|
|
|
struct char_data *pet;
|
|
|
|
|
|
|
|
|
|
/* Gross. */
|
|
|
|
|
pet_room = IN_ROOM(ch) + 1;
|
|
|
|
|
|
|
|
|
|
if (CMD_IS("list")) {
|
|
|
|
|
send_to_char(ch, "Available pets are:\r\n");
|
|
|
|
|
for (pet = world[pet_room].people; pet; pet = pet->next_in_room) {
|
|
|
|
|
/* No, you can't have the Implementor as a pet if he's in there. */
|
|
|
|
|
if (!IS_NPC(pet))
|
|
|
|
|
continue;
|
|
|
|
|
send_to_char(ch, "%8d - %s\r\n", PET_PRICE(pet), GET_NAME(pet));
|
|
|
|
|
}
|
|
|
|
|
return (TRUE);
|
|
|
|
|
} else if (CMD_IS("buy")) {
|
|
|
|
|
|
|
|
|
|
two_arguments(argument, buf, pet_name);
|
|
|
|
|
|
|
|
|
|
if (!(pet = get_char_room(buf, NULL, pet_room)) || !IS_NPC(pet)) {
|
|
|
|
|
send_to_char(ch, "There is no such pet!\r\n");
|
|
|
|
|
return (TRUE);
|
|
|
|
|
}
|
|
|
|
|
if (GET_GOLD(ch) < PET_PRICE(pet)) {
|
|
|
|
|
send_to_char(ch, "You don't have enough gold!\r\n");
|
|
|
|
|
return (TRUE);
|
|
|
|
|
}
|
|
|
|
|
GET_GOLD(ch) -= PET_PRICE(pet);
|
|
|
|
|
|
|
|
|
|
pet = read_mobile(GET_MOB_RNUM(pet), REAL);
|
|
|
|
|
GET_EXP(pet) = 0;
|
|
|
|
|
SET_BIT(AFF_FLAGS(pet), AFF_CHARM);
|
|
|
|
|
|
|
|
|
|
if (*pet_name) {
|
|
|
|
|
snprintf(buf, sizeof(buf), "%s %s", pet->player.name, pet_name);
|
|
|
|
|
/* free(pet->player.name); don't free the prototype! */
|
|
|
|
|
pet->player.name = strdup(buf);
|
|
|
|
|
|
|
|
|
|
snprintf(buf, sizeof(buf), "%sA small sign on a chain around the neck says 'My name is %s'\r\n",
|
|
|
|
|
pet->player.description, pet_name);
|
|
|
|
|
/* free(pet->player.description); don't free the prototype! */
|
|
|
|
|
pet->player.description = strdup(buf);
|
|
|
|
|
}
|
|
|
|
|
char_to_room(pet, IN_ROOM(ch));
|
|
|
|
|
add_follower(pet, ch);
|
|
|
|
|
|
|
|
|
|
/* Be certain that pets can't get/carry/use/wield/wear items */
|
|
|
|
|
IS_CARRYING_W(pet) = 1000;
|
|
|
|
|
IS_CARRYING_N(pet) = 100;
|
|
|
|
|
|
|
|
|
|
send_to_char(ch, "May you enjoy your pet.\r\n");
|
|
|
|
|
act("$n buys $N as a pet.", FALSE, ch, 0, pet, TO_ROOM);
|
|
|
|
|
|
|
|
|
|
return (TRUE);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* All commands except list and buy */
|
|
|
|
|
return (FALSE);
|
|
|
|
|
}
|
|
|
|
|
|
2007-03-28 12:53:48 +00:00
|
|
|
/* Special procedures for objects */
|
2006-12-19 22:56:18 +00:00
|
|
|
SPECIAL(bank)
|
|
|
|
|
{
|
|
|
|
|
int amount;
|
|
|
|
|
|
|
|
|
|
if (CMD_IS("balance")) {
|
|
|
|
|
if (GET_BANK_GOLD(ch) > 0)
|
|
|
|
|
send_to_char(ch, "Your current balance is %d coins.\r\n", GET_BANK_GOLD(ch));
|
|
|
|
|
else
|
|
|
|
|
send_to_char(ch, "You currently have no money deposited.\r\n");
|
|
|
|
|
return (TRUE);
|
|
|
|
|
} else if (CMD_IS("deposit")) {
|
|
|
|
|
if ((amount = atoi(argument)) <= 0) {
|
|
|
|
|
send_to_char(ch, "How much do you want to deposit?\r\n");
|
|
|
|
|
return (TRUE);
|
|
|
|
|
}
|
|
|
|
|
if (GET_GOLD(ch) < amount) {
|
|
|
|
|
send_to_char(ch, "You don't have that many coins!\r\n");
|
|
|
|
|
return (TRUE);
|
|
|
|
|
}
|
|
|
|
|
GET_GOLD(ch) -= amount;
|
|
|
|
|
GET_BANK_GOLD(ch) += amount;
|
|
|
|
|
send_to_char(ch, "You deposit %d coins.\r\n", amount);
|
|
|
|
|
act("$n makes a bank transaction.", TRUE, ch, 0, FALSE, TO_ROOM);
|
|
|
|
|
return (TRUE);
|
|
|
|
|
} else if (CMD_IS("withdraw")) {
|
|
|
|
|
if ((amount = atoi(argument)) <= 0) {
|
|
|
|
|
send_to_char(ch, "How much do you want to withdraw?\r\n");
|
|
|
|
|
return (TRUE);
|
|
|
|
|
}
|
|
|
|
|
if (GET_BANK_GOLD(ch) < amount) {
|
|
|
|
|
send_to_char(ch, "You don't have that many coins deposited!\r\n");
|
|
|
|
|
return (TRUE);
|
|
|
|
|
}
|
|
|
|
|
GET_GOLD(ch) += amount;
|
|
|
|
|
GET_BANK_GOLD(ch) -= amount;
|
|
|
|
|
send_to_char(ch, "You withdraw %d coins.\r\n", amount);
|
|
|
|
|
act("$n makes a bank transaction.", TRUE, ch, 0, FALSE, TO_ROOM);
|
|
|
|
|
return (TRUE);
|
|
|
|
|
} else
|
|
|
|
|
return (FALSE);
|
|
|
|
|
}
|
|
|
|
|
|