tbamud/src/spec_procs.c
Rumble ebc985f010 jeremyosborne | 2008-04-04 02:36:38 +0200 (Fri, 04 Apr 2008) | 1 line
Minor Bugfix: All game configuration settings now reference the world config 
structure, not the individual config variables found in config.c.
------------------------------------------------------------------------
 rumble | 2008-03-22 13:27:00 +0100 (Sat, 22 Mar 2008) | 1 line

Added lib/world/qst/ directory, index, index.mini, and 0.qst.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-08 03:27:51 +0100 (Sat, 08 Mar 2008) | 3 lines

Bugfix: the include directory (for .h files) is now referenced correctly in the
depend statement.
Deletion: listrent.c removed as a separate utility.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-08 03:08:51 +0100 (Sat, 08 Mar 2008) | 1 line

Enhancement: utils/ Makefile will now use a depends file, and looks for dependen
cies in the ../ directory (shrinks the necessary information to make each utilit
y).
------------------------------------------------------------------------
 Rumble | 2008-03-06 23:39:35 +0100 (Thu, 06 Mar 2008) | 1 line

Made TBA specific changes. do_cheat, removed help level checking, and advance to
level 32.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-06 18:37:12 +0100 (Thu, 06 Mar 2008) | 1 line

Minor Update: Changed header of Makefile.in to read 'tbaMUD' and also added in a
ttribution for the changes. (Thanks seqwith.)
------------------------------------------------------------------------
 jeremyosborne | 2008-03-06 18:31:07 +0100 (Thu, 06 Mar 2008) | 4 lines

Changed Makefile.in to use glob expressions when building the objects. This 
translates into no longer a need to update Makefile.in whenever a new .c file 
is added to the mud code. Other Makefile.* have not yet been changed (and 
need review, anyway).

All CXREF cruft left in Makefile.in has been removed. tbaMUD is now using 
Doxygen. Technically, CXREF provides a bit more auto-documentation than Doxygen
does, however the tbaMUD (and legacy circle code) has never been marked-up with 
the special CXREF codes required to effectively use the program. Since Doxygen 
is easier to use, and provides almost as much functionality as CXREF, CXREF 
support has been dropped.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-06 08:31:02 +0100 (Thu, 06 Mar 2008) | 1 line

Bug Fix: asciiflag_conv* functions now can handle a negative numeric value.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-06 08:16:06 +0100 (Thu, 06 Mar 2008) | 1 line

Bug fix/enhancement: Charmed mobs (specifically charmed mobs with a ->master) 
will no longer attempt to wander off.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-06 08:13:38 +0100 (Thu, 06 Mar 2008) | 6 lines

Based on the compiler warning about mag_materials being an unused function, and
the clone spell being unused.

Bug fix: Clone can now be cast. It is an 'ignore' target spell.

Fix and Modification: Clone, being an effectively unused spell that is only used
by mortal Magic Users at level 30, is now implemented as very simple example of
how to use mag_materials(). The item required by mag_materials is vnum 161, 
which in stock tbaMUD is some sacrificial entrails.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-05 01:43:09 +0100 (Wed, 05 Mar 2008) | 3 lines

Bug Fix for "Did you mean:" including DG commands.
------------------------------------------------------------------------
 jeremyosborne | 2008-03-05 01:29:18 +0100 (Wed, 05 Mar 2008) | 3 lines

Bug Fix: do_simple_move slightly rewritten to handle Leave triggers that purge a
 door.

Documentation: do_simple_move documented.
------------------------------------------------------------------------
 Laoris | 2008-03-01 08:22:12 +0100 (Sat, 01 Mar 2008) | 1 line

Trial run of columnizer function on commands list to see how people like it.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-26 22:36:17 +0100 (Tue, 26 Feb 2008) | 1 line

asciimap, an in game automap, along with a couple of minor bug fixes to do with
the automap, patched in (Thanks Jamdog).
------------------------------------------------------------------------
 jeremyosborne | 2008-02-22 04:08:05 +0100 (Fri, 22 Feb 2008) | 1 line

Minor update: Relocate local variable declaration to the top of ACMD(do_help)
------------------------------------------------------------------------
 jeremyosborne | 2008-02-22 04:04:37 +0100 (Fri, 22 Feb 2008) | 6 lines

Checked in the following placeholders for do_gen_tog:
#define SCMD_AUTOLOOT   24
#define SCMD_AUTOGOLD   25
#define SCMD_AUTOSPLIT  26
#define SCMD_AUTOSAC    27
#define SCMD_AUTOASSIST 28
------------------------------------------------------------------------
 jeremyosborne | 2008-02-22 03:57:06 +0100 (Fri, 22 Feb 2008) | 1 line

The Autoquest patch, along with a couple of minor bug fixes, has been integrated
into tbaMUD. (Thanks Jamdog, Kenneth Ray and Morgaelin.)
------------------------------------------------------------------------
 jeremyosborne | 2008-02-18 21:46:45 +0100 (Mon, 18 Feb 2008) | 2 lines

Minor Fix:
Casted NOWHERE, NOTHING, NOBODY and NOFLAG as IDXTYPE for the signed short int 
index types.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-18 03:36:16 +0100 (Mon, 18 Feb 2008) | 7 lines

Added a new atoidx() conversion function for dealing with string to IDXTYPE 
conversions (in utils.c, prototype exported through utils.h).
Added IDXTYPE_MIN and IDXTYPE_MAX defines (in structs.h).
Replaced atoi references with atoidx in do_oasis_zedit (in zedit.c).
------------------------------------------------------------------------
 Rumble | 2008-02-18 01:44:13 +0100 (Mon, 18 Feb 2008) | 1 line

Fixed direction mapping to give readable directions instead of sub commands. 
------------------------------------------------------------------------
 jeremyosborne | 2008-02-18 00:26:15 +0100 (Mon, 18 Feb 2008) | 5 lines

Since general olc editing are automatically saved to disk, 'shutdown reboot' has
been changed to not-autosave by default. (Small change made to do_shutdown in 
act.wizard.c).
------------------------------------------------------------------------
 jeremyosborne | 2008-02-18 00:12:12 +0100 (Mon, 18 Feb 2008) | 3 lines

Changed:
struct attack_hit_type moved to fight.h
attack_hit_text exported through fight.h
------------------------------------------------------------------------
 jeremyosborne | 2008-02-17 22:32:51 +0100 (Sun, 17 Feb 2008) | 7 lines

- do_file heads or tails files correctly and has also been enhanced to return 
file info (act.wizard.c)
- defines made for common log files created by autorun, and those used by 
do_file (db.h)
- utility functions added: file_head(), file_tail(), file_sizeof(), and 
file_numlines() (defined utils.c and exported through utils.h)
------------------------------------------------------------------------
 Rumble | 2008-02-16 23:24:05 +0100 (Sat, 16 Feb 2008) | 1 line

Fixed export command. (thanks Kyle)
------------------------------------------------------------------------
 jeremyosborne | 2008-02-16 22:42:46 +0100 (Sat, 16 Feb 2008) | 1 line

Files are now tagged as executable. Should be able to be checked out from subver
sion and executed without running chmod.
------------------------------------------------------------------------
 Rumble | 2008-02-15 17:03:06 +0100 (Fri, 15 Feb 2008) | 1 line

 Fixed strcat() writing out of bounds in cedit.c since strdup() only malloc() 
strlen(str)+1 bytes. (thanks Buggo) and moved attack_hit_text back.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-13 20:41:02 +0100 (Wed, 13 Feb 2008) | 1 line

Event queue function definitions, global variables and defines doxygenated.
------------------------------------------------------------------------
 Rumble | 2008-02-12 00:23:38 +0100 (Tue, 12 Feb 2008) | 1 line

Updated levels command to use an arg/range and added color parsing to greetings.
 (thanks Jamdog)
------------------------------------------------------------------------
 jeremyosborne | 2008-02-11 21:06:10 +0100 (Mon, 11 Feb 2008) | 1 line

Doxygen comments completed for weather.c
------------------------------------------------------------------------
 Rumble | 2008-02-11 03:52:50 +0100 (Mon, 11 Feb 2008) | 1 line

Corrected several 64-bit warnings. (thanks Buggo)
------------------------------------------------------------------------
 Rumble | 2008-02-10 22:56:56 +0100 (Sun, 10 Feb 2008) | 1 line

Added get_flag_by_name allowing for new trigedit variable checks like 
%actor.pref(FLAG)% checks. (thanks Jamdog)
------------------------------------------------------------------------
 jeremyosborne | 2008-02-08 21:22:26 +0100 (Fri, 08 Feb 2008) | 3 lines

COMPLETE: tbaMUD code re-org of global and local scope function and variable 
declarations. There may be a few things that I did not catch (some non extern 
keyword declarations of function prototypes within other functions, for 
example).

BUG FIX: Unused functions encrypt_hex() and decrypt_hex() removed from mail.c.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-05 23:31:09 +0100 (Tue, 05 Feb 2008) | 2 lines

Continued clean-up of 'extern' references to functions and variables.
BUG UNCOVERED: set_title() in class.c incorrectly handles the const nature of 
the char * returned from title_female and title_male.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-05 19:38:17 +0100 (Tue, 05 Feb 2008) | 3 lines

More work on mud clean-up.
New file: spec_procs.h
Created this file to house the legacy special procedures (spec_procs.c and 
castle.c) and special feature assignment in general.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-05 00:59:44 +0100 (Tue, 05 Feb 2008) | 3 lines

- Minor Bugfix: Fixed parse error in mobact.c
- Minor Bugfix: act.h is now included in all of the act functions. Forgot to do
that the first time :(
- Additions: ban.h has been added as the external entry point into the ban.c 
globals and functions. Files needing ban.h have been updated.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-04 20:02:11 +0100 (Mon, 04 Feb 2008) | 1 line

All act*.c functions, defines and globals have been prototyped/declared in 
act.h. The file act.h does not contain every ACMD, only those ACMDs and 
utility functions available within the act*.c files.
------------------------------------------------------------------------
 Rumble | 2008-02-04 17:59:47 +0100 (Mon, 04 Feb 2008) | 1 line

Fixed the last few flags missed for the 128 bit conversion.
------------------------------------------------------------------------
 Laoris | 2008-02-04 07:27:56 +0100 (Mon, 04 Feb 2008) | 3 lines

Adding a column formatter for lists.  Accepts printf-like arguments.
Only used by medit right now.

------------------------------------------------------------------------
 jeremyosborne | 2008-02-04 07:09:19 +0100 (Mon, 04 Feb 2008) | 2 lines

- Changed the 'struct queue' to 'struct dg_queue' to avoid namespace conflicts.
- Ongoing cleanup to mud project.
------------------------------------------------------------------------
 Rumble | 2008-02-04 00:07:09 +0100 (Mon, 04 Feb 2008) | 1 line

Fixed run_autowiz which ran twice on advancement.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-03 03:46:22 +0100 (Sun, 03 Feb 2008) | 1 line

act.h created and added. This header will be the external entry point for the 
functions, function subcommands and variables within the act*.c files. It is 
not designed to be the entry point for all ACMD functions.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-03 02:44:29 +0100 (Sun, 03 Feb 2008) | 1 line

Merge of another part of the code cleanup, the dg script stuff.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-02 08:56:03 +0100 (Sat, 02 Feb 2008) | 1 line

Modularizing and organizing files continues. Committing comm.c and comm.h 
because they are hairy, and I don't want to do them over if my hard drive 
crashes.
------------------------------------------------------------------------
 jeremyosborne | 2008-02-02 07:05:08 +0100 (Sat, 02 Feb 2008) | 4 lines

- Marking all file scope functions as 'static'
- Reorganization of the global variables and functions.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-31 10:20:47 +0100 (Thu, 31 Jan 2008) | 1 line

* Protected the conf.h.* system config files from multiple calls.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-31 09:56:18 +0100 (Thu, 31 Jan 2008) | 1 line

* Removed extraneous references to TRUE / FALSE and YES / NO defines.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-31 09:46:20 +0100 (Thu, 31 Jan 2008) | 2 lines

* BUGFIX: NUM_POSITIONS set to 8 (was incorrectly set to 15 before)
* Migrated NUM_* settings from oasis.h to more appropriate locations near where
they are defined. (For Example: NUM_POSITIONS moved to structs.h next to the 
POSITION_* defines.)
------------------------------------------------------------------------
 jeremyosborne | 2008-01-31 03:58:28 +0100 (Thu, 31 Jan 2008) | 1 line

Added Appendix A - Coder Support. Right now, it simply speaks to the fact that 
we have included doxygen config files, are working to document the source code, 
and provides a rudimentary "do this" guide to create the doxygen cross 
references.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-30 07:12:07 +0100 (Wed, 30 Jan 2008) | 2 lines

- All .h files now have doxygen recognized headers, and the format is slightly 
altered to ease editing of headers.
- Protected all .h files from multiple calls. (Standard format is #ifndef _HEADE
R_H_ #define _HEADER_H_ .... #endif)
------------------------------------------------------------------------
 jeremyosborne | 2008-01-29 11:18:14 +0100 (Tue, 29 Jan 2008) | 1 line

constants.h, structs.h and utils.h now protected from multiple includes. This is
 sometimes overkill, but good practice overall.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-29 10:38:18 +0100 (Tue, 29 Jan 2008) | 1 line

Updated documentation for constants.c and constants.h.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-29 10:15:25 +0100 (Tue, 29 Jan 2008) | 3 lines

The standard Doxygen configuration doxyfiles (config files) for tbaMUD. One is 
to be used with the Graphviz DOT (dox_withGraphs), one is designed to be used if
Graphviz is not available.

Now just need a short document describing the usage of doxygen.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-29 10:11:36 +0100 (Tue, 29 Jan 2008) | 1 line

Minor document correction in struct dex_app_tpe.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-28 20:53:51 +0100 (Mon, 28 Jan 2008) | 1 line

*bugfix* do_drink command: When a container is empty, the correct, "It is 
empty." message is now displayed.
------------------------------------------------------------------------
 jeremyosborne | 2008-01-28 07:58:15 +0100 (Mon, 28 Jan 2008) | 3 lines

Merging changes to trunk for:
* utils.h, utils.c and structs.h doxygen comments
* adding file dox_withGraphs.doxyfile
2008-04-12 01:31:58 +00:00

696 lines
18 KiB
C

/**************************************************************************
* File: spec_procs.c Part of tbaMUD *
* Usage: Implementation of special procedures for mobiles/objects/rooms. *
* *
* All rights reserved. See license for complete information. *
* *
* Copyright (C) 1993, 94 by the Trustees of the Johns Hopkins University *
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
**************************************************************************/
/* For more examples:
* ftp://ftp.circlemud.org/pub/CircleMUD/contrib/snippets/specials */
#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"
#include "act.h"
#include "spec_procs.h"
#include "class.h"
#include "fight.h"
#include "modify.h"
/* locally defined functions of local (file) scope */
static int compare_spells(const void *x, const void *y);
static const char *how_good(int percent);
static void npc_steal(struct char_data *ch, struct char_data *victim);
/* Special procedures for mobiles. */
static int spell_sort_info[MAX_SKILLS + 1];
static 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);
}
static 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'? */
#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));
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);
}
/* General special procedures for mobiles. */
static void npc_steal(struct char_data *ch, struct char_data *victim)
{
int gold;
if (IS_NPC(victim))
return;
if (GET_LEVEL(victim) >= LVL_IMMORT)
return;
if (!CAN_SEE(ch, victim))
return;
if (AWAKE(victim) && (rand_number(0, GET_LEVEL(ch)) == 0)) {
act("You discover that $n has $s hands in your wallet.", FALSE, ch, 0, victim, TO_VICT);
act("$n tries to steal gold from $N.", TRUE, ch, 0, victim, TO_NOTVICT);
} else {
/* Steal some gold coins */
gold = (GET_GOLD(victim) * rand_number(1, 10)) / 100;
if (gold > 0) {
GET_GOLD(ch) += gold;
GET_GOLD(victim) -= gold;
}
}
}
/* Quite lethal to low-level characters. */
SPECIAL(snake)
{
if (cmd || GET_POS(ch) != POS_FIGHTING || !FIGHTING(ch))
return (FALSE);
if (IN_ROOM(FIGHTING(ch)) != IN_ROOM(ch) || rand_number(0, GET_LEVEL(ch)) != 0)
return (FALSE);
act("$n bites $N!", 1, ch, 0, FIGHTING(ch), TO_NOTVICT);
act("$n bites you!", 1, ch, 0, FIGHTING(ch), TO_VICT);
call_magic(ch, FIGHTING(ch), 0, SPELL_POISON, GET_LEVEL(ch), CAST_SPELL);
return (TRUE);
}
SPECIAL(thief)
{
struct char_data *cons;
if (cmd || GET_POS(ch) != POS_STANDING)
return (FALSE);
for (cons = world[IN_ROOM(ch)].people; cons; cons = cons->next_in_room)
if (!IS_NPC(cons) && GET_LEVEL(cons) < LVL_IMMORT && !rand_number(0, 4)) {
npc_steal(ch, cons);
return (TRUE);
}
return (FALSE);
}
SPECIAL(magic_user)
{
struct char_data *vict;
if (cmd || GET_POS(ch) != POS_FIGHTING)
return (FALSE);
/* pseudo-randomly choose someone in the room who is fighting me */
for (vict = world[IN_ROOM(ch)].people; vict; vict = vict->next_in_room)
if (FIGHTING(vict) == ch && !rand_number(0, 4))
break;
/* if I didn't pick any of those, then just slam the guy I'm fighting */
if (vict == NULL && IN_ROOM(FIGHTING(ch)) == IN_ROOM(ch))
vict = FIGHTING(ch);
/* Hm...didn't pick anyone...I'll wait a round. */
if (vict == NULL)
return (TRUE);
if (GET_LEVEL(ch) > 13 && rand_number(0, 10) == 0)
cast_spell(ch, vict, NULL, SPELL_POISON);
if (GET_LEVEL(ch) > 7 && rand_number(0, 8) == 0)
cast_spell(ch, vict, NULL, SPELL_BLINDNESS);
if (GET_LEVEL(ch) > 12 && rand_number(0, 12) == 0) {
if (IS_EVIL(ch))
cast_spell(ch, vict, NULL, SPELL_ENERGY_DRAIN);
else if (IS_GOOD(ch))
cast_spell(ch, vict, NULL, SPELL_DISPEL_EVIL);
}
if (rand_number(0, 4))
return (TRUE);
switch (GET_LEVEL(ch)) {
case 4:
case 5:
cast_spell(ch, vict, NULL, SPELL_MAGIC_MISSILE);
break;
case 6:
case 7:
cast_spell(ch, vict, NULL, SPELL_CHILL_TOUCH);
break;
case 8:
case 9:
cast_spell(ch, vict, NULL, SPELL_BURNING_HANDS);
break;
case 10:
case 11:
cast_spell(ch, vict, NULL, SPELL_SHOCKING_GRASP);
break;
case 12:
case 13:
cast_spell(ch, vict, NULL, SPELL_LIGHTNING_BOLT);
break;
case 14:
case 15:
case 16:
case 17:
cast_spell(ch, vict, NULL, SPELL_COLOR_SPRAY);
break;
default:
cast_spell(ch, vict, NULL, SPELL_FIREBALL);
break;
}
return (TRUE);
}
/* Special procedures for mobiles. */
SPECIAL(guild_guard)
{
int i, direction;
struct char_data *guard = (struct char_data *)me;
const char *buf = "The guard humiliates you, and blocks your way.\r\n";
const char *buf2 = "The guard humiliates $n, and blocks $s way.";
if (!IS_MOVE(cmd) || AFF_FLAGGED(guard, AFF_BLIND))
return (FALSE);
if (GET_LEVEL(ch) >= LVL_IMMORT)
return (FALSE);
/* find out what direction they are trying to go */
for (direction = 0; direction < NUM_OF_DIRS; direction++)
if (!strcmp(cmd_info[cmd].command, dirs[direction]))
break;
for (i = 0; guild_info[i].guild_room != NOWHERE; i++) {
/* Wrong guild. */
if (GET_ROOM_VNUM(IN_ROOM(ch)) != guild_info[i].guild_room)
continue;
/* Wrong direction. */
if (direction != guild_info[i].direction)
continue;
/* Allow the people of the guild through. */
if (!IS_NPC(ch) && GET_CLASS(ch) == guild_info[i].pc_class)
continue;
send_to_char(ch, "%s", buf);
act(buf2, FALSE, ch, 0, 0, TO_ROOM);
return (TRUE);
}
return (FALSE);
}
SPECIAL(puff)
{
char actbuf[MAX_INPUT_LENGTH];
if (cmd)
return (FALSE);
switch (rand_number(0, 60)) {
case 0:
do_say(ch, strcpy(actbuf, "My god! It's full of stars!"), 0, 0); /* strcpy: OK */
return (TRUE);
case 1:
do_say(ch, strcpy(actbuf, "How'd all those fish get up here?"), 0, 0); /* strcpy: OK */
return (TRUE);
case 2:
do_say(ch, strcpy(actbuf, "I'm a very female dragon."), 0, 0); /* strcpy: OK */
return (TRUE);
case 3:
do_say(ch, strcpy(actbuf, "I've got a peaceful, easy feeling."), 0, 0); /* strcpy: OK */
return (TRUE);
default:
return (FALSE);
}
}
SPECIAL(fido)
{
struct obj_data *i, *temp, *next_obj;
if (cmd || !AWAKE(ch))
return (FALSE);
for (i = world[IN_ROOM(ch)].contents; i; i = i->next_content) {
if (!IS_CORPSE(i))
continue;
act("$n savagely devours a corpse.", FALSE, ch, 0, 0, TO_ROOM);
for (temp = i->contains; temp; temp = next_obj) {
next_obj = temp->next_content;
obj_from_obj(temp);
obj_to_room(temp, IN_ROOM(ch));
}
extract_obj(i);
return (TRUE);
}
return (FALSE);
}
SPECIAL(janitor)
{
struct obj_data *i;
if (cmd || !AWAKE(ch))
return (FALSE);
for (i = world[IN_ROOM(ch)].contents; i; i = i->next_content) {
if (!CAN_WEAR(i, ITEM_WEAR_TAKE))
continue;
if (GET_OBJ_TYPE(i) != ITEM_DRINKCON && GET_OBJ_COST(i) >= 15)
continue;
act("$n picks up some trash.", FALSE, ch, 0, 0, TO_ROOM);
obj_from_room(i);
obj_to_char(i, ch);
return (TRUE);
}
return (FALSE);
}
SPECIAL(cityguard)
{
struct char_data *tch, *evil, *spittle;
int max_evil, min_cha;
if (cmd || !AWAKE(ch) || FIGHTING(ch))
return (FALSE);
max_evil = 1000;
min_cha = 6;
spittle = evil = NULL;
for (tch = world[IN_ROOM(ch)].people; tch; tch = tch->next_in_room) {
if (!CAN_SEE(ch, tch))
continue;
if (!IS_NPC(tch) && PLR_FLAGGED(tch, PLR_KILLER)) {
act("$n screams 'HEY!!! You're one of those PLAYER KILLERS!!!!!!'", FALSE, ch, 0, 0, TO_ROOM);
hit(ch, tch, TYPE_UNDEFINED);
return (TRUE);
}
if (!IS_NPC(tch) && PLR_FLAGGED(tch, PLR_THIEF)) {
act("$n screams 'HEY!!! You're one of those PLAYER THIEVES!!!!!!'", FALSE, ch, 0, 0, TO_ROOM);
hit(ch, tch, TYPE_UNDEFINED);
return (TRUE);
}
if (FIGHTING(tch) && GET_ALIGNMENT(tch) < max_evil && (IS_NPC(tch) || IS_NPC(FIGHTING(tch)))) {
max_evil = GET_ALIGNMENT(tch);
evil = tch;
}
if (GET_CHA(tch) < min_cha) {
spittle = tch;
min_cha = GET_CHA(tch);
}
}
if (evil && GET_ALIGNMENT(FIGHTING(evil)) >= 0) {
act("$n screams 'PROTECT THE INNOCENT! BANZAI! CHARGE! ARARARAGGGHH!'", FALSE, ch, 0, 0, TO_ROOM);
hit(ch, evil, TYPE_UNDEFINED);
return (TRUE);
}
/* Reward the socially inept. */
if (spittle && !rand_number(0, 9)) {
static int spit_social;
if (!spit_social)
spit_social = find_command("spit");
if (spit_social > 0) {
char spitbuf[MAX_NAME_LENGTH + 1];
strncpy(spitbuf, GET_NAME(spittle), sizeof(spitbuf)); /* strncpy: OK */
spitbuf[sizeof(spitbuf) - 1] = '\0';
do_action(ch, spitbuf, spit_social, 0);
return (TRUE);
}
}
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_AR(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);
}
/* Special procedures for objects. */
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);
}