2006-12-19 22:56:18 +00:00
|
|
|
/**************************************************************************
|
2007-04-08 10:36:36 +00:00
|
|
|
* File: dg_triggers.c part of tbaMUD *
|
|
|
|
|
* Usage: Contains all the trigger functions for scripts. *
|
2006-12-19 22:56:18 +00:00
|
|
|
* *
|
2007-04-08 10:36:36 +00:00
|
|
|
* All rights reserved. See license for complete information. *
|
2006-12-19 22:56:18 +00:00
|
|
|
* *
|
|
|
|
|
* Death's Gate MUD is based on CircleMUD, Copyright (C) 1993, 94. *
|
|
|
|
|
* CircleMUD is based on DikuMUD, Copyright (C) 1990, 1991. *
|
|
|
|
|
* *
|
|
|
|
|
* $Author: galion/Mark A. Heilpern/egreen/Welcor $ *
|
|
|
|
|
* $Date: 2004/10/11 12:07:00$ *
|
|
|
|
|
* $Revision: 1.0.14 $ *
|
|
|
|
|
**************************************************************************/
|
|
|
|
|
|
|
|
|
|
#include "conf.h"
|
|
|
|
|
#include "sysdep.h"
|
|
|
|
|
#include "structs.h"
|
|
|
|
|
#include "dg_scripts.h"
|
|
|
|
|
#include "utils.h"
|
|
|
|
|
#include "comm.h"
|
|
|
|
|
#include "interpreter.h"
|
|
|
|
|
#include "handler.h"
|
|
|
|
|
#include "db.h"
|
|
|
|
|
#include "oasis.h"
|
|
|
|
|
#include "constants.h"
|
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
|
|
|
#include "spells.h" /* for skill_name() */
|
|
|
|
|
#include "act.h" /* for cmd_door[] */
|
2006-12-19 22:56:18 +00:00
|
|
|
|
2007-04-08 10:36:36 +00:00
|
|
|
/* General functions used by several triggers. */
|
2006-12-19 22:56:18 +00:00
|
|
|
|
2007-04-08 10:36:36 +00:00
|
|
|
/* Copy first phrase into first_arg, returns rest of string. */
|
2006-12-19 22:56:18 +00:00
|
|
|
char *one_phrase(char *arg, char *first_arg)
|
|
|
|
|
{
|
|
|
|
|
skip_spaces(&arg);
|
|
|
|
|
|
|
|
|
|
if (!*arg)
|
|
|
|
|
*first_arg = '\0';
|
|
|
|
|
|
|
|
|
|
else if (*arg == '"')
|
|
|
|
|
{
|
|
|
|
|
char *p, c;
|
|
|
|
|
|
|
|
|
|
p = matching_quote(arg);
|
|
|
|
|
c = *p;
|
|
|
|
|
*p = '\0';
|
|
|
|
|
strcpy(first_arg, arg + 1);
|
|
|
|
|
if (c == '\0')
|
|
|
|
|
return p;
|
|
|
|
|
else
|
|
|
|
|
return p + 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
char *s, *p;
|
|
|
|
|
|
|
|
|
|
s = first_arg;
|
|
|
|
|
p = arg;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
while (*p && !isspace(*p) && *p != '"')
|
|
|
|
|
*s++ = *p++;
|
|
|
|
|
|
|
|
|
|
*s = '\0';
|
|
|
|
|
return p;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return arg;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int is_substring(char *sub, char *string)
|
|
|
|
|
{
|
|
|
|
|
char *s;
|
|
|
|
|
|
|
|
|
|
if ((s = str_str(string, sub)))
|
|
|
|
|
{
|
|
|
|
|
int len = strlen(string);
|
|
|
|
|
int sublen = strlen(sub);
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
/* check front */
|
|
|
|
|
if ((s == string || isspace(*(s - 1)) || ispunct(*(s - 1))) &&
|
|
|
|
|
|
|
|
|
|
/* check end */
|
|
|
|
|
((s + sublen == string + len) || isspace(s[sublen]) ||
|
|
|
|
|
ispunct(s[sublen])))
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2009-01-31 13:24:41 +00:00
|
|
|
/* Return 1 if str contains a word or phrase from wordlist. Phrases are in
|
|
|
|
|
* double quotes ("). if wrdlist is NULL, then return 1, if str is NULL,
|
2007-04-08 10:36:36 +00:00
|
|
|
* return 0. */
|
2006-12-19 22:56:18 +00:00
|
|
|
int word_check(char *str, char *wordlist)
|
|
|
|
|
{
|
|
|
|
|
char words[MAX_INPUT_LENGTH], phrase[MAX_INPUT_LENGTH], *s;
|
|
|
|
|
|
|
|
|
|
if (*wordlist=='*') return 1;
|
|
|
|
|
|
|
|
|
|
strcpy(words, wordlist);
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
for (s = one_phrase(words, phrase); *phrase; s = one_phrase(s, phrase))
|
|
|
|
|
if (is_substring(phrase, str))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-08 10:36:36 +00:00
|
|
|
/*Mob triggers. */
|
2006-12-19 22:56:18 +00:00
|
|
|
void random_mtrigger(char_data *ch)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
|
2007-04-08 10:36:36 +00:00
|
|
|
/* This trigger is only called if a char is in the zone without nohassle. */
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!SCRIPT_CHECK(ch, MTRIG_RANDOM) || AFF_FLAGGED(ch, AFF_CHARM))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
|
2007-01-23 03:07:23 +00:00
|
|
|
if (TRIGGER_CHECK(t, MTRIG_RANDOM) &&
|
2006-12-19 22:56:18 +00:00
|
|
|
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
|
|
|
|
script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void bribe_mtrigger(char_data *ch, char_data *actor, int amount)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!SCRIPT_CHECK(ch, MTRIG_BRIBE) || AFF_FLAGGED(ch, AFF_CHARM))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, MTRIG_BRIBE) && (amount >= GET_TRIG_NARG(t))) {
|
|
|
|
|
snprintf(buf, sizeof(buf), "%d", amount);
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "amount", buf, 0);
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void greet_memory_mtrigger(char_data *actor)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char_data *ch;
|
|
|
|
|
struct script_memory *mem;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
int command_performed = 0;
|
|
|
|
|
|
|
|
|
|
if (!valid_dg_target(actor, DG_ALLOW_GODS))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (ch = world[IN_ROOM(actor)].people; ch; ch = ch->next_in_room) {
|
2007-01-23 03:07:23 +00:00
|
|
|
if (!SCRIPT_MEM(ch) || !AWAKE(ch) || FIGHTING(ch) || (ch == actor) ||
|
2006-12-19 22:56:18 +00:00
|
|
|
AFF_FLAGGED(ch, AFF_CHARM))
|
|
|
|
|
continue;
|
|
|
|
|
/* find memory line with command only */
|
|
|
|
|
for (mem = SCRIPT_MEM(ch); mem && SCRIPT_MEM(ch); mem=mem->next) {
|
|
|
|
|
if (GET_ID(actor)!=mem->id) continue;
|
|
|
|
|
if (mem->cmd) {
|
|
|
|
|
command_interpreter(ch, mem->cmd); /* no script */
|
|
|
|
|
command_performed = 1;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
/* if a command was not performed execute the memory script */
|
|
|
|
|
if (mem && !command_performed) {
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
|
|
|
|
|
if (IS_SET(GET_TRIG_TYPE(t), MTRIG_MEMORY) &&
|
|
|
|
|
CAN_SEE(ch, actor) &&
|
|
|
|
|
!GET_TRIG_DEPTH(t) &&
|
|
|
|
|
rand_number(1, 100) <= GET_TRIG_NARG(t)) {
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* delete the memory */
|
|
|
|
|
if (mem) {
|
|
|
|
|
if (SCRIPT_MEM(ch)==mem) {
|
|
|
|
|
SCRIPT_MEM(ch) = mem->next;
|
|
|
|
|
} else {
|
|
|
|
|
struct script_memory *prev;
|
|
|
|
|
prev = SCRIPT_MEM(ch);
|
|
|
|
|
while (prev->next != mem) prev = prev->next;
|
|
|
|
|
prev->next = mem->next;
|
|
|
|
|
}
|
|
|
|
|
if (mem->cmd) free(mem->cmd);
|
|
|
|
|
free(mem);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int greet_mtrigger(char_data *actor, int dir)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char_data *ch;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
int intermediate, final=TRUE;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!valid_dg_target(actor, DG_ALLOW_GODS))
|
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
|
|
for (ch = world[IN_ROOM(actor)].people; ch; ch = ch->next_in_room) {
|
2007-01-23 03:07:23 +00:00
|
|
|
if (!SCRIPT_CHECK(ch, MTRIG_GREET | MTRIG_GREET_ALL) ||
|
|
|
|
|
!AWAKE(ch) || FIGHTING(ch) || (ch == actor) ||
|
2006-12-19 22:56:18 +00:00
|
|
|
AFF_FLAGGED(ch, AFF_CHARM))
|
|
|
|
|
continue;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
|
|
|
|
|
if (((IS_SET(GET_TRIG_TYPE(t), MTRIG_GREET) && CAN_SEE(ch, actor)) ||
|
2007-01-23 03:07:23 +00:00
|
|
|
IS_SET(GET_TRIG_TYPE(t), MTRIG_GREET_ALL)) &&
|
2006-12-19 22:56:18 +00:00
|
|
|
!GET_TRIG_DEPTH(t) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
|
|
|
|
if (dir>=0 && dir < NUM_OF_DIRS)
|
2008-05-07 23:34:40 +00:00
|
|
|
add_var(&GET_TRIG_VARS(t), "direction", dirs[rev_dir[dir]], 0);
|
2006-12-19 22:56:18 +00:00
|
|
|
else
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "direction", "none", 0);
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
intermediate = script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
|
|
|
|
|
if (!intermediate) final = FALSE;
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return final;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void entry_memory_mtrigger(char_data *ch)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char_data *actor;
|
|
|
|
|
struct script_memory *mem;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
|
|
|
|
|
if (!SCRIPT_MEM(ch) || AFF_FLAGGED(ch, AFF_CHARM))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (actor = world[IN_ROOM(ch)].people; actor && SCRIPT_MEM(ch);
|
|
|
|
|
actor = actor->next_in_room) {
|
|
|
|
|
if (actor!=ch && SCRIPT_MEM(ch)) {
|
|
|
|
|
for (mem = SCRIPT_MEM(ch); mem && SCRIPT_MEM(ch); mem = mem->next) {
|
|
|
|
|
if (GET_ID(actor)==mem->id) {
|
|
|
|
|
struct script_memory *prev;
|
|
|
|
|
if (mem->cmd) command_interpreter(ch, mem->cmd);
|
|
|
|
|
else {
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, MTRIG_MEMORY) && (rand_number(1, 100) <=
|
|
|
|
|
GET_TRIG_NARG(t))){
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* delete the memory */
|
|
|
|
|
if (SCRIPT_MEM(ch)==mem) {
|
|
|
|
|
SCRIPT_MEM(ch) = mem->next;
|
|
|
|
|
} else {
|
|
|
|
|
prev = SCRIPT_MEM(ch);
|
|
|
|
|
while (prev->next != mem) prev = prev->next;
|
|
|
|
|
prev->next = mem->next;
|
|
|
|
|
}
|
|
|
|
|
if (mem->cmd) free(mem->cmd);
|
|
|
|
|
free(mem);
|
|
|
|
|
}
|
|
|
|
|
} /* for (mem =..... */
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int entry_mtrigger(char_data *ch)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!SCRIPT_CHECK(ch, MTRIG_ENTRY) || AFF_FLAGGED(ch, AFF_CHARM))
|
|
|
|
|
return 1;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, MTRIG_ENTRY) && (rand_number(1, 100) <= GET_TRIG_NARG(t))){
|
|
|
|
|
return script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int command_mtrigger(char_data *actor, char *cmd, char *argument)
|
|
|
|
|
{
|
|
|
|
|
char_data *ch, *ch_next;
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
|
|
|
|
|
/* prevent people we like from becoming trapped :P */
|
|
|
|
|
if (!valid_dg_target(actor, 0))
|
|
|
|
|
return 0;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
for (ch = world[IN_ROOM(actor)].people; ch; ch = ch_next) {
|
|
|
|
|
ch_next = ch->next_in_room;
|
|
|
|
|
|
|
|
|
|
if (SCRIPT_CHECK(ch, MTRIG_COMMAND) && !AFF_FLAGGED(ch, AFF_CHARM) &&
|
2008-12-04 06:07:32 +00:00
|
|
|
((actor!=ch) || CONFIG_SCRIPT_PLAYERS)) {
|
2006-12-19 22:56:18 +00:00
|
|
|
for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
|
|
|
|
|
if (!TRIGGER_CHECK(t, MTRIG_COMMAND))
|
|
|
|
|
continue;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!GET_TRIG_ARG(t) || !*GET_TRIG_ARG(t)) {
|
|
|
|
|
mudlog(NRM, LVL_BUILDER, TRUE, "SYSERR: Command Trigger #%d has no text argument!",
|
|
|
|
|
GET_TRIG_VNUM(t));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (*GET_TRIG_ARG(t)=='*' ||
|
|
|
|
|
!strn_cmp(GET_TRIG_ARG(t), cmd, strlen(GET_TRIG_ARG(t)))) {
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
skip_spaces(&argument);
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "arg", argument, 0);
|
|
|
|
|
skip_spaces(&cmd);
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "cmd", cmd, 0);
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW))
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
void speech_mtrigger(char_data *actor, char *str)
|
|
|
|
|
{
|
|
|
|
|
char_data *ch, *ch_next;
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
|
|
|
|
|
for (ch = world[IN_ROOM(actor)].people; ch; ch = ch_next)
|
|
|
|
|
{
|
|
|
|
|
ch_next = ch->next_in_room;
|
|
|
|
|
|
|
|
|
|
if (SCRIPT_CHECK(ch, MTRIG_SPEECH) && AWAKE(ch) &&
|
2008-12-04 06:07:32 +00:00
|
|
|
!AFF_FLAGGED(ch, AFF_CHARM) && ((actor!=ch) || CONFIG_SCRIPT_PLAYERS))
|
2006-12-19 22:56:18 +00:00
|
|
|
for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
|
|
|
|
|
if (!TRIGGER_CHECK(t, MTRIG_SPEECH))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (!GET_TRIG_ARG(t) || !*GET_TRIG_ARG(t)) {
|
|
|
|
|
mudlog(NRM, LVL_BUILDER, TRUE, "SYSERR: Speech Trigger #%d has no text argument!",
|
|
|
|
|
GET_TRIG_VNUM(t));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (((GET_TRIG_NARG(t) && word_check(str, GET_TRIG_ARG(t))) ||
|
|
|
|
|
(!GET_TRIG_NARG(t) && is_substring(GET_TRIG_ARG(t), str)))) {
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "speech", str, 0);
|
|
|
|
|
script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-01-23 03:07:23 +00:00
|
|
|
void act_mtrigger(const char_data *ch, char *str, char_data *actor,
|
2006-12-19 22:56:18 +00:00
|
|
|
char_data *victim, obj_data *object,
|
|
|
|
|
obj_data *target, char *arg)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (SCRIPT_CHECK(ch, MTRIG_ACT) && !AFF_FLAGGED(ch, AFF_CHARM) &&
|
|
|
|
|
(actor!=ch))
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
|
|
|
|
|
if (!TRIGGER_CHECK(t, MTRIG_ACT))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (!GET_TRIG_ARG(t) || !*GET_TRIG_ARG(t)) {
|
|
|
|
|
mudlog(NRM, LVL_BUILDER, TRUE, "SYSERR: Act Trigger #%d has no text argument!",
|
|
|
|
|
GET_TRIG_VNUM(t));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (((GET_TRIG_NARG(t) && word_check(str, GET_TRIG_ARG(t))) ||
|
|
|
|
|
(!GET_TRIG_NARG(t) && is_substring(GET_TRIG_ARG(t), str)))) {
|
|
|
|
|
if (actor)
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
if (victim)
|
|
|
|
|
ADD_UID_VAR(buf, t, victim, "victim", 0);
|
|
|
|
|
if (object)
|
|
|
|
|
ADD_UID_VAR(buf, t, object, "object", 0);
|
|
|
|
|
if (target)
|
|
|
|
|
ADD_UID_VAR(buf, t, target, "target", 0);
|
|
|
|
|
if (str) {
|
|
|
|
|
/* we're guaranteed to have a string ending with \r\n\0 */
|
|
|
|
|
char *nstr = strdup(str), *fstr = nstr, *p = strchr(nstr, '\r');
|
|
|
|
|
skip_spaces(&nstr);
|
|
|
|
|
*p = '\0';
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "arg", nstr, 0);
|
|
|
|
|
free(fstr);
|
2007-01-23 03:07:23 +00:00
|
|
|
}
|
2006-12-19 22:56:18 +00:00
|
|
|
script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
|
|
|
|
|
break;
|
2007-01-23 03:07:23 +00:00
|
|
|
}
|
2006-12-19 22:56:18 +00:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void fight_mtrigger(char_data *ch)
|
|
|
|
|
{
|
|
|
|
|
struct char_data *actor;
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
2007-01-23 03:07:23 +00:00
|
|
|
|
|
|
|
|
if (!SCRIPT_CHECK(ch, MTRIG_FIGHT) || !FIGHTING(ch) ||
|
2006-12-19 22:56:18 +00:00
|
|
|
AFF_FLAGGED(ch, AFF_CHARM))
|
|
|
|
|
return;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, MTRIG_FIGHT) &&
|
|
|
|
|
(rand_number(1, 100) <= GET_TRIG_NARG(t))){
|
|
|
|
|
actor = FIGHTING(ch);
|
|
|
|
|
if (actor)
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
else
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "actor", "nobody", 0);
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void hitprcnt_mtrigger(char_data *ch)
|
|
|
|
|
{
|
|
|
|
|
struct char_data *actor;
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!SCRIPT_CHECK(ch, MTRIG_HITPRCNT) || !FIGHTING(ch) ||
|
|
|
|
|
AFF_FLAGGED(ch, AFF_CHARM))
|
|
|
|
|
return;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, MTRIG_HITPRCNT) && GET_MAX_HIT(ch) &&
|
|
|
|
|
(((GET_HIT(ch) * 100) / GET_MAX_HIT(ch)) <= GET_TRIG_NARG(t))) {
|
|
|
|
|
|
|
|
|
|
actor = FIGHTING(ch);
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int receive_mtrigger(char_data *ch, char_data *actor, obj_data *obj)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
int ret_val;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!SCRIPT_CHECK(ch, MTRIG_RECEIVE) || AFF_FLAGGED(ch, AFF_CHARM))
|
|
|
|
|
return 1;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, MTRIG_RECEIVE) &&
|
|
|
|
|
(rand_number(1, 100) <= GET_TRIG_NARG(t))){
|
|
|
|
|
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
ADD_UID_VAR(buf, t, obj, "object", 0);
|
|
|
|
|
ret_val = script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
|
|
|
|
|
if (DEAD(actor) || DEAD(ch) || obj->carried_by != actor)
|
|
|
|
|
return 0;
|
|
|
|
|
else
|
|
|
|
|
return ret_val;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int death_mtrigger(char_data *ch, char_data *actor)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!SCRIPT_CHECK(ch, MTRIG_DEATH) || AFF_FLAGGED(ch, AFF_CHARM))
|
|
|
|
|
return 1;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, MTRIG_DEATH) &&
|
|
|
|
|
(rand_number(1, 100) <= GET_TRIG_NARG(t))){
|
|
|
|
|
if (actor)
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
return script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void load_mtrigger(char_data *ch)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
int result = 0;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!SCRIPT_CHECK(ch, MTRIG_LOAD))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
|
2007-01-23 03:07:23 +00:00
|
|
|
if (TRIGGER_CHECK(t, MTRIG_LOAD) &&
|
2006-12-19 22:56:18 +00:00
|
|
|
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
|
|
|
|
result = script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (result == SCRIPT_ERROR_CODE) {
|
|
|
|
|
/* we have recursed beyond reasonable depth */
|
|
|
|
|
/* make sure this mob is the last one in the load chain */
|
|
|
|
|
if (GET_MOB_RNUM(ch) != NOBODY) {
|
|
|
|
|
free_proto_script(&mob_proto[GET_MOB_RNUM(ch)], MOB_TRIGGER);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int cast_mtrigger(char_data *actor, char_data *ch, int spellnum)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
|
|
|
|
|
if (ch == NULL)
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
if (!SCRIPT_CHECK(ch, MTRIG_CAST) || AFF_FLAGGED(ch, AFF_CHARM))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, MTRIG_CAST) &&
|
|
|
|
|
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
sprintf(buf, "%d", spellnum);
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "spell", buf, 0);
|
2008-05-07 23:34:40 +00:00
|
|
|
add_var(&GET_TRIG_VARS(t), "spellname", skill_name(spellnum), 0);
|
2006-12-19 22:56:18 +00:00
|
|
|
return script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int leave_mtrigger(char_data *actor, int dir)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char_data *ch;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
|
|
|
|
|
if (!valid_dg_target(actor, DG_ALLOW_GODS))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
for (ch = world[IN_ROOM(actor)].people; ch; ch = ch->next_in_room) {
|
|
|
|
|
if (!SCRIPT_CHECK(ch, MTRIG_LEAVE) ||
|
|
|
|
|
!AWAKE(ch) || FIGHTING(ch) || (ch == actor) ||
|
|
|
|
|
AFF_FLAGGED(ch, AFF_CHARM))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
|
|
|
|
|
if ((IS_SET(GET_TRIG_TYPE(t), MTRIG_LEAVE) && CAN_SEE(ch, actor)) &&
|
|
|
|
|
!GET_TRIG_DEPTH(t) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
|
|
|
|
if (dir>=0 && dir < NUM_OF_DIRS)
|
2008-05-07 23:34:40 +00:00
|
|
|
add_var(&GET_TRIG_VARS(t), "direction", dirs[dir], 0);
|
2006-12-19 22:56:18 +00:00
|
|
|
else
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "direction", "none", 0);
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
return script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int door_mtrigger(char_data *actor, int subcmd, int dir)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char_data *ch;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
|
|
|
|
|
for (ch = world[IN_ROOM(actor)].people; ch; ch = ch->next_in_room) {
|
|
|
|
|
if (!SCRIPT_CHECK(ch, MTRIG_DOOR) ||
|
|
|
|
|
!AWAKE(ch) || FIGHTING(ch) || (ch == actor) ||
|
|
|
|
|
AFF_FLAGGED(ch, AFF_CHARM))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
|
|
|
|
|
if (IS_SET(GET_TRIG_TYPE(t), MTRIG_DOOR) && CAN_SEE(ch, actor) &&
|
|
|
|
|
!GET_TRIG_DEPTH(t) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
2008-05-07 23:34:40 +00:00
|
|
|
add_var(&GET_TRIG_VARS(t), "cmd", cmd_door[subcmd], 0);
|
2006-12-19 22:56:18 +00:00
|
|
|
if (dir>=0 && dir < NUM_OF_DIRS)
|
2008-05-07 23:34:40 +00:00
|
|
|
add_var(&GET_TRIG_VARS(t), "direction", dirs[dir], 0);
|
2006-12-19 22:56:18 +00:00
|
|
|
else
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "direction", "none", 0);
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
return script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void time_mtrigger(char_data *ch)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
|
2007-04-08 10:36:36 +00:00
|
|
|
/* This trigger is called if the hour is the same as specified in Narg. */
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!SCRIPT_CHECK(ch, MTRIG_TIME) || AFF_FLAGGED(ch, AFF_CHARM))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(ch)); t; t = t->next) {
|
2007-01-23 03:07:23 +00:00
|
|
|
if (TRIGGER_CHECK(t, MTRIG_TIME) &&
|
2006-12-19 22:56:18 +00:00
|
|
|
(time_info.hours == GET_TRIG_NARG(t))) {
|
|
|
|
|
sprintf(buf, "%d", time_info.hours);
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "time", buf, 0);
|
|
|
|
|
script_driver(&ch, t, MOB_TRIGGER, TRIG_NEW);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-08 10:36:36 +00:00
|
|
|
/* Object triggers. */
|
2006-12-19 22:56:18 +00:00
|
|
|
void random_otrigger(obj_data *obj)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
|
|
|
|
|
if (!SCRIPT_CHECK(obj, OTRIG_RANDOM))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) {
|
2007-01-23 03:07:23 +00:00
|
|
|
if (TRIGGER_CHECK(t, OTRIG_RANDOM) &&
|
2006-12-19 22:56:18 +00:00
|
|
|
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
|
|
|
|
script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void timer_otrigger(struct obj_data *obj)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!SCRIPT_CHECK(obj, OTRIG_TIMER))
|
|
|
|
|
return;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, OTRIG_TIMER)) {
|
|
|
|
|
script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW);
|
|
|
|
|
}
|
2007-01-23 03:07:23 +00:00
|
|
|
}
|
|
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int get_otrigger(obj_data *obj, char_data *actor)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
int ret_val;
|
|
|
|
|
if (!SCRIPT_CHECK(obj, OTRIG_GET))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, OTRIG_GET) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
ret_val = script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW);
|
2009-01-31 13:24:41 +00:00
|
|
|
/* Don't allow a get to take place, if the actor is killed (the mud
|
2007-04-14 00:44:52 +00:00
|
|
|
* would choke on obj_to_char) or the object is purged. */
|
2006-12-19 22:56:18 +00:00
|
|
|
if (DEAD(actor) || !obj)
|
|
|
|
|
return 0;
|
|
|
|
|
else
|
|
|
|
|
return ret_val;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* checks for command trigger on specific object. assumes obj has cmd trig */
|
|
|
|
|
int cmd_otrig(obj_data *obj, char_data *actor, char *cmd,
|
|
|
|
|
char *argument, int type)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (obj && SCRIPT_CHECK(obj, OTRIG_COMMAND))
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) {
|
|
|
|
|
if (!TRIGGER_CHECK(t, OTRIG_COMMAND))
|
|
|
|
|
continue;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (IS_SET(GET_TRIG_NARG(t), type) &&
|
|
|
|
|
(!GET_TRIG_ARG(t) || !*GET_TRIG_ARG(t))) {
|
|
|
|
|
mudlog(NRM, LVL_BUILDER, TRUE, "SYSERR: O-Command Trigger #%d has no text argument!",
|
|
|
|
|
GET_TRIG_VNUM(t));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (IS_SET(GET_TRIG_NARG(t), type) &&
|
|
|
|
|
(*GET_TRIG_ARG(t)=='*' ||
|
|
|
|
|
!strn_cmp(GET_TRIG_ARG(t), cmd, strlen(GET_TRIG_ARG(t))))) {
|
|
|
|
|
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
skip_spaces(&argument);
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "arg", argument, 0);
|
|
|
|
|
skip_spaces(&cmd);
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "cmd", cmd, 0);
|
|
|
|
|
|
|
|
|
|
if (script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW))
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int command_otrigger(char_data *actor, char *cmd, char *argument)
|
|
|
|
|
{
|
|
|
|
|
obj_data *obj;
|
|
|
|
|
int i;
|
|
|
|
|
|
|
|
|
|
/* prevent people we like from becoming trapped :P */
|
|
|
|
|
if (!valid_dg_target(actor, 0))
|
|
|
|
|
return 0;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
for (i = 0; i < NUM_WEARS; i++)
|
|
|
|
|
if (GET_EQ(actor, i))
|
|
|
|
|
if (cmd_otrig(GET_EQ(actor, i), actor, cmd, argument, OCMD_EQUIP))
|
|
|
|
|
return 1;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
for (obj = actor->carrying; obj; obj = obj->next_content)
|
|
|
|
|
if (cmd_otrig(obj, actor, cmd, argument, OCMD_INVEN))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
for (obj = world[IN_ROOM(actor)].contents; obj; obj = obj->next_content)
|
|
|
|
|
if (cmd_otrig(obj, actor, cmd, argument, OCMD_ROOM))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int wear_otrigger(obj_data *obj, char_data *actor, int where)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
int ret_val;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!SCRIPT_CHECK(obj, OTRIG_WEAR))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, OTRIG_WEAR)) {
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
ret_val = script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW);
|
2007-04-14 00:44:52 +00:00
|
|
|
/* Don't allow a wear to take place, if the object is purged. */
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!obj)
|
|
|
|
|
return 0;
|
|
|
|
|
else
|
|
|
|
|
return ret_val;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int remove_otrigger(obj_data *obj, char_data *actor)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
int ret_val;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!SCRIPT_CHECK(obj, OTRIG_REMOVE))
|
|
|
|
|
return 1;
|
|
|
|
|
|
2007-05-17 20:51:06 +00:00
|
|
|
if (!valid_dg_target(actor, 0))
|
|
|
|
|
return 1;
|
|
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, OTRIG_REMOVE)) {
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
ret_val = script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW);
|
2007-04-14 00:44:52 +00:00
|
|
|
/* Don't allow a remove to take place, if the object is purged. */
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!obj)
|
|
|
|
|
return 0;
|
|
|
|
|
else
|
|
|
|
|
return ret_val;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int drop_otrigger(obj_data *obj, char_data *actor)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
int ret_val;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!SCRIPT_CHECK(obj, OTRIG_DROP))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, OTRIG_DROP) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
ret_val = script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW);
|
2007-04-14 00:44:52 +00:00
|
|
|
/* Don't allow a drop to take place, if the object is purged. */
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!obj)
|
|
|
|
|
return 0;
|
|
|
|
|
else
|
|
|
|
|
return ret_val;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int give_otrigger(obj_data *obj, char_data *actor, char_data *victim)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
int ret_val;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!SCRIPT_CHECK(obj, OTRIG_GIVE))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, OTRIG_GIVE) && (rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
ADD_UID_VAR(buf, t, victim, "victim", 0);
|
|
|
|
|
ret_val = script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW);
|
2009-01-31 13:24:41 +00:00
|
|
|
/* Don't allow a give to take place, if the object is purged or the
|
2007-04-14 00:44:52 +00:00
|
|
|
* object is not carried by the giver. */
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!obj || obj->carried_by != actor)
|
|
|
|
|
return 0;
|
|
|
|
|
else
|
|
|
|
|
return ret_val;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void load_otrigger(obj_data *obj)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
int result = 0;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!SCRIPT_CHECK(obj, OTRIG_LOAD))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) {
|
2007-01-23 03:07:23 +00:00
|
|
|
if (TRIGGER_CHECK(t, OTRIG_LOAD) &&
|
2006-12-19 22:56:18 +00:00
|
|
|
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
|
|
|
|
result = script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (result == SCRIPT_ERROR_CODE) {
|
|
|
|
|
/* we have recursed beyond reasonable depth */
|
|
|
|
|
/* make sure this mob is the last one in the load chain */
|
|
|
|
|
if (GET_OBJ_RNUM(obj) != NOTHING) {
|
|
|
|
|
free_proto_script(&obj_proto[GET_OBJ_RNUM(obj)], OBJ_TRIGGER);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int cast_otrigger(char_data *actor, obj_data *obj, int spellnum)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
|
|
|
|
|
if (obj == NULL)
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
if (!SCRIPT_CHECK(obj, OTRIG_CAST))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, OTRIG_CAST) &&
|
|
|
|
|
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
sprintf(buf, "%d", spellnum);
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "spell", buf, 0);
|
2008-05-07 23:34:40 +00:00
|
|
|
add_var(&GET_TRIG_VARS(t), "spellname", skill_name(spellnum), 0);
|
2006-12-19 22:56:18 +00:00
|
|
|
return script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int leave_otrigger(room_data *room, char_data *actor, int dir)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
int temp, final = 1;
|
|
|
|
|
obj_data *obj, *obj_next;
|
|
|
|
|
|
|
|
|
|
if (!valid_dg_target(actor, DG_ALLOW_GODS))
|
|
|
|
|
return 1;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
for (obj = room->contents; obj; obj = obj_next) {
|
|
|
|
|
obj_next = obj->next_content;
|
|
|
|
|
if (!SCRIPT_CHECK(obj, OTRIG_LEAVE))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, OTRIG_LEAVE) &&
|
|
|
|
|
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
|
|
|
|
if (dir>=0 && dir < NUM_OF_DIRS)
|
2008-05-07 23:34:40 +00:00
|
|
|
add_var(&GET_TRIG_VARS(t), "direction", dirs[dir], 0);
|
2006-12-19 22:56:18 +00:00
|
|
|
else
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "direction", "none", 0);
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
temp = script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW);
|
|
|
|
|
if (temp == 0)
|
|
|
|
|
final = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
return final;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int consume_otrigger(obj_data *obj, char_data *actor, int cmd)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
int ret_val;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!SCRIPT_CHECK(obj, OTRIG_CONSUME))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, OTRIG_CONSUME)) {
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
switch (cmd) {
|
|
|
|
|
case OCMD_EAT:
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "command", "eat", 0);
|
|
|
|
|
break;
|
|
|
|
|
case OCMD_DRINK:
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "command", "drink", 0);
|
|
|
|
|
break;
|
|
|
|
|
case OCMD_QUAFF:
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "command", "quaff", 0);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
ret_val = script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW);
|
2007-04-14 00:44:52 +00:00
|
|
|
/* Don't allow a wear to take place, if the object is purged. */
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!obj)
|
|
|
|
|
return 0;
|
|
|
|
|
else
|
|
|
|
|
return ret_val;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void time_otrigger(obj_data *obj)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
|
|
|
|
|
if (!SCRIPT_CHECK(obj, OTRIG_TIME))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(obj)); t; t = t->next) {
|
2007-01-23 03:07:23 +00:00
|
|
|
if (TRIGGER_CHECK(t, OTRIG_TIME) &&
|
2006-12-19 22:56:18 +00:00
|
|
|
(time_info.hours == GET_TRIG_NARG(t))) {
|
|
|
|
|
sprintf(buf, "%d", time_info.hours);
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "time", buf, 0);
|
|
|
|
|
script_driver(&obj, t, OBJ_TRIGGER, TRIG_NEW);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2007-04-08 10:36:36 +00:00
|
|
|
/* World triggers. */
|
2006-12-19 22:56:18 +00:00
|
|
|
void reset_wtrigger(struct room_data *room)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
|
|
|
|
|
if (!SCRIPT_CHECK(room, WTRIG_RESET))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, WTRIG_RESET) &&
|
|
|
|
|
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
|
|
|
|
script_driver(&room, t, WLD_TRIGGER, TRIG_NEW);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void random_wtrigger(struct room_data *room)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
|
|
|
|
|
if (!SCRIPT_CHECK(room, WTRIG_RANDOM))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, WTRIG_RANDOM) &&
|
|
|
|
|
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
|
|
|
|
script_driver(&room, t, WLD_TRIGGER, TRIG_NEW);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int enter_wtrigger(struct room_data *room, char_data *actor, int dir)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
|
|
|
|
|
if (!SCRIPT_CHECK(room, WTRIG_ENTER))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) {
|
2007-01-23 03:07:23 +00:00
|
|
|
if (TRIGGER_CHECK(t, WTRIG_ENTER) &&
|
2006-12-19 22:56:18 +00:00
|
|
|
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
|
|
|
|
if (dir>=0 && dir < NUM_OF_DIRS)
|
2008-05-07 23:34:40 +00:00
|
|
|
add_var(&GET_TRIG_VARS(t), "direction", dirs[rev_dir[dir]], 0);
|
2006-12-19 22:56:18 +00:00
|
|
|
else
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "direction", "none", 0);
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
return script_driver(&room, t, WLD_TRIGGER, TRIG_NEW);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int command_wtrigger(char_data *actor, char *cmd, char *argument)
|
|
|
|
|
{
|
|
|
|
|
struct room_data *room;
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
|
|
|
|
|
if (!actor || !SCRIPT_CHECK(&world[IN_ROOM(actor)], WTRIG_COMMAND))
|
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
|
|
/* prevent people we like from becoming trapped :P */
|
|
|
|
|
if (!valid_dg_target(actor, 0))
|
|
|
|
|
return 0;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
room = &world[IN_ROOM(actor)];
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) {
|
|
|
|
|
if (!TRIGGER_CHECK(t, WTRIG_COMMAND))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (!GET_TRIG_ARG(t) || !*GET_TRIG_ARG(t)) {
|
|
|
|
|
mudlog(NRM, LVL_BUILDER, TRUE, "SYSERR: W-Command Trigger #%d has no text argument!",
|
|
|
|
|
GET_TRIG_VNUM(t));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (*GET_TRIG_ARG(t)=='*' ||
|
|
|
|
|
!strn_cmp(GET_TRIG_ARG(t), cmd, strlen(GET_TRIG_ARG(t)))) {
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
skip_spaces(&argument);
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "arg", argument, 0);
|
|
|
|
|
skip_spaces(&cmd);
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "cmd", cmd, 0);
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
return script_driver(&room, t, WLD_TRIGGER, TRIG_NEW);
|
|
|
|
|
}
|
|
|
|
|
}
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void speech_wtrigger(char_data *actor, char *str)
|
|
|
|
|
{
|
|
|
|
|
struct room_data *room;
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
|
|
|
|
|
if (!actor || !SCRIPT_CHECK(&world[IN_ROOM(actor)], WTRIG_SPEECH))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
room = &world[IN_ROOM(actor)];
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) {
|
|
|
|
|
if (!TRIGGER_CHECK(t, WTRIG_SPEECH))
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
|
|
if (!GET_TRIG_ARG(t) || !*GET_TRIG_ARG(t)) {
|
|
|
|
|
mudlog(NRM, LVL_BUILDER, TRUE, "SYSERR: W-Speech Trigger #%d has no text argument!",
|
|
|
|
|
GET_TRIG_VNUM(t));
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (*GET_TRIG_ARG(t)=='*' ||
|
|
|
|
|
(GET_TRIG_NARG(t) && word_check(str, GET_TRIG_ARG(t))) ||
|
|
|
|
|
(!GET_TRIG_NARG(t) && is_substring(GET_TRIG_ARG(t), str))) {
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "speech", str, 0);
|
|
|
|
|
script_driver(&room, t, WLD_TRIGGER, TRIG_NEW);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int drop_wtrigger(obj_data *obj, char_data *actor)
|
|
|
|
|
{
|
|
|
|
|
struct room_data *room;
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
int ret_val;
|
2007-01-23 03:07:23 +00:00
|
|
|
|
2006-12-19 22:56:18 +00:00
|
|
|
if (!actor || !SCRIPT_CHECK(&world[IN_ROOM(actor)], WTRIG_DROP))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
room = &world[IN_ROOM(actor)];
|
2007-01-23 03:07:23 +00:00
|
|
|
for (t = TRIGGERS(SCRIPT(room)); t; t = t->next)
|
2006-12-19 22:56:18 +00:00
|
|
|
if (TRIGGER_CHECK(t, WTRIG_DROP) &&
|
2007-01-23 03:07:23 +00:00
|
|
|
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
2006-12-19 22:56:18 +00:00
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
ADD_UID_VAR(buf, t, obj, "object", 0);
|
|
|
|
|
ret_val = script_driver(&room, t, WLD_TRIGGER, TRIG_NEW);
|
|
|
|
|
if (obj->carried_by != actor)
|
|
|
|
|
return 0;
|
|
|
|
|
else
|
|
|
|
|
return ret_val;
|
|
|
|
|
break;
|
2007-01-23 03:07:23 +00:00
|
|
|
}
|
2006-12-19 22:56:18 +00:00
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int cast_wtrigger(char_data *actor, char_data *vict, obj_data *obj, int spellnum)
|
|
|
|
|
{
|
|
|
|
|
room_data *room;
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
|
|
|
|
|
if (!actor || !SCRIPT_CHECK(&world[IN_ROOM(actor)], WTRIG_CAST))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
room = &world[IN_ROOM(actor)];
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, WTRIG_CAST) &&
|
|
|
|
|
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
|
|
|
|
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
if (vict)
|
|
|
|
|
ADD_UID_VAR(buf, t, vict, "victim", 0);
|
|
|
|
|
if (obj)
|
|
|
|
|
ADD_UID_VAR(buf, t, obj, "object", 0);
|
|
|
|
|
sprintf(buf, "%d", spellnum);
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "spell", buf, 0);
|
2008-05-07 23:34:40 +00:00
|
|
|
add_var(&GET_TRIG_VARS(t), "spellname", skill_name(spellnum), 0);
|
2006-12-19 22:56:18 +00:00
|
|
|
return script_driver(&room, t, WLD_TRIGGER, TRIG_NEW);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int leave_wtrigger(struct room_data *room, char_data *actor, int dir)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
|
|
|
|
|
if (!valid_dg_target(actor, DG_ALLOW_GODS))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
if (!SCRIPT_CHECK(room, WTRIG_LEAVE))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, WTRIG_LEAVE) &&
|
|
|
|
|
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
|
|
|
|
if (dir>=0 && dir < NUM_OF_DIRS)
|
2008-05-07 23:34:40 +00:00
|
|
|
add_var(&GET_TRIG_VARS(t), "direction", dirs[dir], 0);
|
2006-12-19 22:56:18 +00:00
|
|
|
else
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "direction", "none", 0);
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
return script_driver(&room, t, WLD_TRIGGER, TRIG_NEW);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
int door_wtrigger(char_data *actor, int subcmd, int dir)
|
|
|
|
|
{
|
|
|
|
|
room_data *room;
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
|
|
|
|
|
if (!actor || !SCRIPT_CHECK(&world[IN_ROOM(actor)], WTRIG_DOOR))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
room = &world[IN_ROOM(actor)];
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, WTRIG_DOOR) &&
|
|
|
|
|
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
2008-05-07 23:34:40 +00:00
|
|
|
add_var(&GET_TRIG_VARS(t), "cmd", cmd_door[subcmd], 0);
|
2006-12-19 22:56:18 +00:00
|
|
|
if (dir>=0 && dir < NUM_OF_DIRS)
|
2008-05-07 23:34:40 +00:00
|
|
|
add_var(&GET_TRIG_VARS(t), "direction", dirs[dir], 0);
|
2006-12-19 22:56:18 +00:00
|
|
|
else
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "direction", "none", 0);
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
return script_driver(&room, t, WLD_TRIGGER, TRIG_NEW);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void time_wtrigger(struct room_data *room)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
|
|
|
|
|
if (!SCRIPT_CHECK(room, WTRIG_TIME))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, WTRIG_TIME) &&
|
|
|
|
|
(time_info.hours == GET_TRIG_NARG(t))) {
|
|
|
|
|
sprintf(buf, "%d", time_info.hours);
|
|
|
|
|
add_var(&GET_TRIG_VARS(t), "time", buf, 0);
|
|
|
|
|
script_driver(&room, t, WLD_TRIGGER, TRIG_NEW);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2009-01-31 13:24:41 +00:00
|
|
|
|
|
|
|
|
int login_wtrigger(struct room_data *room, char_data *actor)
|
|
|
|
|
{
|
|
|
|
|
trig_data *t;
|
|
|
|
|
char buf[MAX_INPUT_LENGTH];
|
|
|
|
|
|
|
|
|
|
if (!SCRIPT_CHECK(room, WTRIG_LOGIN))
|
|
|
|
|
return 1;
|
|
|
|
|
|
|
|
|
|
for (t = TRIGGERS(SCRIPT(room)); t; t = t->next) {
|
|
|
|
|
if (TRIGGER_CHECK(t, WTRIG_LOGIN) &&
|
|
|
|
|
(rand_number(1, 100) <= GET_TRIG_NARG(t))) {
|
|
|
|
|
ADD_UID_VAR(buf, t, actor, "actor", 0);
|
|
|
|
|
return script_driver(&room, t, WLD_TRIGGER, TRIG_NEW);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
|
}
|