SKILLS.CPP
SmaugWizard/Src/SKILLS.CPP · 194.4 KB
From the archive SmaugWiz203.zip
Download the archive « Back to the archive contents
/****************************************************************************
* [S]imulated [M]edieval [A]dventure multi[U]ser [G]ame | *
* -----------------------------------------------------------| \\._.// *
* SmaugWiz (C) 1998 by Russ Pillsbury (Windows NT version) | (0...0) *
* -----------------------------------------------------------| ).:.( *
* SMAUG (C) 1994, 1995, 1996 by Derek Snider | {o o} *
* -----------------------------------------------------------| / ' ' \ *
* SMAUG code team: Thoric, Altrag, Blodkai, Narn, Haus, |~'~.VxvxV.~'~*
* Scryn, Swordbearer, Rennard, Tricops, and Gorog. | *
* ------------------------------------------------------------------------ *
* Merc 2.1 Diku Mud improvments copyright (C) 1992, 1993 by Michael *
* Chastain, Michael Quan, and Mitchell Tse. *
* Original Diku Mud copyright (C) 1990, 1991 by Sebastian Hammer, *
* Michael Seifert, Hans Henrik Staerfeldt, Tom Madsen, and Katja Nyboe. *
* ------------------------------------------------------------------------ *
* Player skills module *
****************************************************************************/
#include "stdafx.h"
#include "smaug.h"
#include "SysData.h"
#include "area.h"
#include "skill.h"
#include "mobiles.h"
#include "objects.h"
#include "rooms.h"
#include "deity.h"
#include "races.h"
#include "class.h"
#include "Exits.h"
#include "character.h"
#include "SmaugWizDoc.h"
char * const spell_flag[] =
{ "water", "earth", "air", "astral", "area", "distant", "reverse",
"noself", "_unused2_", "accumulative", "recastable", "noscribe",
"nobrew", "group", "object", "character", "secretskill", "pksensitive",
"stoponfail", "nofight", "nodispel", "r1", "r2", "r3", "r4", "r5", "r6",
"r7", "r8", "r9", "r10", "r11"
};
char * const spell_saves[] =
{ "none", "poison_death", "wands", "para_petri", "breath", "spell_staff" };
char * const spell_damage[] =
{ "none", "fire", "cold", "electricity", "energy", "acid", "poison", "drain" };
char * const spell_action[] =
{ "none", "create", "destroy", "resist", "suscept", "divinate", "obscure",
"change" };
char * const spell_power[] =
{ "none", "minor", "greater", "major" };
char * const spell_class[] =
{ "none", "lunar", "solar", "travel", "summon", "life", "death", "illusion" };
char * const target_type[] =
{ "ignore", "offensive", "defensive", "self", "objinv" };
int ris_save (CCharacter *ch, int chance, int ris);
BOOL check_illegal_psteal (CCharacter *ch, CCharacter *victim);
BOOL can_use_skill (CCharacter* ch, int percent, int gsn);
char *myobj (CObjData *obj);
void SkillHelp (CCharacter* ch);
ch_ret ranged_got_target (CCharacter *ch, CCharacter *victim,
CObjData *weapon, CObjData *projectile,
short dist, short dt, char *stxt, short color);
CObjData *find_projectile (CCharacter* ch, int type);
// Dummy function
void skill_notfound (CCharacter *ch, char *argument)
{
ch->SendText ("Huh?\n\r");
return;
}
int get_ssave (char *name)
{
int x;
for (x = 0; x < DIM (spell_saves); x++)
if (!str_cmp (name, spell_saves[x]))
return x;
return -1;
}
int get_starget (char *name)
{
int x;
for (x = 0; x < DIM (target_type); x++)
if (!str_cmp (name, target_type[x]))
return x;
return -1;
}
int get_sflag (char *name)
{
int x;
for (x = 0; x < DIM (spell_flag); x++)
if (!str_cmp (name, spell_flag[x]))
return x;
return -1;
}
int get_sdamage (char *name)
{
int x;
for (x = 0; x < DIM (spell_damage); x++)
if (!str_cmp (name, spell_damage[x]))
return x;
return -1;
}
int get_saction (char *name)
{
int x;
for (x = 0; x < DIM (spell_action); x++)
if (!str_cmp (name, spell_action[x]))
return x;
return -1;
}
int get_spower (char *name)
{
int x;
for (x = 0; x < DIM (spell_power); x++)
if (!str_cmp (name, spell_power[x]))
return x;
return -1;
}
int get_sclass (char *name)
{
int x;
for (x = 0; x < DIM (spell_class); x++)
if (!str_cmp (name, spell_class[x]))
return x;
return -1;
}
BOOL is_legal_kill (CCharacter *ch, CCharacter *vch)
{
if (ch->IsNpc () || vch->IsNpc ())
return TRUE;
if (!ch->IsPkiller () || !vch->IsPkiller ())
return FALSE;
if (ch->GetPcData ()->GetClan () && ch->GetPcData ()->GetClan () == vch->GetPcData ()->GetClan ())
return FALSE;
return TRUE;
}
extern char *target_name; /* from magic.c */
// Perform a binary search on a section of the skill table
// Each different section of the skill table is sorted alphabetically
// Only match skills player knows -Thoric
BOOL check_skill (CCharacter *ch, char *command, char *argument)
{
int sn;
int first = gsn_first_skill;
int top = gsn_first_weapon-1;
int mana, blood;
struct timeval time_used;
// bsearch for the skill
for (;;) {
sn = (first + top) >> 1;
if (LOWER (command[0]) == LOWER (SkillTable.GetName (sn)[0])
&& !str_prefix (command, SkillTable.GetName (sn))
&& (SkillTable.GetSkillFunction (sn) ||
SkillTable.GetSpellFunction (sn) != spell_null)
&& (can_use_skill (ch, 0, sn)))
break;
if (first >= top)
return FALSE;
if (strcmp (command, SkillTable.GetName (sn)) < 1)
top = sn - 1;
else
first = sn + 1;
}
if (! check_pos (ch, SkillTable.GetMinimumPosition (sn)))
return TRUE;
if (ch->IsNpc () && (ch->IsCharmed () || ch->IsPossessed ())) {
ch->SendText ("For some reason, you seem unable to perform that...\n\r");
act (AT_GREY,"$n wanders around aimlessly.", ch, NULL, NULL, TO_ROOM);
return TRUE;
}
// check if mana is required
if (SkillTable.GetMinMana (sn)) {
mana = ch->IsNpc () ? 0 : UMAX (SkillTable.GetMinMana (sn),
100 / (2 + ch->GetLevel ()
- SkillTable.GetClassLevel (sn, ch->GetClass ())));
blood = UMAX (1, (mana+4) / 8); // NPCs don't have PCDatas. -- Altrag
if (ch->IsVampire ()) {
if (ch->GetPcData ()->condition [COND_BLOODTHIRST] < blood) {
ch->SendText ("You don't have enough blood power.\n\r");
return TRUE;
}
}
else if (! ch->IsNpc () && ch->GetMana () < mana) {
ch->SendText ("You don't have enough mana.\n\r");
return TRUE;
}
} else {
mana = 0;
blood = 0;
}
// Is this a real do-fun, or a really a spell?
if (! SkillTable.GetSkillFunction (sn)) {
ch_ret retcode = rNONE;
void *vo = NULL;
CCharacter *victim = NULL;
CObjData *obj = NULL;
target_name = "";
switch (SkillTable.GetTarget (sn)) {
default:
bug ("Check_skill: bad target for sn %d.", sn);
ch->SendText ("Something went wrong...\n\r");
return TRUE;
case TAR_IGNORE:
vo = NULL;
if (argument [0] == '\0') {
if (victim = ch->GetFightWho ())
target_name = NCCP victim->GetName ();
}
else
target_name = argument;
break;
case TAR_CHAR_OFFENSIVE:
if (argument [0] == '\0'
&& (victim = ch->GetFightWho ()) == NULL) {
ch->SendTextf ("%s who?\n\r",
capitalize (SkillTable.GetName (sn)));
return TRUE;
}
else if (argument[0] != '\0'
&& (victim=get_char_room (ch, argument)) == NULL) {
ch->SendText ("They aren't here.\n\r");
return TRUE;
}
if (is_safe (ch, victim))
return TRUE;
vo = victim;
break;
case TAR_CHAR_DEFENSIVE:
if (argument [0] != '\0'
&& (victim=get_char_room (ch, argument)) == NULL) {
ch->SendText ("They aren't here.\n\r");
return TRUE;
}
if (! victim)
victim = ch;
vo = victim;
break;
case TAR_CHAR_SELF:
vo = ch;
break;
case TAR_OBJ_INV:
if ((obj = get_obj_carry (ch, argument)) == NULL) {
ch->SendText ("You can't find that.\n\r");
return TRUE;
}
vo = obj;
break;
}
// waitstate
WAIT_STATE (ch, SkillTable.GetBeats (sn));
// check for failure
if ((number_percent () + SkillTable.GetDifficulty (sn) * 5)
> (ch->IsNpc () ? 75 : ch->GetPcData ()->learned [sn])) {
failed_casting (SkillTable.GetSkill (sn), ch, (CCharacter*) vo,
obj);
learn_from_failure (ch, sn);
if (mana) {
if (ch->IsVampire ())
gain_condition (ch, COND_BLOODTHIRST, - blood/2);
else
ch->AddMana (-mana/2);
}
return TRUE;
}
if (mana) {
if (ch->IsVampire ())
gain_condition (ch, COND_BLOODTHIRST, - blood);
else
ch->AddMana (-mana);
}
start_timer (&time_used);
retcode =
(*SkillTable.GetSpellFunction (sn)) (sn, ch->GetLevel (),ch,vo);
end_timer (&time_used);
update_userec (&time_used, &SkillTable.GetUseRec (sn));
if (retcode == rCHAR_DIED || retcode == rERROR)
return TRUE;
if (char_died (ch))
return TRUE;
if (retcode == rSPELL_FAILED) {
learn_from_failure (ch, sn);
retcode = rNONE;
}
else
learn_from_success (ch, sn);
if (SkillTable.GetTarget (sn) == TAR_CHAR_OFFENSIVE
&& victim != ch && ! char_died (victim)) {
CCharacter *vch;
CCharacter *vch_next;
for (vch = ch->GetInRoom ()->first_person; vch; vch = vch_next) {
vch_next = vch->GetNextInRoom ();
if (victim == vch && ! victim->GetFightData ()
&& victim->GetMaster () != ch) {
retcode = multi_hit (victim, ch, TYPE_UNDEFINED);
break;
}
}
}
return TRUE;
}
if (mana) {
if (ch->IsVampire ())
gain_condition (ch, COND_BLOODTHIRST, - blood);
else
ch->AddMana (-mana);
}
ch->prev_cmd = ch->last_cmd; // haus, for automapping
ch->last_cmd = SkillTable.GetSkillFunction (sn);
start_timer (&time_used);
(*SkillTable.GetSkillFunction (sn)) (ch, argument);
end_timer (&time_used);
update_userec (&time_used, &SkillTable.GetUseRec (sn));
return TRUE;
}
// Lookup a skills information
// High god command
void do_slookup (CCharacter *ch, char *argument)
{
char buf [MAX_STRING_LENGTH];
char arg [MAX_INPUT_LENGTH];
int sn;
int iClass;
CSkill *pSkill = NULL;
one_argument (argument, arg);
if (arg [0] == '\0') {
ch->SendText ("Slookup what?\n\r");
return;
}
if (! str_cmp (arg, "all")) {
for (sn=0; sn < SkillTable.GetCount (); ++sn) {
if (pSkill = SkillTable.GetSkill (sn))
pager_printf (ch,
"Sn: %4d Slot: %4d Skill/spell: '%-20s' Damtype: %s\n\r",
sn, pSkill->GetSlot (), pSkill->GetName (),
spell_damage [pSkill->GetSpellDamage ()]);
}
}
else if (! str_cmp (arg, "herbs")) {
for (sn=0; sn < HerbTable.GetCount (); ++sn) {
pSkill = HerbTable.GetSkill (sn);
pager_printf (ch, "%d) %s\n\r", sn, pSkill->GetName ());
}
} else {
pSkill = NULL;
CSmaugAffect *aff;
int cnt = 0;
if (arg [0] == 'h' && is_number (arg+1)) {
sn = atoi (arg+1);
if (! HerbTable.IsValid (sn)) {
ch->SendText ("Invalid herb.\n\r");
return;
}
pSkill = HerbTable.GetSkill (sn);
}
else if (is_number (arg)) {
sn = atoi (arg);
if ((pSkill = SkillTable.GetValidSkill (sn)) == NULL) {
ch->SendText ("Invalid sn.\n\r");
return;
}
sn %= 1000;
}
else
if ((sn = SkillTable.Lookup (arg)) >= 0)
pSkill = SkillTable.GetSkill (sn);
else
if ((sn = HerbTable.Lookup (arg)) >= 0)
pSkill = HerbTable.GetSkill (sn);
else {
ch->SendText ("No such skill, spell, proficiency or tongue.\n\r");
return;
}
if (! pSkill) {
ch->SendText ("Not created yet.\n\r");
return;
}
ch->SendTextf ("Sn: %4d Slot: %4d %s: '%-20s'\n\r",
sn, pSkill->GetSlot (), skill_tname [pSkill->GetType ()],
pSkill->GetName ());
if (pSkill->GetInfo ())
ch->SendTextf ("Damtype: %s Acttype: %s Classtype: %s"
" Powertype: %s\n\r",
spell_damage [pSkill->GetSpellDamage ()],
spell_action [pSkill->GetSpellAction ()],
spell_class [pSkill->GetSpellClass ()],
spell_power [pSkill->GetSpellPower ()]);
if (pSkill->GetFlags ()) {
strcpy (buf, "Flags:");
for (int x = 0; x < 32; x++)
if (pSkill->HasSpell (1 << x)) {
strcat (buf, " ");
strcat (buf, spell_flag [x]);
}
strcat (buf, "\n\r");
ch->SendText (buf);
}
ch->SendTextf ("Saves: %s SaveEffect: %s\n\r",
pSkill->GetSaveName (), pSkill->GetSaveEffectName ());
if (pSkill->GetDifficulty () != '\0')
ch->SendTextf ("Difficulty: %d\n\r", pSkill->GetDifficulty ());
ch->SendTextf ("Type: %s Target: %s Minpos: %d Mana: %d "
"Beats: %d Range: %d\n\r", skill_tname [pSkill->GetType ()],
target_type [URANGE (TAR_IGNORE, pSkill->GetTarget (),
TAR_OBJ_INV)],
pSkill->GetMinimumPosition (), pSkill->GetMinMana (),
pSkill->GetBeats (), pSkill->GetRange ());
ch->SendTextf (
"Flags: %d Guild: %d Value: %d Info: %d Code: %s\n\r",
pSkill->GetFlags (), pSkill->GetGuild (), pSkill->GetValue (),
pSkill->GetInfo (), pSkill->GetSkillFunction () ?
skill_name (pSkill->GetSkillFunction ())
: spell_name (pSkill->GetSpellFunction ()));
ch->SendTextf ("Dammsg: %s\n\rWearoff: %s\n",
pSkill->GetDamageMsg (),
pSkill->GetOffMsg () ? pSkill->GetOffMsg () : "(none set)");
if (pSkill->GetDiceRoll () && pSkill->GetDiceRoll ()[0] != '\0')
ch->SendTextf ("Dice: %s\n\r", pSkill->GetDiceRoll ());
if (pSkill->GetTeachers () && pSkill->GetTeachers ()[0] != '\0')
ch->SendTextf ("Teachers: %s\n\r", pSkill->GetTeachers ());
if (pSkill->GetComponents () && pSkill->GetComponents ()[0] != '\0')
ch->SendTextf ("Components: %s\n\r", pSkill->GetComponents ());
if (pSkill->GetParticipants ())
ch->SendTextf ("Participants: %d\n\r", pSkill->GetParticipants ());
if (pSkill->GetUseRec ().num_uses)
send_timer (&pSkill->GetUseRec (), ch);
for (aff = pSkill->GetAffects (); aff; aff = aff->GetNext ()) {
if (aff == pSkill->GetAffects ())
ch->SendText ("\n\r");
sprintf (buf, "Affect %d", ++cnt);
if (aff->location) {
strcat (buf, " modifies ");
strcat (buf, a_types [aff->location % REVERSE_APPLY]);
strcat (buf, " by '");
strcat (buf, aff->modifier);
strcat (buf, (aff->bitvector >= 0) ? "' and" : "'");
}
if (aff->bitvector >= 0) {
strcat (buf, " applies ");
strcat (buf, CAffectFlags::GetName (aff->bitvector));
}
if (aff->duration [0] != '\0' && aff->duration [0] != '0') {
strcat (buf, " for '");
strcat (buf, aff->duration);
strcat (buf, "' rounds");
}
if (aff->location >= REVERSE_APPLY)
strcat (buf, " (affects caster only)");
strcat (buf, "\n\r");
ch->SendText (buf);
if (! aff->GetNext ())
ch->SendText ("\n\r");
}
if (pSkill->ValidHitCharMsg ())
ch->SendTextf ("Hitchar : %s\n\r", pSkill->GetHitCharMsg ());
if (pSkill->ValidHitVictMsg ())
ch->SendTextf ("Hitvict : %s\n\r", pSkill->GetHitVictMsg ());
if (pSkill->ValidHitRoomMsg ())
ch->SendTextf ("Hitroom : %s\n\r", pSkill->GetHitRoomMsg ());
if (pSkill->ValidHitDest ())
ch->SendTextf ("Hitdest : %s\n\r", pSkill->GetHitDest ());
if (pSkill->ValidMissCharMsg ())
ch->SendTextf ("Misschar : %s\n\r", pSkill->GetMissCharMsg ());
if (pSkill->ValidMissVictMsg ())
ch->SendTextf ("Missvict : %s\n\r", pSkill->GetMissVictMsg ());
if (pSkill->ValidMissRoomMsg ())
ch->SendTextf ("Missroom : %s\n\r", pSkill->GetMissRoomMsg ());
if (pSkill->ValidDieCharMsg ())
ch->SendTextf ("Diechar : %s\n\r", pSkill->GetDieCharMsg ());
if (pSkill->ValidDieVictMsg ())
ch->SendTextf ("Dievict : %s\n\r", pSkill->GetDieVictMsg ());
if (pSkill->ValidDieRoomMsg ())
ch->SendTextf ("Dieroom : %s\n\r", pSkill->GetDieRoomMsg ());
if (pSkill->ValidImmuneCharMsg ())
ch->SendTextf ("Immchar : %s\n\r", pSkill->GetImmuneCharMsg ());
if (pSkill->ValidImmuneVictMsg ())
ch->SendTextf ("Immvict : %s\n\r", pSkill->GetImmuneVictMsg ());
if (pSkill->ValidImmuneRoomMsg ())
ch->SendTextf ("Immroom : %s\n\r", pSkill->GetImmuneRoomMsg ());
if (pSkill->GetType () != SKILL_HERB) {
if (pSkill->GetType () != SKILL_RACIAL) {
ch->SendText ("--------------------------[CLASS USE]-----"
"---------------------\n\r");
for (iClass = 0; iClass < ClassTable.GetCount (); ++iClass) {
strcpy (buf, ClassTable.GetName (iClass));
sprintf (buf+3, ") lvl: %3d max: %2d%%",
pSkill->GetClassLevel (iClass),
pSkill->GetClassAdept (iClass));
if (iClass % 3 == 2)
strcat (buf, "\n\r");
else
strcat (buf, " ");
ch->SendText (buf);
}
} else {
ch->SendText ("\n\r--------------------------[RACE USE]---"
"-----------------------\n\r");
for (int ra=0; ra < RaceTable.GetCount (); ++ra) {
sprintf (buf, "%8.8s) lvl: %3d max: %2d%%",
RaceTable.GetName (ra),
pSkill->GetRaceLevel (ra),
pSkill->GetRaceAdept (ra));
if (ra % 3 == 2)
strcat (buf, "\n\r");
else
strcat (buf, " ");
ch->SendText (buf);
}
}
}
ch->SendText ("\n\r");
}
}
// Set a skill's attributes or what skills a player has.
// High god command, with support for creating skills/spells/herbs/etc
void do_sset (CCharacter *ch, char *argument)
{
char arg1 [MAX_INPUT_LENGTH];
char arg2 [MAX_INPUT_LENGTH];
CCharacter *victim;
int value;
int sn;
int i;
BOOL fAll;
argument = one_argument (argument, arg1);
argument = one_argument (argument, arg2);
if (arg1 [0] == '\0' || arg2 [0] == '\0') {
SkillHelp (ch);
return;
}
if (ch->GetTrustLevel () > LEVEL_SUB_IMPLEM
&& ! str_cmp (arg1, "save")) {
if (! str_cmp (arg2, "skills")) {
ch->SendText ("Saving skill table...\n\r");
save_skill_table ();
return;
}
if (! str_cmp (arg2, "classes")) {
ch->SendText ("Saving classes...\n\r");
ClassTable.Save ();
return;
}
if (! str_cmp (arg2, "races")) {
ch->SendText ("Saving races...\n\r");
RaceTable.Save ();
return;
}
if (! str_cmp (arg2, "herbs")) {
ch->SendText ("Saving herb table...\n\r");
save_herb_table ();
return;
}
}
if (argument [0] == '\0') {
SkillHelp (ch);
return;
}
if (ch->GetTrustLevel () > LEVEL_SUB_IMPLEM
&& !str_cmp (arg1, "create")
&& (!str_cmp (arg2, "skill") || !str_cmp (arg2, "herb")
|| !str_cmp (arg2, "ability"))) {
CSkill *skill;
short type = SKILL_UNKNOWN;
if (! str_cmp (arg2, "herb")) {
type = SKILL_HERB;
if (HerbTable.GetCount () >= MAX_HERB) {
ch->SendTextf ("The current top herb is %d, which is the "
"maximum. To add more herbs,\n\rMAX_HERB will have to be "
"raised in smaug.h, and the mud recompiled.\n\r",
HerbTable.GetCount ());
return;
}
}
else if (SkillTable.GetCount () >= MAX_SKILL) {
ch->SendTextf ("The current top sn is %d, which is the maximum. "
"To add more skills,\n\rMAX_SKILL will have to be "
"raised in smaug.h, and the mud recompiled.\n\r",
SkillTable.GetCount ());
return;
}
skill = new CSkill;
if (type == SKILL_HERB)
HerbTable.Add (skill);
else SkillTable.Add (skill);
skill->SetName (str_dup (argument));
skill->SetDamageMsg (str_dup (""));
skill->SetOffMsg (str_dup (""));
skill->SetSpellFunction (spell_smaug);
skill->SetType (type);
skill->SetGuild (CLASS_NONE);
if (! str_cmp (arg2, "ability"))
skill->SetType (SKILL_RACIAL);
for (i=0; i < ClassTable.GetCount (); ++i) {
skill->SetClassLevel (i, LEVEL_IMMORTAL);
skill->SetClassAdept (i, 95);
}
for (i=0; i < RaceTable.GetCount (); ++i) {
skill->SetRaceLevel (i, LEVEL_IMMORTAL);
skill->SetRaceAdept (i, 95);
}
ch->SendText ("Done.\n\r");
return;
}
if (arg1 [0] == 'h')
sn = atoi (arg1+1);
else
sn = atoi (arg1);
if (ch->GetTrustLevel () > LEVEL_GREATER
&& ((arg1[0] == 'h' && is_number (arg1+1) && (sn=atoi (arg1+1))>=0)
|| (is_number (arg1) && (sn=atoi (arg1)) >= 0))) {
CSkill *skill;
if (arg1 [0] == 'h') {
if (sn >= HerbTable.GetCount ()) {
ch->SendText ("Herb number out of range.\n\r");
return;
}
skill = HerbTable.GetSkill (sn);
} else {
if ((skill=SkillTable.GetValidSkill (sn)) == NULL) {
ch->SendText ("Skill number out of range.\n\r");
return;
}
sn %= 1000;
}
if (! str_cmp (arg2, "difficulty")) {
skill->SetDifficulty (atoi (argument));
ch->SendText ("Ok.\n\r");
return;
}
if (! str_cmp (arg2, "participants")) {
skill->SetParticipants (atoi (argument));
ch->SendText ("Ok.\n\r");
return;
}
if (! str_cmp (arg2, "damtype")) {
int x = get_sdamage (argument);
if (x == -1)
ch->SendText ("Not a spell damage type.\n\r");
else {
SET_SDAM (skill, x);
ch->SendText ("Ok.\n\r");
}
return;
}
if (! str_cmp (arg2, "acttype")) {
int x = get_saction (argument);
if (x == -1)
ch->SendText ("Not a spell action type.\n\r");
else {
SET_SACT (skill, x);
ch->SendText ("Ok.\n\r");
}
return;
}
if (! str_cmp (arg2, "classtype")) {
int x = get_sclass (argument);
if (x == -1)
ch->SendText ("Not a spell class type.\n\r");
else {
SET_SCLA (skill, x);
ch->SendText ("Ok.\n\r");
}
return;
}
if (! str_cmp (arg2, "powertype")) {
int x = get_spower (argument);
if (x == -1)
ch->SendText ("Not a spell power type.\n\r");
else {
SET_SPOW (skill, x);
ch->SendText ("Ok.\n\r");
}
return;
}
if (! str_cmp (arg2, "seffect")) {
int x = SkillTable.GetSaveEffectFromName (argument);
if (x == -1)
ch->SendText ("Not a spell save effect type.\n\r");
else {
skill->SetSaveEffect (x);
ch->SendText ("Ok.\n\r");
}
return;
}
if (! str_cmp (arg2, "flag")) {
int x = get_sflag (argument);
if (x == -1)
ch->SendText ("Not a spell flag.\n\r");
else {
int flgs = skill->GetFlags ();
TOGGLE_BIT (flgs, 1 << (x));
skill->SetFlags (flgs);
ch->SendText ("Ok.\n\r");
}
return;
}
if (! str_cmp (arg2, "saves")) {
int x = get_ssave (argument);
if (x == -1)
ch->SendText ("Not a saving type.\n\r");
else {
skill->SetSaves (x);
ch->SendText ("Ok.\n\r");
}
return;
}
if (! str_cmp (arg2, "code")) {
SPELL_FUN *spellfun;
DO_FUN *dofun;
if ((spellfun=spell_function (argument)) != spell_notfound) {
skill->SetSpellFunction (spellfun);
skill->SetSkillFunction (NULL);
}
else if ((dofun=skill_function (argument)) != skill_notfound) {
skill->SetSkillFunction (dofun);
skill->SetSpellFunction (NULL);
} else {
ch->SendText ("Not a spell or skill.\n\r");
return;
}
ch->SendText ("Ok.\n\r");
return;
}
if (! str_cmp (arg2, "target")) {
int x = get_starget (argument);
if (x == -1)
ch->SendText ("Not a valid target type.\n\r");
else {
skill->SetTarget (x);
ch->SendText ("Ok.\n\r");
}
return;
}
if (! str_cmp (arg2, "minpos")) {
skill->SetMinimumPosition (URANGE (POS_DEAD, atoi (argument), POS_DRAG));
ch->SendText ("Ok.\n\r");
return;
}
if (! str_cmp (arg2, "minlevel")) {
skill->SetMinLevel (URANGE (1, atoi (argument), MAX_LEVEL));
ch->SendText ("Ok.\n\r");
return;
}
if (! str_cmp (arg2, "slot")) {
skill->SetSlot (URANGE (0, atoi (argument), 30000));
ch->SendText ("Ok.\n\r");
return;
}
if (! str_cmp (arg2, "mana")) {
skill->SetMinMana (URANGE (0, atoi (argument), 2000));
ch->SendText ("Ok.\n\r");
return;
}
if (! str_cmp (arg2, "beats")) {
skill->SetBeats (URANGE (0, atoi (argument), 120));
ch->SendText ("Ok.\n\r");
return;
}
if (! str_cmp (arg2, "range")) {
skill->SetRange (URANGE (0, atoi (argument), 20));
ch->SendText ("Ok.\n\r");
return;
}
if (! str_cmp (arg2, "guild")) {
skill->SetGuild (atoi (argument));
ch->SendText ("Ok.\n\r");
return;
}
if (! str_cmp (arg2, "value")) {
skill->SetValue (atoi (argument));
ch->SendText ("Ok.\n\r");
return;
}
if (! str_cmp (arg2, "type")) {
skill->SetType (get_skill (argument));
ch->SendText ("Ok.\n\r");
return;
}
if (! str_cmp (arg2, "rmaffect")) {
CSmaugAffect *aff = skill->GetAffects ();
CSmaugAffect *aff_next;
int num = atoi (argument);
int cnt = 1;
if (! aff) {
ch->SendText ("This spell has no special affects to remove.\n\r");
return;
}
if (num == 1) {
skill->SetAffects (aff->GetNext ());
delete aff;
ch->SendText ("Removed.\n\r");
return;
}
for (; aff; aff = aff->GetNext ()) {
if (++cnt == num && (aff_next=aff->GetNext ()) != NULL) {
aff->SetNext (aff_next->GetNext ());
delete aff_next;
ch->SendText ("Removed.\n\r");
return;
}
}
ch->SendText ("Not found.\n\r");
return;
}
// affect <location> <modifier> <duration> <bitvector>
if (! str_cmp (arg2, "affect")) {
char location [MAX_INPUT_LENGTH];
char modifier [MAX_INPUT_LENGTH];
char duration [MAX_INPUT_LENGTH];
int loc, bit, tmpbit;
CSmaugAffect *aff;
argument = one_argument (argument, location);
argument = one_argument (argument, modifier);
argument = one_argument (argument, duration);
if (location [0] == '!')
loc = get_atype (location+1) + REVERSE_APPLY;
else
loc = get_atype (location);
if ((loc % REVERSE_APPLY) < 0
|| (loc % REVERSE_APPLY) >= MAX_APPLY_TYPE) {
ch->SendText ("Unknown affect location. See AFFECTTYPES.\n\r");
return;
}
bit = -1;
if (argument [0] != 0) {
if ((tmpbit = get_aflag (argument)) == -1)
ch->SendTextf ("Unknown bitvector: %s. See "
"AFFECTED_BY\n\r", argument);
else
bit = tmpbit;
}
aff = new CSmaugAffect;
if (! str_cmp (duration, "0"))
duration [0] = '\0';
if (! str_cmp (modifier, "0"))
modifier [0] = '\0';
aff->duration = str_dup (duration);
aff->location = loc;
aff->modifier = str_dup (modifier);
aff->bitvector = bit;
aff->SetNext (skill->GetAffects ());
skill->SetAffects (aff);
ch->SendText ("Ok.\n\r");
return;
}
if (! str_cmp (arg2, "level")) {
char arg3 [MAX_INPUT_LENGTH];
int Class;
argument = one_argument (argument, arg3);
Class = ClassTable.GetClass (arg3);
if (Class == CLASS_NONE)
ch->SendText ("Not a valid class.\n\r");
else
skill->SetClassLevel (Class, URANGE (0, atoi (argument), MAX_LEVEL));
return;
}
if (! str_cmp (arg2, "racelevel")) {
char arg3 [MAX_INPUT_LENGTH];
int race;
argument = one_argument (argument, arg3);
race = RaceTable.GetRace (arg3);
if (race == RACE_NONE)
ch->SendText ("Not a valid race.\n\r");
else
skill->SetRaceLevel (race,
URANGE (0, atoi (argument), MAX_LEVEL));
return;
}
if (! str_cmp (arg2, "adept")) {
char arg3 [MAX_INPUT_LENGTH];
int Class;
argument = one_argument (argument, arg3);
Class = ClassTable.GetClass (arg3);
if (Class == CLASS_NONE)
ch->SendText ("Not a valid class.\n\r");
else
skill->SetClassAdept (Class,
URANGE (0, atoi (argument), 100));
return;
}
if (! str_cmp (arg2, "raceadept")) {
char arg3 [MAX_INPUT_LENGTH];
int race;
argument = one_argument (argument, arg3);
race = RaceTable.GetRace (arg3);
if (race == RACE_NONE)
ch->SendText ("Not a valid race.\n\r");
else
skill->SetRaceAdept (race,
URANGE (0, atoi (argument), 100));
return;
}
if (! str_cmp (arg2, "name")) {
delete skill->GetName ();
skill->SetName (str_dup (argument));
ch->SendText ("Ok.\n\r");
return;
}
#define REP(msg) skill->msg (stricmp (argument, "clear") ? \
str_dup (argument) : NULL); \
ch->SendText ("Ok.\n\r")
// if (! str_cmp (argument, "clear"))
// skill->SetDamageMsg (NULL);
// else
// skill->SetDamageMsg (str_dup (argument));
// ch->SendText ("Ok.\n\r");
if (! str_cmp (arg2, "dammsg")) {
delete skill->GetDamageMsg ();
REP (SetDamageMsg);
return;
}
if (! str_cmp (arg2, "wearoff")) {
delete skill->GetOffMsg ();
REP (SetOffMsg);
return;
}
if (! str_cmp (arg2, "hitchar")) {
delete skill->GetHitCharMsg ();
REP (SetHitCharMsg);
return;
}
if (! str_cmp (arg2, "hitvict")) {
delete skill->GetHitVictMsg ();
REP (SetHitVictMsg);
return;
}
if (! str_cmp (arg2, "hitroom")) {
delete skill->GetHitRoomMsg ();
REP (SetHitRoomMsg);
return;
}
if (! str_cmp (arg2, "hitdest")) {
delete skill->GetHitDest ();
REP (SetHitDest);
return;
}
if (! str_cmp (arg2, "misschar")) {
delete skill->GetMissCharMsg ();
REP (SetMissCharMsg);
return;
}
if (! str_cmp (arg2, "missvict")) {
delete skill->GetMissVictMsg ();
REP (SetMissVictMsg);
return;
}
if (! str_cmp (arg2, "missroom")) {
delete skill->GetMissRoomMsg ();
REP (SetMissRoomMsg);
return;
}
if (! str_cmp (arg2, "diechar")) {
delete skill->GetDieCharMsg ();
REP (SetDieCharMsg);
return;
}
if (! str_cmp (arg2, "dievict")) {
delete skill->GetDieVictMsg ();
REP (SetDieVictMsg);
return;
}
if (! str_cmp (arg2, "dieroom")) {
delete skill->GetDieRoomMsg ();
REP (SetDieRoomMsg);
return;
}
if (! str_cmp (arg2, "immchar")) {
delete skill->GetImmuneCharMsg ();
REP (SetImmuneCharMsg);
return;
}
if (! str_cmp (arg2, "immvict")) {
delete skill->GetImmuneVictMsg ();
REP (SetImmuneVictMsg);
return;
}
if (! str_cmp (arg2, "immroom")) {
delete skill->GetImmuneRoomMsg ();
REP (SetImmuneRoomMsg);
return;
}
if (! str_cmp (arg2, "dice")) {
delete skill->GetDiceRoll ();
REP (SetDiceRoll);
return;
}
if (! str_cmp (arg2, "components")) {
delete skill->GetComponents ();
REP (SetComponents);
return;
}
if (! str_cmp (arg2, "teachers")) {
delete skill->GetTeachers ();
REP (SetTeachers);
return;
}
do_sset (ch, "");
return;
}
if ((victim = get_char_world (ch, arg1)) == NULL) {
if ((sn = SkillTable.Lookup (arg1)) >= 0) {
sprintf (arg1, "%d %s %s", sn, arg2, argument);
do_sset (ch, arg1);
}
else
ch->SendText ("They aren't here.\n\r");
return;
}
if (victim->IsNpc ()) {
ch->SendText ("Not on NPC's.\n\r");
return;
}
fAll = ! str_cmp (arg2, "all");
sn = 0;
if (! fAll && (sn = SkillTable.Lookup (arg2)) < 0) {
ch->SendText ("No such skill or spell.\n\r");
return;
}
// Snarf the value.
if (! is_number (argument)) {
ch->SendText ("Value must be numeric.\n\r");
return;
}
value = atoi (argument);
if (value < 0 || value > 100) {
ch->SendText ("Value range is 0 to 100.\n\r");
return;
}
if (fAll) {
for (sn = 0; sn < SkillTable.GetCount (); sn++) {
// Fix by Narn to prevent ssetting skills
// the player shouldn't have.
if (SkillTable.GetName (sn)
&& (victim->GetLevel () >=
SkillTable.GetClassLevel (sn,
victim->GetClass ()) || value == 0))
victim->GetPcData ()->learned [sn] = value;
}
}
else victim->GetPcData ()->learned [sn] = value;
}
void SkillHelp (CCharacter* ch)
{
ch->SendText ("Syntax: sset <victim> <skill> <value>\n\r");
ch->SendText ("or: sset <victim> all <value>\n\r");
if (ch->GetTrustLevel () > LEVEL_SUB_IMPLEM) {
ch->SendText ("or: sset save skills\n\r");
ch->SendText ("or: sset save herbs\n\r");
ch->SendText ("or: sset save classes\n\r");
ch->SendText ("or: sset save races\n\r");
ch->SendText ("or: sset create skill 'new skill'\n\r");
ch->SendText ("or: sset create herb 'new herb'\n\r");
ch->SendText ("or: sset create ability 'new ability'\n\r");
}
if (ch->GetTrustLevel () > LEVEL_GREATER) {
ch->SendText ("or: sset <sn> <field> <value>\n\r");
ch->SendText ("\n\rField being one of:\n\r");
ch->SendText (" name code target minpos slot mana beats dammsg wearoff guild minlevel\n\r");
ch->SendText (" type damtype acttype classtype powertype seffect flag dice value difficulty affect\n\r");
ch->SendText (" affect rmaffect level adept hit miss die imm (char/vict/room)\n\r");
ch->SendText (" components teachers racelevel raceadept\n\r");
ch->SendText ("Affect having the fields: <location> <modfifier> [duration] [bitvector]\n\r");
ch->SendText ("(See AFFECTTYPES for location, and AFFECTED_BY for bitvector)\n\r");
}
ch->SendText ("Skill being any skill or spell.\n\r");
}
void learn_from_success (CCharacter *ch, int sn)
{
int adept, gain, sklvl, learn, percent, chance;
if (ch->IsNpc () || ch->GetPcData ()->learned [sn] == 0)
return;
short &learned = ch->GetPcData ()->learned [sn];
adept = SkillTable.GetClassAdept (sn, ch->GetClass ());
if (learned >= adept)
return; // already knows it all
sklvl = SkillTable.GetClassLevel (sn, ch->GetClass ());
if (sklvl == 0)
sklvl = ch->GetLevel ();
chance = learned + (5 * SkillTable.GetDifficulty (sn));
percent = number_percent ();
if (percent >= chance)
learn = 2;
else
if (chance - percent > 25)
return;
else
learn = 1;
learned = UMIN (adept, learned + learn);
int Mage = ClassTable.GetClass ("Mage");
if (learned == adept) { // now fully learned!
gain = 1000 * sklvl;
if (ch->GetClass () == Mage)
gain *= 5; // h, mage upgrade
set_char_color (AT_WHITE, ch);
ch->SendTextf ("You are now an adept of %s! You gain %d bonus"
" experience!\n\r", SkillTable.GetName (sn), gain);
} else {
gain = 20 * sklvl;
if (ch->GetClass () == Mage)
gain *= 6; // h, mage upgrade
if (! ch->GetFightData () && sn != gsn_hide && sn != gsn_sneak) {
set_char_color (AT_WHITE, ch);
ch->SendTextf (
"You gain %d experience points from your success!\n\r", gain);
}
}
gain_exp (ch, gain);
}
void learn_from_failure (CCharacter *ch, int sn)
{
int adept, chance;
short &learned = ch->GetPcData ()->learned [sn];
if (ch->IsNpc () || learned == 0)
return;
chance = learned + (5 * SkillTable.GetDifficulty (sn));
if (chance - number_percent () > 25)
return;
adept = SkillTable.GetClassAdept (sn, ch->GetClass ());
if (learned < (adept-1))
++learned;
}
void do_gouge (CCharacter *ch, char *argument)
{
CCharacter *victim;
CAffectData af;
short dam;
int chance;
if (ch->IsNpc () && ch->IsCharmed ()) {
ch->SendText ("You can't concentrate enough for that.\n\r");
return;
}
if (! can_use_skill (ch, 0, gsn_gouge)) {
ch->SendText ("You do not yet know of this skill.\n\r");
return;
}
if (ch->mount) {
ch->SendText ("You can't get close enough while mounted.\n\r");
return;
}
if ((victim = ch->GetFightWho ()) == NULL) {
ch->SendText ("You aren't fighting anyone.\n\r");
return;
}
chance = ((victim->GetDexterity () - ch->GetDexterity ()) * 10) + 10;
// 1.4add
// if (! ch->IsNpc () && ! victim->IsNpc ())
// chance += sysdata.gouge_plr_vs_plr;
//
// if (victim->fighting && victim->fighting->who != ch)
// chance += sysdata.gouge_nontank;
if (can_use_skill (ch, (number_percent () + chance), gsn_gouge)) {
dam = number_range (5, ch->GetLevel ());
global_retcode = damage (ch, victim, dam, gsn_gouge);
if (global_retcode == rNONE) {
if (! victim->IsBlind ()) {
af.type = gsn_blindness;
af.location = APPLY_HITROLL;
af.modifier = -6;
if (! victim->IsNpc () && ! ch->IsNpc ())
af.duration = (ch->GetLevel () + 10) /
victim->GetConstitution ();
else af.duration = 3 + (ch->GetLevel () / 15);
af.bitvector = AFF_BLIND;
affect_to_char (victim, &af);
act (AT_SKILL, "You can't see a thing!",
victim, NULL, NULL, TO_CHAR);
}
WAIT_STATE (ch, PULSE_VIOLENCE);
if (! ch->IsNpc () && ! victim->IsNpc ()) {
if (number_bits (1) == 0) {
ch->SendTextf ("%s looks momentarily dazed.\n\r",
victim->GetName ());
victim->SendText ("You are momentarily dazed ...\n\r");
WAIT_STATE (victim, PULSE_VIOLENCE);
}
}
else WAIT_STATE (victim, PULSE_VIOLENCE);
// Taken out by request - put back in by Thoric
// This is how it was designed. You'd be a tad stunned
// if someone gouged you in the eye.
// Mildly modified by Blodkai, Feb 1998 at request of
// of pkill Conclave (peaceful use remains the same)
}
else if (global_retcode == rVICT_DIED) {
act (AT_BLOOD, "Your fingers plunge into your victim's brain, "
"causing immediate death!", ch, NULL, NULL, TO_CHAR);
}
if (global_retcode != rCHAR_DIED && global_retcode != rBOTH_DIED)
learn_from_success (ch, gsn_gouge);
} else {
WAIT_STATE (victim, PULSE_VIOLENCE);
WAIT_STATE (ch, SkillTable.GetBeats (gsn_gouge));
global_retcode = damage (ch, victim, 0, gsn_gouge);
learn_from_failure (ch, gsn_gouge);
}
}
void do_detrap (CCharacter *ch, char *argument)
{
char arg [MAX_INPUT_LENGTH];
CObjData *trap;
CObjData *obj;
int percent;
BOOL bFound = FALSE;
POSITION Cpos;
switch (ch->GetSubstate ()) {
default:
if (ch->IsNpc () && ch->IsCharmed ()) {
ch->SendText ("You can't concentrate enough for that.\n\r");
return;
}
argument = one_argument (argument, arg);
if (! can_use_skill (ch, 0, gsn_detrap)) {
ch->SendText ("You do not yet know of this skill.\n\r");
return;
}
if (arg [0] == '\0') {
ch->SendText ("Detrap what?\n\r");
return;
}
if (ms_find_obj (ch))
return;
if (ch->mount) {
ch->SendText ("You can't do that while mounted.\n\r");
return;
}
if (ch->GetInRoom ()->IsEmpty ()) {
ch->SendText ("You can't find that here.\n\r");
return;
}
Cpos = ch->GetInRoom ()->GetHeadContentPos ();
while (obj = ch->GetInRoom ()->GetNextContent (Cpos)) {
if (can_see_obj (ch, *obj)
&& nifty_is_name (arg, obj->GetName ())) {
bFound = TRUE;
break;
}
}
if (! bFound) {
ch->SendText ("You can't find that here.\n\r");
return;
}
act (AT_ACTION,
"You carefully begin your attempt to remove a trap from $p...",
ch, obj, NULL, TO_CHAR);
act (AT_ACTION, "$n carefully attempts to remove a trap from $p...",
ch, obj, NULL, TO_ROOM);
ch->alloc_ptr = str_dup (obj->GetName ());
add_timer (ch, TIMER_DO_FUN, 3, do_detrap, 1);
/* WAIT_STATE (ch, skill_table[gsn_detrap]->beats); */
return;
case 1:
if (! ch->alloc_ptr) {
ch->SendText ("Your detrapping was interrupted!\n\r");
bug ("do_detrap: ch->dest_buf NULL!");
return;
}
strcpy (arg, (char*) ch->alloc_ptr);
delete ch->alloc_ptr;
ch->alloc_ptr = NULL;
ch->SetSubstate (SUB_NONE);
break;
case SUB_TIMER_DO_ABORT:
delete ch->alloc_ptr;
ch->alloc_ptr = NULL;
ch->SetSubstate (SUB_NONE);
ch->SendText ("You carefully stop what you were doing.\n\r");
return;
}
if (ch->GetInRoom ()->IsEmpty ()) {
ch->SendText ("You can't find that here.\n\r");
return;
}
Cpos = ch->GetInRoom ()->GetHeadContentPos ();
while (obj = ch->GetInRoom ()->GetNextContent (Cpos)) {
if (can_see_obj (ch, *obj) && nifty_is_name (arg, obj->GetName ())) {
bFound = TRUE;
break;
}
}
if (! bFound) {
ch->SendText ("You can't find that here.\n\r");
return;
}
if ((trap = get_trap (obj)) == NULL) {
ch->SendText ("You find no trap on that.\n\r");
return;
}
percent = number_percent () - (ch->GetLevel () / 15)
- (get_curr_lck (ch) - 16);
separate_obj (obj);
if (can_use_skill (ch, percent, gsn_detrap)) {
ch->SendText ("Ooops!\n\r");
spring_trap (ch, trap);
learn_from_failure (ch, gsn_detrap);
return;
}
extract_obj (trap);
ch->SendText ("You successfully remove a trap.\n\r");
learn_from_success (ch, gsn_detrap);
}
void do_dig (CCharacter *ch, char *argument)
{
char arg [MAX_INPUT_LENGTH];
CObjData *obj;
BOOL bFound;
BOOL bShovel;
CExitData *pexit;
switch (ch->GetSubstate ()) {
default:
if (ch->IsNpc () && ch->IsCharmed ()) {
ch->SendText ("You can't concentrate enough for that.\n\r");
return;
}
if (ch->mount) {
ch->SendText ("You can't do that while mounted.\n\r");
return;
}
one_argument (argument, arg);
if (arg [0] != '\0') {
if ((pexit = find_door (ch, arg, TRUE)) == NULL
&& get_dir (arg) == -1) {
ch->SendText ("What direction is that?\n\r");
return;
}
if (pexit) {
if (! pexit->IsDig () && ! pexit->IsClosed ()) {
ch->SendText ("There is no need to dig out that exit.\n\r");
return;
}
}
} else {
switch (ch->GetInRoom ()->sector_type) {
case SECT_CITY:
case SECT_INSIDE:
ch->SendText ("The floor is too hard to dig through.\n\r");
return;
case SECT_WATER_SWIM:
case SECT_WATER_NOSWIM:
case SECT_UNDERWATER:
ch->SendText ("You cannot dig here.\n\r");
return;
case SECT_AIR:
ch->SendText ("What? In the air?!\n\r");
return;
}
}
add_timer (ch,
TIMER_DO_FUN, UMIN (SkillTable.GetBeats (gsn_dig) / 10, 3),
do_dig, 1);
ch->alloc_ptr = str_dup (arg);
ch->SendText ("You begin digging...\n\r");
act (AT_PLAIN, "$n begins digging...", ch, NULL, NULL, TO_ROOM);
return;
case 1:
if (! ch->alloc_ptr) {
ch->SendText ("Your digging was interrupted!\n\r");
act (AT_PLAIN, "$n's digging was interrupted!",
ch, NULL, NULL, TO_ROOM);
bug ("do_dig: dest_buf NULL");
return;
}
strcpy (arg, (char*) ch->alloc_ptr);
delete ch->alloc_ptr;
ch->alloc_ptr = NULL;
break;
case SUB_TIMER_DO_ABORT:
delete ch->alloc_ptr;
ch->alloc_ptr = NULL;
ch->SetSubstate (SUB_NONE);
ch->SendText ("You stop digging...\n\r");
act (AT_PLAIN, "$n stops digging...", ch, NULL, NULL, TO_ROOM);
return;
}
ch->SetSubstate (SUB_NONE);
// not having a shovel makes it harder to succeed
bShovel = FALSE;
POSITION pos = ch->GetHeadCarryPos ();
while (pos)
if (ch->GetNextCarrying (pos)->item_type == ITEM_SHOVEL) {
bShovel = TRUE;
break;
}
// dig out an EX_DIG exit...
if (arg [0] != '\0') {
if ((pexit = find_door (ch, arg, TRUE)) != NULL
&& pexit->IsDig () && pexit->IsClosed ()) {
// 4 times harder to dig open a passage without a shovel
if (can_use_skill (ch, (number_percent () * (bShovel ? 1 : 4)),
gsn_dig)) {
pexit->ClrClosed ();
ch->SendText ("You dig open a passageway!\n\r");
act (AT_PLAIN, "$n digs open a passageway!",
ch, NULL, NULL, TO_ROOM);
learn_from_success (ch, gsn_dig);
return;
}
}
learn_from_failure (ch, gsn_dig);
ch->SendText ("Your dig did not discover any exit...\n\r");
act (AT_PLAIN, "$n's dig did not discover any exit...",
ch, NULL, NULL, TO_ROOM);
return;
}
bFound = FALSE;
pos = ch->GetInRoom ()->GetHeadContentPos ();
while (obj = ch->GetInRoom ()->GetNextContent (pos)) {
// twice as hard to find something without a shovel
if (obj->IsBuried ()
&& (can_use_skill (ch, (number_percent () * (bShovel ? 1 : 2)),
gsn_dig))) {
bFound = TRUE;
break;
}
}
if (! bFound) {
ch->SendText ("Your dig uncovered nothing.\n\r");
act (AT_PLAIN, "$n's dig uncovered nothing.", ch, NULL, NULL, TO_ROOM);
learn_from_failure (ch, gsn_dig);
return;
}
separate_obj (obj);
obj->ClrBuried ();
act (AT_SKILL, "Your dig uncovered $p!", ch, obj, NULL, TO_CHAR);
act (AT_SKILL, "$n's dig uncovered $p!", ch, obj, NULL, TO_ROOM);
learn_from_success (ch, gsn_dig);
if (obj->item_type == ITEM_CORPSE_PC
|| obj->item_type == ITEM_CORPSE_NPC)
adjust_favor (ch, 14, 1);
}
void do_search (CCharacter *ch, char *argument)
{
char arg [MAX_INPUT_LENGTH];
CObjData *obj;
CObjData *container;
int percent;
int door = -1;
switch (ch->GetSubstate ()) {
default:
if (ch->IsNpc () && ch->IsCharmed ()) {
ch->SendText ("You can't concentrate enough for that.\n\r");
return;
}
if (ch->mount) {
ch->SendText ("You can't do that while mounted.\n\r");
return;
}
argument = one_argument (argument, arg);
if (arg [0] != '\0' && (door = get_door (arg)) == -1) {
container = get_obj_here (ch, arg);
if (! container) {
ch->SendText ("You can't find that here.\n\r");
return;
}
if (container->item_type != ITEM_CONTAINER) {
ch->SendText ("You can't search in that!\n\r");
return;
}
if (IS_SET (container->value [1], CONT_CLOSED)) {
ch->SendText ("It is closed.\n\r");
return;
}
}
add_timer (ch, TIMER_DO_FUN,
UMIN (SkillTable.GetBeats (gsn_search) / 10, 3), do_search, 1);
ch->SendText ("You begin your search...\n\r");
ch->alloc_ptr = str_dup (arg);
return;
case 1:
if (! ch->alloc_ptr) {
ch->SendText ("Your search was interrupted!\n\r");
bug ("do_search: dest_buf NULL");
return;
}
strcpy (arg, (char*) ch->alloc_ptr);
delete ch->alloc_ptr;
ch->alloc_ptr = NULL;
break;
case SUB_TIMER_DO_ABORT:
delete ch->alloc_ptr;
ch->alloc_ptr = NULL;
ch->SetSubstate (SUB_NONE);
ch->SendText ("You stop your search...\n\r");
return;
}
ch->SetSubstate (SUB_NONE);
CObjectList *pList = NULL;
if (arg [0] == '\0')
pList = &ch->GetInRoom ()->GetContentList ();
else {
if ((door = get_door (arg)) == -1) {
container = get_obj_here (ch, arg);
if (! container) {
ch->SendText ("You can't find that here.\n\r");
return;
}
pList = &container->GetContentList ();
}
}
if ((! pList && door == -1) || ch->IsNpc ()) {
ch->SendText ("You find nothing.\n\r");
learn_from_failure (ch, gsn_search);
return;
}
percent = number_percent () + number_percent () - (ch->GetLevel () / 10);
if (door != -1) {
CExitData *pexit;
if ((pexit = get_exit (ch->GetInRoom (), door)) != NULL
&& pexit->IsSecret () && pexit->CanSearch ()
&& can_use_skill (ch, percent, gsn_search)) {
act (AT_SKILL, "Your search reveals the $d!",
ch, NULL, pexit->keyword, TO_CHAR);
act (AT_SKILL, "$n finds the $d!",
ch, NULL, pexit->keyword, TO_ROOM);
pexit->ClrSecret ();
learn_from_success (ch, gsn_search);
return;
}
} else {
POSITION pos = pList->GetHeadPosition ();
while (obj = pList->GetNext (pos)) {
if (obj->IsHidden ()
&& can_use_skill (ch, percent, gsn_search)) {
separate_obj (obj);
obj->ClrHidden ();
act (AT_SKILL, "Your search reveals $p!", ch, obj,NULL,TO_CHAR);
act (AT_SKILL, "$n finds $p!", ch, obj, NULL, TO_ROOM );
learn_from_success (ch, gsn_search);
return;
}
}
}
ch->SendText ("You find nothing.\n\r");
learn_from_failure (ch, gsn_search);
}
void do_steal (CCharacter *ch, char *argument)
{
char buf [MAX_STRING_LENGTH];
char arg1 [MAX_INPUT_LENGTH];
char arg2 [MAX_INPUT_LENGTH];
CCharacter *victim, *mst;
CObjData *obj;
int percent;
argument = one_argument (argument, arg1);
argument = one_argument (argument, arg2);
if (ch->mount)
{
ch->SendText ("You can't do that while mounted.\n\r");
return;
}
if (arg1[0] == '\0' || arg2[0] == '\0')
{
ch->SendText ("Steal what from whom?\n\r");
return;
}
if (ms_find_obj (ch))
return;
if ((victim = get_char_room (ch, arg2)) == NULL)
{
ch->SendText ("They aren't here.\n\r");
return;
}
if (victim == ch)
{
ch->SendText ("That's pointless.\n\r");
return;
}
if (ch->GetInRoom ()->IsSafe ()) {
set_char_color (AT_MAGIC, ch);
ch->SendText ("A magical force interrupts you.\n\r");
return;
}
/* Disabled stealing among players because of complaints naked avatars were
running around stealing eq from equipped pkillers. -- Narn
*/
/* if (check_illegal_psteal (ch, victim))
{
ch->SendText ("You can't steal from that player.\n\r");
return;
}
*/
if (!ch->IsNpc () && !victim->IsNpc ())
{
set_char_color (AT_IMMORT, ch);
ch->SendText ("The gods forbid theft between players.\n\r");
return;
}
WAIT_STATE (ch, SkillTable.GetBeats (gsn_steal));
percent = number_percent () + (victim->IsAwake () ? 10 : -50)
- (get_curr_lck (ch) - 15) + (get_curr_lck (victim) - 13);
/* Changed the level check, made it 10 levels instead of five and made the
victim not attack in the case of a too high level difference. This is
to allow mobprogs where the mob steals eq without having to put level
checks into the progs. Also gave the mobs a 10% chance of failure.
*/
if (ch->GetLevel () + 10 < victim->GetLevel ())
{
ch->SendText ("You really don't want to try that!\n\r");
return;
}
if (victim->GetPosition () == POS_FIGHTING
|| ! can_use_skill (ch, percent, gsn_steal))
{
/*
* Failure.
*/
ch->SendText ("Oops...\n\r");
act (AT_ACTION, "$n tried to steal from you!\n\r", ch, NULL, victim, TO_VICT );
act (AT_ACTION, "$n tried to steal from $N.\n\r", ch, NULL, victim, TO_NOTVICT);
sprintf (buf, "%s is a bloody thief!", ch->GetName ());
do_yell (victim, buf);
learn_from_failure (ch, gsn_steal);
if (!ch->IsNpc ())
{
if (legal_loot (ch, victim))
{
global_retcode = multi_hit (victim, ch, TYPE_UNDEFINED);
}
else
{
/* gpDoc->LogString (buf); */
if (ch->IsNpc ())
{
if ((mst = ch->GetMaster ()) == NULL)
return;
}
else
mst = ch;
if (mst->IsNpc ())
return;
if (! mst->IsThief ())
{
mst->SetThief ();
set_char_color (AT_WHITE, ch);
ch->SendText ("A strange feeling grows deep inside you, and a tingle goes up your spine...\n\r");
set_char_color (AT_IMMORT, ch);
ch->SendText ("A deep voice booms inside your head, 'Thou shall now be known as a lowly thief!'\n\r");
set_char_color (AT_WHITE, ch);
ch->SendText ("You feel as if your soul has been revealed for all to see.\n\r");
save_char_obj (mst);
}
}
}
return;
}
if (!str_cmp (arg1, "coin" )
|| !str_cmp (arg1, "coins")
|| !str_cmp (arg1, "gold" ))
{
int amount;
amount = (int) (victim->GetGold () * number_range (1, 10) / 100);
if (amount <= 0)
{
ch->SendText ("You couldn't get any gold.\n\r");
learn_from_failure (ch, gsn_steal);
return;
}
ch->AddGold (amount);
victim->AddGold (-amount);
ch->SendTextf ("Aha! You got %d gold coins.\n\r", amount);
learn_from_success (ch, gsn_steal);
return;
}
if ((obj = get_obj_carry (victim, arg1)) == NULL)
{
ch->SendText ("You can't seem to find it.\n\r");
learn_from_failure (ch, gsn_steal);
return;
}
if (!can_drop_obj (ch, obj)
|| obj->IsInventory ()
|| obj->IsPrototype ()
|| obj->level > ch->GetLevel ())
{
ch->SendText ("You can't manage to pry it away.\n\r");
learn_from_failure (ch, gsn_steal);
return;
}
if (ch->carry_number + (get_obj_number (obj)/obj->count) > ch->GetMaxItems ())
{
ch->SendText ("You have your hands full.\n\r");
learn_from_failure (ch, gsn_steal);
return;
}
if (ch->GetCarryWeight () + (get_obj_weight (obj)/obj->count) > can_carry_w (ch))
{
ch->SendText ("You can't carry that much weight.\n\r");
learn_from_failure (ch, gsn_steal);
return;
}
separate_obj (obj);
obj_from_char (obj);
obj_to_char (obj, ch);
ch->SendText ("Ok.\n\r");
learn_from_success (ch, gsn_steal);
adjust_favor (ch, 9, 1);
return;
}
void do_backstab (CCharacter *ch, char *argument)
{
char arg[MAX_INPUT_LENGTH];
CCharacter *victim;
CObjData *obj;
int percent;
if (ch->IsNpc () && ch->IsCharmed ())
{
ch->SendText ("You can't do that right now.\n\r");
return;
}
one_argument (argument, arg);
if (ch->mount)
{
ch->SendText ("You can't get close enough while mounted.\n\r");
return;
}
if (arg[0] == '\0')
{
ch->SendText ("Backstab whom?\n\r");
return;
}
if ((victim = get_char_room (ch, arg)) == NULL)
{
ch->SendText ("They aren't here.\n\r");
return;
}
if (victim == ch)
{
ch->SendText ("How can you sneak up on yourself?\n\r");
return;
}
if (is_safe (ch, victim))
return;
/* Added stabbing weapon. -Narn */
if ((obj = get_eq_char (ch, WEAR_WIELD)) == NULL
|| (obj->value[3] != 11 && obj->value[3] != 2))
{
ch->SendText ("You need to wield a piercing or stabbing weapon.\n\r");
return;
}
if (victim->GetFightData ())
{
ch->SendText ("You can't backstab someone who is in combat.\n\r");
return;
}
/* Can backstab a char even if it's hurt as long as it's sleeping. -Narn */
if (victim->GetHp () < victim->GetMaxHp () && victim->IsAwake ())
{
act (AT_PLAIN, "$N is hurt and suspicious ... you can't sneak up.",
ch, NULL, victim, TO_CHAR);
return;
}
percent = number_percent () - (get_curr_lck (ch) - 14)
+ (get_curr_lck (victim) - 13);
check_attacker (ch, victim);
WAIT_STATE (ch, SkillTable.GetBeats (gsn_backstab));
if (!victim->IsAwake ()
|| ch->IsNpc ()
|| can_use_skill( ch, percent, gsn_backstab))
{
learn_from_success (ch, gsn_backstab);
global_retcode = multi_hit (ch, victim, gsn_backstab);
adjust_favor (ch, 10, 1);
check_illegal_pk (ch, victim);
}
else
{
learn_from_failure (ch, gsn_backstab);
global_retcode = damage (ch, victim, 0, gsn_backstab);
}
return;
}
void do_rescue (CCharacter *ch, char *argument)
{
char arg[MAX_INPUT_LENGTH];
CCharacter *victim;
CCharacter *fch;
int percent;
if (ch->IsNpc () && ch->IsCharmed ())
{
ch->SendText ("You can't concentrate enough for that.\n\r");
return;
}
one_argument (argument, arg);
if (arg[0] == '\0')
{
ch->SendText ("Rescue whom?\n\r");
return;
}
if ((victim = get_char_room (ch, arg)) == NULL)
{
ch->SendText ("They aren't here.\n\r");
return;
}
if (victim == ch)
{
ch->SendText ("How about fleeing instead?\n\r");
return;
}
if (ch->mount)
{
ch->SendText ("You can't do that while mounted.\n\r");
return;
}
if (!ch->IsNpc () && victim->IsNpc ())
{
ch->SendText ("Doesn't need your help!\n\r");
return;
}
if (!ch->GetFightData ())
{
ch->SendText ("Too late...\n\r");
return;
}
if ((fch = victim->GetFightWho ()) == NULL)
{
ch->SendText ("They are not fighting right now.\n\r");
return;
}
percent = number_percent () - (get_curr_lck (ch) - 14)
- (get_curr_lck (victim) - 16);
WAIT_STATE (ch, SkillTable.GetBeats (gsn_rescue));
if (! can_use_skill( ch, percent, gsn_rescue))
{
ch->SendText ("You fail the rescue.\n\r");
act (AT_SKILL, "$n tries to rescue you!", ch, NULL, victim, TO_VICT );
act (AT_SKILL, "$n tries to rescue $N!", ch, NULL, victim, TO_NOTVICT);
learn_from_failure (ch, gsn_rescue);
return;
}
act (AT_SKILL, "You rescue $N!", ch, NULL, victim, TO_CHAR );
act (AT_SKILL, "$n rescues you!", ch, NULL, victim, TO_VICT );
act (AT_SKILL, "$n moves in front of $N!", ch, NULL, victim, TO_NOTVICT);
learn_from_success (ch, gsn_rescue);
adjust_favor (ch, 8, 1);
stop_fighting (fch, FALSE);
stop_fighting (victim, FALSE);
if (ch->GetFightData ())
stop_fighting (ch, FALSE);
/* check_killer (ch, fch); */
set_fighting (ch, fch);
set_fighting (fch, ch);
return;
}
void do_kick (CCharacter *ch, char *argument)
{
CCharacter *victim;
if (ch->IsNpc () && ch->IsCharmed ())
{
ch->SendText ("You can't concentrate enough for that.\n\r");
return;
}
if (!ch->IsNpc ()
&& ch->GetLevel () < SkillTable.GetClassLevel (gsn_kick, ch->GetClass ()))
{
ch->SendText (
"You better leave the martial arts to fighters.\n\r");
return;
}
if ((victim = ch->GetFightWho ()) == NULL)
{
ch->SendText ("You aren't fighting anyone.\n\r");
return;
}
WAIT_STATE (ch, SkillTable.GetBeats (gsn_kick));
if (ch->IsNpc () || number_percent () < ch->GetPcData ()->learned[gsn_kick])
{
learn_from_success (ch, gsn_kick);
global_retcode = damage (ch, victim, number_range (1, ch->GetLevel ()), gsn_kick);
}
else
{
learn_from_failure (ch, gsn_kick);
global_retcode = damage (ch, victim, 0, gsn_kick);
}
return;
}
void do_punch (CCharacter *ch, char *argument)
{
CCharacter *victim;
if (ch->IsNpc () && ch->IsCharmed ())
{
ch->SendText ("You can't concentrate enough for that.\n\r");
return;
}
if (!ch->IsNpc ()
&& ch->GetLevel () < SkillTable.GetClassLevel (gsn_punch, ch->GetClass ()))
{
ch->SendText (
"You better leave the martial arts to fighters.\n\r");
return;
}
if ((victim = ch->GetFightWho ()) == NULL)
{
ch->SendText ("You aren't fighting anyone.\n\r");
return;
}
WAIT_STATE (ch, SkillTable.GetBeats (gsn_punch));
if (can_use_skill (ch, number_percent (), gsn_kick))
{
learn_from_success (ch, gsn_punch);
global_retcode = damage (ch, victim, number_range (1, ch->GetLevel ()), gsn_punch);
}
else
{
learn_from_failure (ch, gsn_punch);
global_retcode = damage (ch, victim, 0, gsn_punch);
}
return;
}
void do_bite (CCharacter *ch, char *argument)
{
CCharacter *victim;
if (ch->IsNpc () && ch->IsCharmed ()) {
ch->SendText ("You can't concentrate enough for that.\n\r");
return;
}
if (! ch->IsNpc () && ch->GetLevel () <
SkillTable.GetClassLevel (gsn_bite, ch->GetClass ())) {
ch->SendText ("That isn't quite one of your natural skills.\n\r");
return;
}
if ((victim = ch->GetFightWho ()) == NULL) {
ch->SendText ("You aren't fighting anyone.\n\r");
return;
}
WAIT_STATE (ch, SkillTable.GetBeats (gsn_bite));
if (can_use_skill (ch, number_percent (), gsn_bite)) {
learn_from_success (ch, gsn_bite);
global_retcode =
damage (ch, victim, number_range (1, ch->GetLevel ()), gsn_bite);
} else {
learn_from_failure (ch, gsn_bite);
global_retcode = damage (ch, victim, 0, gsn_bite);
}
}
void do_claw (CCharacter *ch, char *argument)
{
CCharacter *victim;
if (! ch->IsNpc () && ch->GetLevel () <
SkillTable.GetClassLevel (gsn_claw, ch->GetClass ())) {
ch->SendText ("That isn't quite one of your natural skills.\n\r");
return;
}
if ((victim = ch->GetFightWho ()) == NULL) {
ch->SendText ("You aren't fighting anyone.\n\r");
return;
}
WAIT_STATE (ch, SkillTable.GetBeats (gsn_claw));
if (can_use_skill (ch, number_percent (), gsn_claw)) {
learn_from_success (ch, gsn_claw);
global_retcode =
damage (ch, victim, number_range (1, ch->GetLevel ()), gsn_claw);
} else {
learn_from_failure (ch, gsn_claw);
global_retcode = damage (ch, victim, 0, gsn_claw);
}
}
void do_sting (CCharacter *ch, char *argument)
{
CCharacter *victim;
if (ch->IsNpc () && ch->IsCharmed ()) {
ch->SendText ("You can't concentrate enough for that.\n\r");
return;
}
if (! ch->IsNpc () && ch->GetLevel () <
SkillTable.GetClassLevel (gsn_sting, ch->GetClass ())) {
ch->SendText ("That isn't quite one of your natural skills.\n\r");
return;
}
if ((victim = ch->GetFightWho ()) == NULL) {
ch->SendText ("You aren't fighting anyone.\n\r");
return;
}
WAIT_STATE (ch, SkillTable.GetBeats (gsn_sting));
if (can_use_skill (ch, number_percent (), gsn_sting)) {
learn_from_success (ch, gsn_sting);
global_retcode =
damage (ch, victim, number_range (1, ch->GetLevel ()), gsn_sting);
} else {
learn_from_failure (ch, gsn_sting);
global_retcode = damage (ch, victim, 0, gsn_sting);
}
}
void do_tail (CCharacter *ch, char *argument)
{
CCharacter *victim;
if (ch->IsNpc () && ch->IsCharmed ()) {
ch->SendText ("You can't concentrate enough for that.\n\r");
return;
}
if (! ch->IsNpc () && ch->GetLevel () <
SkillTable.GetClassLevel (gsn_tail, ch->GetClass ())) {
ch->SendText ("That isn't quite one of your natural skills.\n\r");
return;
}
if ((victim = ch->GetFightWho ()) == NULL) {
ch->SendText ("You aren't fighting anyone.\n\r");
return;
}
WAIT_STATE (ch, SkillTable.GetBeats (gsn_tail));
if (can_use_skill (ch, number_percent (), gsn_tail)) {
learn_from_success (ch, gsn_tail);
global_retcode =
damage (ch, victim, number_range (1, ch->GetLevel ()), gsn_tail);
} else {
learn_from_failure (ch, gsn_tail);
global_retcode = damage (ch, victim, 0, gsn_tail);
}
}
void do_bash (CCharacter *ch, char *argument)
{
CCharacter *victim;
if (ch->IsNpc () && ch->IsCharmed ()) {
ch->SendText ("You can't concentrate enough for that.\n\r");
return;
}
if (! ch->IsNpc () && ch->GetLevel () <
SkillTable.GetClassLevel (gsn_bash, ch->GetClass ())) {
ch->SendText ("You better leave the martial arts to fighters.\n\r");
return;
}
if ((victim = ch->GetFightWho ()) == NULL) {
ch->SendText ("You aren't fighting anyone.\n\r");
return;
}
int chance = (((victim->GetDexterity () + victim->GetCurrentStrength ())
- (ch->GetDexterity () + ch->GetCurrentStrength ())) * 10) + 10;
if (! ch->IsNpc () && !victim->IsNpc ())
chance += 25;
if (victim->GetFightData () && victim->GetFightData ()->who != ch)
chance += 19;
WAIT_STATE (ch, SkillTable.GetBeats (gsn_bash));
if (can_use_skill (ch, (number_percent () + chance), gsn_bash)) {
learn_from_success (ch, gsn_bash);
// do not change anything here! -Thoric
WAIT_STATE (ch, 2 * PULSE_VIOLENCE);
WAIT_STATE (victim, 2 * PULSE_VIOLENCE);
victim->SetPosition (POS_SITTING);
global_retcode =
damage (ch, victim, number_range (1, ch->GetLevel ()), gsn_bash);
} else {
WAIT_STATE (ch, 2 * PULSE_VIOLENCE);
learn_from_failure (ch, gsn_bash);
global_retcode = damage (ch, victim, 0, gsn_bash);
}
}
void do_stun (CCharacter *ch, char *argument)
{
CCharacter *victim;
CAffectData af;
if (ch->IsNpc () && ch->IsCharmed ()) {
ch->SendText ("You can't concentrate enough for that.\n\r");
return;
}
if (! ch->IsNpc () && ch->GetLevel () <
SkillTable.GetClassLevel (gsn_stun, ch->GetClass ())) {
ch->SendText ("You better leave the martial arts to fighters.\n\r");
return;
}
if ((victim = ch->GetFightWho ()) == NULL) {
ch->SendText ("You aren't fighting anyone.\n\r");
return;
}
if (ch->GetMove () < 16) {
set_char_color (AT_SKILL, ch);
ch->SendText ("You are far too tired to do that.\n\r");
return;
}
WAIT_STATE (ch, SkillTable.GetBeats (gsn_stun));
BOOL fail = FALSE;
int chance = ris_save (victim, ch->GetLevel (), RIS_PARALYSIS);
if (chance == 1000)
fail = TRUE;
else
fail = saves_para_petri (chance, victim);
chance = (((victim->GetDexterity () + victim->GetCurrentStrength ())
- (ch->GetDexterity () + ch->GetCurrentStrength ())) * 10) + 10;
// harder for player to stun another player
if (!ch->IsNpc () && !victim->IsNpc ())
chance += SysData.StunPlayerLev;
else
chance += SysData.StunRegularLev;
if (!fail && can_use_skill (ch, (number_percent () + chance), gsn_stun)) {
learn_from_success (ch, gsn_stun);
// DO *NOT* CHANGE! -Thoric
ch->AddMove (-15);
WAIT_STATE (ch, 2 * PULSE_VIOLENCE);
WAIT_STATE (victim, PULSE_VIOLENCE);
act (AT_SKILL, "$N smashes into you, leaving you stunned!",
victim, NULL, ch, TO_CHAR);
act (AT_SKILL, "You smash into $N, leaving $M stunned!",
ch, NULL, victim, TO_CHAR);
act (AT_SKILL, "$n smashes into $N, leaving $M stunned!",
ch, NULL, victim, TO_NOTVICT);
if (! victim->IsParalysed ()) {
af.type = gsn_stun;
af.location = APPLY_AC;
af.modifier = 20;
af.duration = 3;
af.bitvector = AFF_PARALYSIS;
affect_to_char (victim, &af);
update_pos (victim);
}
} else {
WAIT_STATE (ch, 2 * PULSE_VIOLENCE);
ch->AddMove (-5);
learn_from_failure (ch, gsn_stun);
act (AT_SKILL, "$N charges at you screaming, but you dodge out "
"of the way.", victim, NULL, ch, TO_CHAR);
act (AT_SKILL, "You try to stun $N, but $E dodges out of the way.",
ch, NULL, victim, TO_CHAR);
act (AT_SKILL, "$n charges screaming at $N, but keeps going right "
"on past.", ch, NULL, victim, TO_NOTVICT);
}
}
void do_bloodlet (CCharacter *ch, char *argument)
{
CObjData *obj;
if (ch->IsNpc () || ! ch->IsVampire ())
return;
if (ch->GetFightWho ()) {
ch->SendText ("You're too busy fighting...\n\r");
return;
}
if (ch->GetPcData ()->condition [COND_BLOODTHIRST] < 10) {
ch->SendText ("You are too drained to offer any blood...\n\r");
return;
}
WAIT_STATE (ch, PULSE_VIOLENCE);
if (can_use_skill (ch, number_percent (), gsn_bloodlet)) {
gain_condition (ch, COND_BLOODTHIRST, -7);
act (AT_BLOOD, "Tracing a sharp nail over your skin, you let your "
"blood spill.", ch, NULL, NULL, TO_CHAR);
act (AT_BLOOD, "$n traces a sharp nail over $s skin, spilling a "
"quantity of blood to the ground.", ch, NULL, NULL, TO_ROOM);
learn_from_success (ch, gsn_bloodlet);
obj = create_object (OIdxTable.GetObj (OBJ_VNUM_BLOODLET), 0);
obj->timer = 1;
obj->value [1] = 6;
obj_to_room (obj, ch->GetInRoom ());
} else {
act (AT_BLOOD, "You cannot manage to draw much blood...",
ch, NULL, NULL, TO_CHAR);
act (AT_BLOOD, "$n slices open $s skin, but no blood is spilled...",
ch, NULL, NULL, TO_ROOM);
learn_from_failure (ch, gsn_bloodlet);
}
}
void do_feed (CCharacter *ch, char *argument)
{
CCharacter *victim;
short dam;
if (ch->IsNpc () && ch->IsCharmed ())
{
ch->SendText ("You can't concentrate enough for that.\n\r");
return;
}
if (!ch->IsNpc ()
&& !ch->IsVampire ())
{
ch->SendText ("It is not of your nature to feed on living creatures.\n\r");
return;
}
if (! can_use_skill (ch, 0, gsn_feed))
{
ch->SendText ("You have not yet practiced your new teeth.\n\r");
return;
}
if ((victim = ch->GetFightWho ()) == NULL)
{
ch->SendText ("You aren't fighting anyone.\n\r");
return;
}
if (ch->mount)
{
ch->SendText ("You can't do that while mounted.\n\r");
return;
}
WAIT_STATE (ch, SkillTable.GetBeats (gsn_feed));
if (can_use_skill (ch, number_percent (), gsn_feed))
{
dam = number_range (1, ch->GetLevel ());
global_retcode = damage (ch, victim, dam, gsn_feed);
if (global_retcode == rNONE && !ch->IsNpc () && dam
&& ch->GetFightData ()
&& ch->GetPcData ()->condition[COND_BLOODTHIRST] < (10 + ch->GetLevel ()))
{
gain_condition (ch, COND_BLOODTHIRST,
UMIN (number_range (1, (ch->GetLevel ()+victim->GetLevel () / 20) + 3),
(10 + ch->GetLevel ()) - ch->GetPcData ()->condition[COND_BLOODTHIRST]));
gain_condition (ch, COND_FULL, 2);
gain_condition (ch, COND_THIRST, 2);
act (AT_BLOOD, "You manage to suck a little life out of $N.", ch, NULL,
victim, TO_CHAR);
act (AT_BLOOD, "$n sucks some of your blood!", ch, NULL, victim, TO_VICT);
learn_from_success (ch, gsn_feed);
}
}
else
{
global_retcode = damage (ch, victim, 0, gsn_feed);
if (global_retcode == rNONE && !ch->IsNpc ()
&& ch->GetFightData ()
&& ch->GetPcData ()->condition[COND_BLOODTHIRST] < (10 + ch->GetLevel ()))
{
act (AT_BLOOD, "The smell of $N's blood is driving you insane!",
ch, NULL, victim, TO_CHAR);
act (AT_BLOOD, "$n is lusting after your blood!", ch, NULL, victim, TO_VICT);
learn_from_failure (ch, gsn_feed);
}
}
return;
}
// Disarm a creature.
// Caller must check for successful attack.
// Check for loyalty flag (weapon disarms to inventory) for pkillers -Blodkai
void disarm (CCharacter *ch, CCharacter *victim)
{
CObjData *obj, *tmpobj;
if ((obj = get_eq_char (victim, WEAR_WIELD)) == NULL)
return;
if ((tmpobj = get_eq_char (victim, WEAR_DUAL_WIELD))
&& number_bits (1) == 0)
obj = tmpobj;
if (get_eq_char (ch, WEAR_WIELD) == NULL && number_bits (1) == 0) {
learn_from_failure (ch, gsn_disarm);
return;
}
if (ch->IsNpc () && !can_see_obj (ch, *obj) && number_bits (1) == 0) {
learn_from_failure (ch, gsn_disarm);
return;
}
if (check_grip (ch, victim)) {
learn_from_failure (ch, gsn_disarm);
return;
}
act (AT_SKILL, "$n DISARMS you!", ch, NULL, victim, TO_VICT);
act (AT_SKILL, "You disarm $N!", ch, NULL, victim, TO_CHAR);
act (AT_SKILL, "$n disarms $N!", ch, NULL, victim, TO_NOTVICT);
learn_from_success (ch, gsn_disarm);
if (obj == get_eq_char (victim, WEAR_WIELD)
&& (tmpobj = get_eq_char (victim, WEAR_DUAL_WIELD)) != NULL)
tmpobj->wear_loc = WEAR_WIELD;
obj_from_char (obj);
if (victim->IsNpc () || (obj->IsLoyal () && victim->IsPkiller ()))
obj_to_char (obj, victim);
else
obj_to_room (obj, victim->GetInRoom ());
}
void do_disarm (CCharacter *ch, char *argument)
{
CCharacter *victim;
CObjData *obj;
int percent;
if (ch->IsNpc () && ch->IsCharmed ()) {
ch->SendText ("You can't concentrate enough for that.\n\r");
return;
}
if (! ch->IsNpc () && ch->GetLevel ()
< SkillTable.GetClassLevel (gsn_disarm, ch->GetClass ())) {
ch->SendText ("You don't know how to disarm opponents.\n\r");
return;
}
if (get_eq_char (ch, WEAR_WIELD) == NULL) {
ch->SendText ("You must wield a weapon to disarm.\n\r");
return;
}
if ((victim = ch->GetFightWho ()) == NULL) {
ch->SendText ("You aren't fighting anyone.\n\r");
return;
}
if ((obj = get_eq_char (victim, WEAR_WIELD)) == NULL) {
ch->SendText ("Your opponent is not wielding a weapon.\n\r");
return;
}
WAIT_STATE (ch, SkillTable.GetBeats (gsn_disarm));
percent = number_percent () + victim->GetLevel () - ch->GetLevel ()
- (get_curr_lck (ch) - 15) + (get_curr_lck (victim) - 15);
if (! can_see_obj (ch, *obj))
percent += 10;
if (can_use_skill (ch, (percent*3/2), gsn_disarm))
disarm (ch, victim);
else {
ch->SendText ("You failed.\n\r");
learn_from_failure (ch, gsn_disarm);
}
}
// Trip a creature.
// Caller must check for successful attack.
void trip (CCharacter *ch, CCharacter *victim)
{
if (victim->IsFlying ()
|| victim->IsFloating ())
return;
if (victim->mount)
{
if (victim->mount->IsFlying ()
|| victim->mount->IsFloating ())
return;
act (AT_SKILL, "$n trips your mount and you fall off!", ch, NULL, victim, TO_VICT );
act (AT_SKILL, "You trip $N's mount and $N falls off!", ch, NULL, victim, TO_CHAR );
act (AT_SKILL, "$n trips $N's mount and $N falls off!", ch, NULL, victim, TO_NOTVICT);
victim->mount->ClrActBit (ACT_MOUNTED);
victim->mount = NULL;
WAIT_STATE (ch, 2 * PULSE_VIOLENCE);
WAIT_STATE (victim, 2 * PULSE_VIOLENCE);
victim->SetPosition (POS_RESTING);
return;
}
if (victim->GetWait () == 0)
{
act (AT_SKILL, "$n trips you and you go down!", ch, NULL, victim, TO_VICT );
act (AT_SKILL, "You trip $N and $N goes down!", ch, NULL, victim, TO_CHAR );
act (AT_SKILL, "$n trips $N and $N goes down!", ch, NULL, victim, TO_NOTVICT);
WAIT_STATE (ch, 2 * PULSE_VIOLENCE);
WAIT_STATE (victim, 2 * PULSE_VIOLENCE);
victim->SetPosition (POS_RESTING);
}
return;
}
// Converted to function well as a skill for vampires -- Blodkai
void do_mistwalk (CCharacter *ch, char *argument)
{
char arg [MAX_INPUT_LENGTH];
CCharacter *victim;
bool allowday;
set_char_color (AT_DGREEN, ch);
if (ch->IsNpc () && ch->IsCharmed ()) {
ch->SendText ("You can't do that right now.\n\r");
return;
}
if (ch->mount) {
ch->SendText ("And scare your mount to death?\n\r");
return;
}
one_argument (argument, arg);
if (arg [0] == '\0') {
ch->SendText ("Who will be your victim?\n\r");
return;
}
WAIT_STATE (ch, SkillTable.GetBeats (gsn_mistwalk));
if ((victim = get_char_world (ch, arg)) == NULL || victim == ch) {
ch->SendText ("You are unable to sense your victim.\n\r");
return;
}
allowday =
(ch->IsPkiller () &&
ch->GetPcData ()->condition [COND_BLOODTHIRST] > 22);
CRoomIndexData *pRoom = victim->GetInRoom ();
if ((time_info.hour < 21 && time_info.hour > 5 && !allowday)
|| ! pRoom
|| pRoom->IsPrivate ()
|| pRoom->IsSolitary ()
|| pRoom->IsNoAstral ()
|| pRoom->IsDeathRoom ()
|| pRoom->IsPrototype ()
|| pRoom->IsNoRecall ()
|| victim->GetLevel () >= ch->GetLevel () + 15
|| (victim->IsNpc () && victim->IsPrototype ())
|| (victim->IsNpc () && saves_spell_staff (ch->GetLevel (), victim))
|| (victim->CanPkill () && ! ch->IsNpc () && ! ch->CanPkill ())
|| ! in_hard_range (ch, pRoom->GetArea ())
|| (pRoom->GetArea ()->IsNoPkill () && ch->IsPkiller ())) {
ch->SendText ("You are unable to sense your victim.\n\r");
learn_from_failure (ch, gsn_mistwalk);
return;
}
// Subtract 22 extra bp for mist walk from 0500 to 2100 SB
if (time_info.hour < 21 && time_info.hour > 5 && ! ch->IsNpc ())
gain_condition (ch, COND_BLOODTHIRST, - 22);
act (AT_DGREEN, "Your surroundings blur as you assume a form of "
"churning mist!", ch, NULL, NULL, TO_CHAR);
act (AT_DGREEN, "$n dissolves into a cloud of glowing mist, then "
"vanishes!", ch, NULL, NULL, TO_ROOM);
learn_from_success (ch, gsn_mistwalk);
ch->RemoveFromRoom ();
ch->SendToRoom (pRoom);
act (AT_DGREEN, "A cloud of glowing mist engulfs you, then withdraws "
"to unveil $n!", ch, NULL, NULL, TO_ROOM);
do_look (ch, "auto");
}
void do_broach (CCharacter *ch, char *argument)
{
char arg [MAX_INPUT_LENGTH];
CExitData *pexit;
set_char_color (AT_DGREEN, ch);
if (ch->IsNpc () && ch->IsCharmed ()) {
ch->SendText ("You can't concentrate enough for that.\n\r");
return;
}
one_argument (argument, arg);
if (arg [0] == '\0') {
ch->SendText ("Attempt this in which direction?\n\r");
return;
}
if (ch->mount) {
ch->SendText ("You should really dismount first.\n\r");
return;
}
WAIT_STATE (ch, SkillTable.GetBeats (gsn_broach));
if (pexit = find_door (ch, arg, TRUE)) {
CExitData *pexit_rev;
if (! pexit->IsClosed () || ! pexit->IsLocked ()
|| pexit->IsPickProof ()
|| can_use_skill (ch, number_percent (), gsn_broach)) {
ch->SendText ("Your attempt fails.\n\r");
learn_from_failure (ch, gsn_broach);
check_room_for_traps (ch, TRAP_PICK | trap_door[pexit->vdir]);
return;
}
pexit->ClrLocked ();
ch->SendText ("You successfully broach the exit...\n\r");
learn_from_success (ch, gsn_broach);
adjust_favor (ch, 9, 1);
if ((pexit_rev = pexit->rexit) != NULL
&& pexit_rev->GetToRoom () == ch->GetInRoom ())
pexit_rev->ClrLocked ();
check_room_for_traps (ch, TRAP_PICK | trap_door [pexit->vdir]);
return;
}
ch->SendText ("Your attempt fails.\n\r");
}
void do_pick (CCharacter *ch, char *argument)
{
char arg [MAX_INPUT_LENGTH];
CCharacter *gch;
CObjData *obj;
CExitData *pexit;
if (ch->IsNpc () && ch->IsCharmed ()) {
ch->SendText ("You can't concentrate enough for that.\n\r");
return;
}
one_argument (argument, arg);
if (arg [0] == '\0') {
ch->SendText ("Pick what?\n\r");
return;
}
if (ms_find_obj (ch))
return;
if (ch->mount) {
ch->SendText ("You can't do that while mounted.\n\r");
return;
}
WAIT_STATE (ch, SkillTable.GetBeats (gsn_pick_lock));
// look for guards
gch = ch->GetInRoom ()->first_person;
for ( ; gch; gch = gch->GetNextInRoom ()) {
if (gch->IsNpc ()
&& gch->IsAwake () && ch->GetLevel () + 5 < gch->GetLevel ()) {
act (AT_PLAIN, "$N is standing too close to the lock.",
ch, NULL, gch, TO_CHAR);
return;
}
}
if (! can_use_skill (ch, number_percent (), gsn_pick_lock)) {
ch->SendText ("You failed.\n\r");
learn_from_failure (ch, gsn_pick_lock);
return;
}
if ((pexit = find_door (ch, arg, TRUE)) != NULL) {
// 'pick door'
CExitData *pexit_rev;
if (! pexit->IsClosed ()) {
ch->SendText ("It's not closed.\n\r");
return;
}
if (pexit->key < 0) {
ch->SendText ("It can't be picked.\n\r");
return;
}
if (! pexit->IsLocked ()) {
ch->SendText ("It's already unlocked.\n\r");
return;
}
if (pexit->IsPickProof ()) {
ch->SendText ("You failed.\n\r");
learn_from_failure (ch, gsn_pick_lock);
check_room_for_traps (ch, TRAP_PICK | trap_door[pexit->vdir]);
return;
}
pexit->ClrLocked ();
ch->SendText ("*Click*\n\r");
act (AT_ACTION, "$n picks the $d.", ch, NULL, pexit->keyword, TO_ROOM);
learn_from_success (ch, gsn_pick_lock);
adjust_favor (ch, 9, 1);
// pick the other side
if ((pexit_rev = pexit->rexit) != NULL
&& pexit_rev->GetToRoom () == ch->GetInRoom ()) {
pexit_rev->ClrLocked ();
}
check_room_for_traps (ch, TRAP_PICK | trap_door[pexit->vdir]);
return;
}
if ((obj = get_obj_here (ch, arg)) != NULL) {
// 'pick object'
if (obj->item_type != ITEM_CONTAINER) {
ch->SendText ("That's not a container.\n\r");
return;
}
if (! IS_SET (obj->value[1], CONT_CLOSED)) {
ch->SendText ("It's not closed.\n\r");
return;
}
if (obj->value [2] < 0) {
ch->SendText ("It can't be unlocked.\n\r");
return;
}
if (! IS_SET (obj->value [1], CONT_LOCKED)) {
ch->SendText ("It's already unlocked.\n\r");
return;
}
if (IS_SET (obj->value [1], CONT_PICKPROOF)) {
ch->SendText ("You failed.\n\r");
learn_from_failure (ch, gsn_pick_lock);
check_for_trap (ch, obj, TRAP_PICK);
return;
}
separate_obj (obj);
REMOVE_BIT (obj->value [1], CONT_LOCKED);
ch->SendText ("*Click*\n\r");
act (AT_ACTION, "$n picks $p.", ch, obj, NULL, TO_ROOM);
learn_from_success (ch, gsn_pick_lock);
adjust_favor (ch, 9, 1);
check_for_trap (ch, obj, TRAP_PICK);
return;
}
ch->SendTextf ("You see no %s here.\n\r", arg);
}
void do_sneak (CCharacter *ch, char *argument)
{
CAffectData af;
if (ch->IsNpc () && ch->IsCharmed ())
{
ch->SendText ("You can't concentrate enough for that.\n\r");
return;
}
if (ch->mount)
{
ch->SendText ("You can't do that while mounted.\n\r");
return;
}
ch->SendText ("You attempt to move silently.\n\r");
affect_strip (ch, gsn_sneak);
if (can_use_skill (ch, number_percent (), gsn_sneak))
{
af.type = gsn_sneak;
af.duration = (short) (ch->GetLevel () * DUR_CONV);
af.location = APPLY_NONE;
af.modifier = 0;
af.bitvector = AFF_SNEAK;
affect_to_char (ch, &af);
learn_from_success (ch, gsn_sneak);
}
else
learn_from_failure (ch, gsn_sneak);
return;
}
void do_hide (CCharacter *ch, char *argument)
{
if (ch->IsNpc () && ch->IsCharmed ())
{
ch->SendText ("You can't concentrate enough for that.\n\r");
return;
}
if (ch->mount)
{
ch->SendText ("You can't do that while mounted.\n\r");
return;
}
ch->SendText ("You attempt to hide.\n\r");
if (ch->IsHidden ())
ch->ClrHide ();
if (can_use_skill (ch, number_percent (), gsn_hide))
{
ch->SetHide ();
learn_from_success (ch, gsn_hide);
}
else
learn_from_failure (ch, gsn_hide);
return;
}
// Contributed by Alander.
void do_visible (CCharacter *ch, char *argument)
{
affect_strip (ch, gsn_invis);
affect_strip (ch, gsn_mass_invis);
affect_strip (ch, gsn_sneak);
ch->ClrHide ();
ch->ClrInvis ();
if (! RaceTable.IsAffected (ch->GetRace (), AFF_SNEAK))
ch->ClrSneak ();
ch->SendText ("Ok.\n\r");
}
void do_recall (CCharacter *ch, char *argument)
{
CRoomIndexData *location;
CCharacter *opponent;
location = NULL;
if (!ch->IsNpc () && ch->GetPcData ()->GetClan ())
location = RoomTable.GetRoom (ch->GetPcData ()->GetClan ()->recall);
if (! location) // 1998-01-02, h
location =
RoomTable.GetRoom (RaceTable.GetRaceRecall (ch->GetRace ()));
if (! location)
location = RoomTable.GetRoom (SysData.m_RoomTemple);
if (! location) {
ch->SendText ("You are completely lost.\n\r");
return;
}
if (ch->GetInRoom () == location)
return;
if (ch->GetInRoom ()->IsNoRecall ()) {
ch->SendText ("For some strange reason... nothing happens.\n\r");
return;
}
if (ch->IsCursed ()) {
ch->SendText ("You are cursed and cannot recall!\n\r");
return;
}
if (opponent = ch->GetFightWho ()) {
int lose;
if (number_bits (1) == 0
|| (!opponent->IsNpc () && number_bits (3) > 1)) {
WAIT_STATE (ch, 4);
lose = (int) ((exp_level (ch, ch->GetLevel ()+1) -
exp_level (ch, ch->GetLevel ())) * 0.1);
if (ch->GetDesc ())
lose /= 2;
gain_exp (ch, 0 - lose);
ch->SendTextf ("You failed! You lose %d exps.\n\r", lose);
return;
}
lose = (int) ((exp_level (ch, ch->GetLevel ()+1) -
exp_level (ch, ch->GetLevel ())) * 0.2);
if (ch->GetDesc ())
lose /= 2;
gain_exp (ch, 0 - lose);
ch->SendTextf ("You recall from combat! You lose %d exps.\n\r",lose);
stop_fighting (ch, TRUE);
}
act (AT_ACTION, "$n disappears in a swirl of smoke.", ch, NULL, NULL,
TO_ROOM);
ch->RemoveFromRoom ();
ch->SendToRoom (location);
if (ch->mount) {
ch->mount->RemoveFromRoom ();
ch->mount->SendToRoom (location);
}
act (AT_ACTION, "$n appears in the room.", ch, NULL, NULL, TO_ROOM);
do_look (ch, "auto");
}
void do_aid (CCharacter *ch, char *argument)
{
char arg[MAX_INPUT_LENGTH];
CCharacter *victim;
int percent;
if (ch->IsNpc () && ch->IsCharmed ())
{
ch->SendText ("You can't concentrate enough for that.\n\r");
return;
}
one_argument (argument, arg);
if (arg[0] == '\0')
{
ch->SendText ("Aid whom?\n\r");
return;
}
if ((victim = get_char_room (ch, arg)) == NULL)
{
ch->SendText ("They aren't here.\n\r");
return;
}
if (ch->mount)
{
ch->SendText ("You can't do that while mounted.\n\r");
return;
}
if (victim == ch)
{
ch->SendText ("Aid yourself?\n\r");
return;
}
if (victim->GetPosition () > POS_STUNNED)
{
act (AT_PLAIN, "$N doesn't need your help.", ch, NULL, victim,
TO_CHAR);
return;
}
if (victim->GetHp () <= -6)
{
act (AT_PLAIN, "$N's condition is beyond your aiding ability.", ch,
NULL, victim, TO_CHAR);
return;
}
percent = number_percent () - (get_curr_lck (ch) - 13);
WAIT_STATE (ch, SkillTable.GetBeats (gsn_aid));
if (! can_use_skill (ch, percent, gsn_aid))
{
ch->SendText ("You fail.\n\r");
learn_from_failure (ch, gsn_aid);
return;
}
act (AT_SKILL, "You aid $N!", ch, NULL, victim, TO_CHAR );
act (AT_SKILL, "$n aids $N!", ch, NULL, victim, TO_NOTVICT);
learn_from_success (ch, gsn_aid);
adjust_favor (ch, 8, 1);
if (victim->GetHp () < 1)
victim->SetHp (1);
update_pos (victim);
act (AT_SKILL, "$n aids you!", ch, NULL, victim, TO_VICT );
return;
}
void do_mount (CCharacter *ch, char *argument)
{
CCharacter *victim;
if (!ch->IsNpc ()
&& ch->GetLevel () < SkillTable.GetClassLevel (gsn_mount, ch->GetClass ()))
{
ch->SendText (
"I don't think that would be a good idea...\n\r");
return;
}
if (ch->mount)
{
ch->SendText ("You're already mounted!\n\r");
return;
}
if ((victim = get_char_room (ch, argument)) == NULL)
{
ch->SendText ("You can't find that here.\n\r");
return;
}
if (!victim->IsNpc () || ! victim->IsAction (ACT_MOUNTABLE))
{
ch->SendText ("You can't mount that!\n\r");
return;
}
if (victim->IsAction (ACT_MOUNTED))
{
ch->SendText ("That mount already has a rider.\n\r");
return;
}
if (victim->GetPosition () < POS_STANDING)
{
ch->SendText ("Your mount must be standing.\n\r");
return;
}
if (victim->GetPosition () == POS_FIGHTING || victim->GetFightData ())
{
ch->SendText ("Your mount is moving around too much.\n\r");
return;
}
WAIT_STATE (ch, SkillTable.GetBeats (gsn_mount));
if (can_use_skill (ch, number_percent (), gsn_mount))
{
victim->SetActBit (ACT_MOUNTED);
ch->mount = victim;
act (AT_SKILL, "You mount $N.", ch, NULL, victim, TO_CHAR);
act (AT_SKILL, "$n skillfully mounts $N.", ch, NULL, victim, TO_NOTVICT);
act (AT_SKILL, "$n mounts you.", ch, NULL, victim, TO_VICT);
learn_from_success (ch, gsn_mount);
ch->SetPosition (POS_MOUNTED);
}
else
{
act (AT_SKILL, "You unsuccessfully try to mount $N.", ch, NULL, victim, TO_CHAR);
act (AT_SKILL, "$n unsuccessfully attempts to mount $N.", ch, NULL, victim, TO_NOTVICT);
act (AT_SKILL, "$n tries to mount you.", ch, NULL, victim, TO_VICT);
learn_from_failure (ch, gsn_mount);
}
return;
}
void do_dismount (CCharacter *ch, char *argument)
{
CCharacter *victim;
if ((victim = ch->mount) == NULL)
{
ch->SendText ("You're not mounted.\n\r");
return;
}
WAIT_STATE (ch, SkillTable.GetBeats (gsn_mount));
if (can_use_skill (ch, number_percent (), gsn_mount))
{
act (AT_SKILL, "You dismount $N.", ch, NULL, victim, TO_CHAR);
act (AT_SKILL, "$n skillfully dismounts $N.", ch, NULL, victim, TO_NOTVICT);
act (AT_SKILL, "$n dismounts you. Whew!", ch, NULL, victim, TO_VICT);
victim->ClrActBit (ACT_MOUNTED);
ch->mount = NULL;
ch->SetPosition (POS_STANDING);
learn_from_success (ch, gsn_mount);
}
else
{
act (AT_SKILL, "You fall off while dismounting $N. Ouch!", ch, NULL, victim, TO_CHAR);
act (AT_SKILL, "$n falls off of $N while dismounting.", ch, NULL, victim, TO_NOTVICT);
act (AT_SKILL, "$n falls off your back.", ch, NULL, victim, TO_VICT);
learn_from_failure (ch, gsn_mount);
victim->ClrActBit (ACT_MOUNTED);
ch->mount = NULL;
ch->SetPosition (POS_SITTING);
global_retcode = damage (ch, ch, 1, TYPE_UNDEFINED);
}
return;
}
/**************************************************************************/
// Check for parry.
BOOL check_parry (CCharacter *ch, CCharacter *victim)
{
int chances;
if (! victim->IsAwake ())
return FALSE;
if (victim->IsNpc () && ! victim->CanParry ())
return FALSE;
if (victim->IsNpc ()) {
// Tuan was here. :)
chances = UMIN (60, 2 * victim->GetLevel ());
} else {
if (get_eq_char (victim, WEAR_WIELD) == NULL)
return FALSE;
chances = (int) (victim->GetPcData ()->learned [gsn_parry] / 2);
}
// Put in the call to chance () to allow penalties for misaligned
// clannies.
if (! chance (victim, chances + victim->GetLevel () - ch->GetLevel ())) {
learn_from_failure (victim, gsn_parry);
return FALSE;
}
if (! victim->IsNpc () && ! victim->IsGagged ()) // SB
act (AT_SKILL, "You parry $n's attack.", ch, NULL, victim, TO_VICT);
if (! ch->IsNpc () && ! ch->IsGagged ()) // SB
act (AT_SKILL, "$N parries your attack.", ch, NULL, victim, TO_CHAR);
learn_from_success (victim, gsn_parry);
return TRUE;
}
// Check for dodge.
BOOL check_dodge (CCharacter *ch, CCharacter *victim)
{
int chances;
if (! victim->IsAwake ())
return FALSE;
if (victim->IsNpc () && ! victim->CanDodge ())
return FALSE;
if (victim->IsNpc ())
chances = UMIN (60, 2 * victim->GetLevel ());
else
chances = (int) (victim->GetPcData ()->learned [gsn_dodge] / 2);
// Consider luck as a factor
if (! chance (victim, chances + victim->GetLevel () - ch->GetLevel ())) {
learn_from_failure (victim, gsn_dodge);
return FALSE;
}
if (! victim->IsNpc () && ! victim->IsGagged ())
act (AT_SKILL, "You dodge $n's attack.", ch, NULL, victim, TO_VICT);
if (! ch->IsNpc () && ! ch->IsGagged ())
act (AT_SKILL, "$N dodges your attack.", ch, NULL, victim, TO_CHAR);
learn_from_success (victim, gsn_dodge);
return TRUE;
}
void do_poison_weapon (CCharacter *ch, char *argument)
{
CObjData *obj;
CObjData *pobj;
CObjData *wobj;
char arg [ MAX_INPUT_LENGTH ];
int percent;
if (!ch->IsNpc ()
&& ch->GetLevel () < SkillTable.GetClassLevel (gsn_poison_weapon, ch->GetClass ()))
{
ch->SendText ("What do you think you are, a thief?\n\r");
return;
}
one_argument (argument, arg);
if (arg[0] == '\0')
{
ch->SendText ("What are you trying to poison?\n\r");
return;
}
if (ch->GetFightData ())
{
ch->SendText ("While you're fighting? Nice try.\n\r");
return;
}
if (ms_find_obj (ch))
return;
if (! (obj = get_obj_carry (ch, arg)))
{
ch->SendText ("You do not have that weapon.\n\r");
return;
}
if (obj->item_type != ITEM_WEAPON)
{
ch->SendText ("That item is not a weapon.\n\r");
return;
}
if (obj->IsPoisoned ())
{
ch->SendText ("That weapon is already poisoned.\n\r");
return;
}
// Now we have a valid weapon...check to see if we have the powder.
POSITION Cpos = ch->GetHeadCarryPos ();
while (pobj = ch->GetNextCarrying (Cpos)) {
if (pobj->pIndexData->vnum == OBJ_VNUM_BLACK_POWDER)
break;
}
if (! pobj) {
ch->SendText ("You do not have the black poison powder.\n\r");
return;
}
// Okay, we have the powder...do we have water?
Cpos = ch->GetHeadCarryPos ();
while (wobj = ch->GetNextCarrying (Cpos)) {
if (wobj->item_type == ITEM_DRINK_CON
&& wobj->value [1] > 0 && wobj->value [2] == 0)
break;
}
if (! wobj) {
ch->SendText ("You have no water to mix with the powder.\n\r");
return;
}
/* Great, we have the ingredients...but is the thief smart enough? */
if (!ch->IsNpc () && ch->GetWisdom () < 16)
{
ch->SendText ("You can't quite remember what to do...\n\r");
return;
}
/* And does the thief have steady enough hands? */
if (!ch->IsNpc ()
&& ((ch->GetDexterity () < 17) || ch->GetPcData ()->condition[COND_DRUNK] > 0))
{
ch->SendText ("Your hands aren't steady enough to properly mix the poison.\n\r");
return;
}
WAIT_STATE (ch, SkillTable.GetBeats (gsn_poison_weapon));
percent = (number_percent () - get_curr_lck (ch) - 14);
/* Check the skill percentage */
separate_obj (pobj);
separate_obj (wobj);
if (! can_use_skill (ch, percent, gsn_poison_weapon))
{
set_char_color (AT_RED, ch);
ch->SendText ("You failed and spill some on yourself. Ouch!\n\r");
set_char_color (AT_GREY, ch);
damage (ch, ch, ch->GetLevel (), gsn_poison_weapon);
act (AT_RED, "$n spills the poison all over!", ch, NULL, NULL, TO_ROOM);
extract_obj (pobj);
extract_obj (wobj);
learn_from_failure (ch, gsn_poison_weapon);
return;
}
separate_obj (obj);
/* Well, I'm tired of waiting. Are you? */
act (AT_RED, "You mix $p in $P, creating a deadly poison!", ch, pobj, wobj, TO_CHAR);
act (AT_RED, "$n mixes $p in $P, creating a deadly poison!",ch, pobj, wobj, TO_ROOM);
act (AT_GREEN, "You pour the poison over $p, which glistens wickedly!",ch, obj, NULL, TO_CHAR );
act (AT_GREEN, "$n pours the poison over $p, which glistens wickedly!",ch, obj, NULL, TO_ROOM );
obj->SetPoisoned ();
obj->cost *= ch->GetLevel ();
/* Set an object timer. Don't want proliferation of poisoned weapons */
obj->timer = 10 + ch->GetLevel ();
if (obj->IsBlessed ())
obj->timer *= 2;
if (obj->IsMagic ())
obj->timer *= 2;
/* WHAT? All of that, just for that one bit? How lame. ;) */
act (AT_BLUE, "The remainder of the poison eats through $p.", ch, wobj, NULL, TO_CHAR);
act (AT_BLUE, "The remainder of the poison eats through $p.", ch, wobj, NULL, TO_ROOM);
extract_obj (pobj);
extract_obj (wobj);
learn_from_success (ch, gsn_poison_weapon);
return;
}
void do_scribe (CCharacter *ch, char *argument)
{
CObjData *scroll;
int sn;
char buf1[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
char buf3[MAX_STRING_LENGTH];
int mana;
if (ch->IsNpc ())
return;
if (!ch->IsNpc ()
&& ch->GetLevel () < SkillTable.GetClassLevel (gsn_scribe, ch->GetClass ()))
{
ch->SendText ("A skill such as this requires more magical ability than that of your class.\n\r");
return;
}
if (argument[0] == '\0' || !str_cmp (argument, ""))
{
ch->SendText ("Scribe what?\n\r");
return;
}
if (ms_find_obj (ch))
return;
if ((sn = find_spell (ch, argument, TRUE)) < 0)
{
ch->SendText ("You have not learned that spell.\n\r");
return;
}
if (SkillTable.GetSpellFunction (sn) == spell_null)
{
ch->SendText ("That's not a spell!\n\r");
return;
}
if (SkillTable.GetSkill (sn)->IsNoScribe ()) {
ch->SendText ("You cannot scribe that spell.\n\r");
return;
}
mana = ch->IsNpc () ? 0 : UMAX (SkillTable.GetMinMana (sn),
100 / (2 + ch->GetLevel () - SkillTable.GetClassLevel (sn, ch->GetClass ())));
mana *=5;
if (!ch->IsNpc () && ch->GetMana () < mana)
{
ch->SendText ("You don't have enough mana.\n\r");
return;
}
if ((scroll = get_eq_char (ch, WEAR_HOLD)) == NULL)
{
ch->SendText ("You must be holding a blank scroll to scribe it.\n\r");
return;
}
if (scroll->pIndexData->vnum != OBJ_VNUM_SCROLL_SCRIBING)
{
ch->SendText ("You must be holding a blank scroll to scribe it.\n\r");
return;
}
if ((scroll->value[1] != -1)
&& (scroll->pIndexData->vnum == OBJ_VNUM_SCROLL_SCRIBING))
{
ch->SendText ("That scroll has already been inscribed.\n\r");
return;
}
if (!process_spell_components (ch, sn))
{
learn_from_failure (ch, gsn_scribe);
ch->AddMana (-mana / 2);
return;
}
if (! can_use_skill (ch, number_percent (), gsn_scribe))
{
set_char_color (AT_MAGIC, ch);
ch->SendText ("You failed.\n\r");
learn_from_failure (ch, gsn_scribe);
ch->AddMana (-mana / 2);
return;
}
scroll->value[1] = sn;
scroll->value[0] = ch->GetLevel ();
sprintf (buf1, "%s scroll", SkillTable.GetName (sn));
scroll->SetShortDescr (aoran (buf1));
sprintf (buf2, "A glowing scroll inscribed '%s' lies in the dust.",
SkillTable.GetName (sn));
scroll->SetDescription (buf2);
sprintf (buf3, "scroll scribing %s", SkillTable.GetName (sn));
scroll->SetName (buf3);
act (AT_MAGIC, "$n magically scribes $p.", ch,scroll, NULL, TO_ROOM);
act (AT_MAGIC, "You magically scribe $p.", ch,scroll, NULL, TO_CHAR);
learn_from_success (ch, gsn_scribe);
ch->AddMana (-mana);
}
void do_brew (CCharacter *ch, char *argument)
{
CObjData *potion;
CObjData *fire;
int sn;
char buf1[MAX_STRING_LENGTH];
char buf2[MAX_STRING_LENGTH];
char buf3[MAX_STRING_LENGTH];
int mana;
BOOL found;
if (ch->IsNpc ())
return;
if (!ch->IsNpc ()
&& ch->GetLevel () < SkillTable.GetClassLevel (gsn_brew, ch->GetClass ()))
{
ch->SendText ("A skill such as this requires more magical ability than that of your class.\n\r");
return;
}
if (argument[0] == '\0' || !str_cmp (argument, ""))
{
ch->SendText ("Brew what?\n\r");
return;
}
if (ms_find_obj (ch))
return;
if ((sn = find_spell (ch, argument, TRUE)) < 0)
{
ch->SendText ("You have not learned that spell.\n\r");
return;
}
if (SkillTable.GetSpellFunction (sn) == spell_null)
{
ch->SendText ("That's not a spell!\n\r");
return;
}
if (SkillTable.GetSkill (sn)->IsNoBrew ()) {
ch->SendText ("You cannot brew that spell.\n\r");
return;
}
mana = ch->IsNpc () ? 0 : UMAX (SkillTable.GetMinMana (sn),
100 / (2 + ch->GetLevel () - SkillTable.GetClassLevel (sn, ch->GetClass ())));
mana *=4;
if (!ch->IsNpc () && ch->GetMana () < mana)
{
ch->SendText ("You don't have enough mana.\n\r");
return;
}
found = FALSE;
POSITION pos = ch->GetInRoom ()->GetHeadContentPos ();
while (fire = ch->GetInRoom ()->GetNextContent (pos)) {
if (fire->item_type == ITEM_FIRE) {
found = TRUE;
break;
}
}
if (! found) {
ch->SendText (
"There must be a fire in the room to brew a potion.\n\r");
return;
}
if ((potion = get_eq_char (ch, WEAR_HOLD)) == NULL)
{
ch->SendText (
"You must be holding an empty flask to brew a potion.\n\r");
return;
}
if (potion->pIndexData->vnum != OBJ_VNUM_FLASK_BREWING)
{
ch->SendText ("You must be holding an empty flask to brew a potion.\n\r");
return;
}
if ((potion->value[1] != -1)
&& (potion->pIndexData->vnum == OBJ_VNUM_FLASK_BREWING))
{
ch->SendText ("That's not an empty flask.\n\r");
return;
}
if (!process_spell_components (ch, sn))
{
learn_from_failure (ch, gsn_brew);
ch->AddMana (-mana / 2);
return;
}
if (! can_use_skill (ch, number_percent (), gsn_brew))
{
set_char_color (AT_MAGIC, ch);
ch->SendText ("You failed.\n\r");
learn_from_failure (ch, gsn_brew);
ch->AddMana (-mana / 2);
return;
}
potion->value[1] = sn;
potion->value[0] = ch->GetLevel ();
sprintf (buf1, "%s potion", SkillTable.GetName (sn));
potion->SetShortDescr (aoran (buf1));
sprintf (buf2, "A strange potion labelled '%s' sizzles in a glass flask.",
SkillTable.GetName (sn));
potion->SetDescription (buf2);
sprintf (buf3, "flask potion %s", SkillTable.GetName (sn));
potion->SetName (buf3);
act (AT_MAGIC, "$n brews up $p.", ch,potion, NULL, TO_ROOM);
act (AT_MAGIC, "You brew up $p.", ch,potion, NULL, TO_CHAR);
learn_from_success (ch, gsn_brew);
ch->AddMana (-mana);
}
BOOL check_grip (CCharacter *ch, CCharacter *victim)
{
int chance;
if (! victim->IsAwake ())
return FALSE;
if (victim->IsNpc () && ! victim->CanGrip ())
return FALSE;
if (victim->IsNpc ())
chance = UMIN (60, 2 * victim->GetLevel ());
else
chance = victim->GetLearnedPercent (gsn_grip) / 2;
// Consider luck as a factor
chance += (2 * (get_curr_lck (victim) - 13));
if (number_percent () >=
chance + victim->GetLevel () - ch->GetLevel ()) {
learn_from_failure (victim, gsn_grip);
return FALSE;
}
act (AT_SKILL, "You evade $n's attempt to disarm you.",
ch, NULL, victim, TO_VICT );
act (AT_SKILL, "$N holds $S weapon strongly, and is not disarmed.",
ch, NULL, victim, TO_CHAR);
learn_from_success (victim, gsn_grip);
return TRUE;
}
void do_circle (CCharacter *ch, char *argument)
{
char arg [MAX_INPUT_LENGTH];
CCharacter *victim;
CObjData *obj;
int percent;
if (ch->IsNpc () && ch->IsCharmed ()) {
ch->SendText ("You can't concentrate enough for that.\n\r");
return;
}
one_argument (argument, arg);
if (ch->mount) {
ch->SendText ("You can't circle while mounted.\n\r");
return;
}
if (arg [0] == '\0') {
ch->SendText ("Circle around whom?\n\r");
return;
}
if ((victim = get_char_room (ch, arg)) == NULL) {
ch->SendText ("They aren't here.\n\r");
return;
}
if (victim == ch) {
ch->SendText ("How can you sneak up on yourself?\n\r");
return;
}
if (is_safe (ch, victim))
return;
if ((obj = get_eq_char (ch, WEAR_WIELD)) == NULL
|| (obj->value [3] != 11 && obj->value [3] != 2)) {
ch->SendText ("You need to wield a piercing or stabbing weapon.\n\r");
return;
}
if (! ch->GetFightData ()) {
ch->SendText ("You can't circle when you aren't fighting.\n\r");
return;
}
if (! victim->GetFightData ()) {
ch->SendText ("You can't circle around a person who is not fighting.\n\r");
return;
}
if (victim->num_fighting < 2) {
act (AT_PLAIN, "You can't circle around them without a distraction.",
ch, NULL, victim, TO_CHAR);
return;
}
percent = number_percent () - (get_curr_lck (ch) - 16)
+ (get_curr_lck (victim) - 13);
check_attacker (ch, victim);
WAIT_STATE (ch, SkillTable.GetBeats (gsn_circle));
if (can_use_skill (ch, percent, gsn_circle)) {
learn_from_success (ch, gShowing the first 100 KB of 194.4 KB. Download the archive for the full file.