sflag.c
pdirt/drv/src/sflag.c · 9.8 KB
From the archive pDirt-1_tar.gz
Download the archive « Back to the archive contents
#define SFLAG_C
#include "kernel.h"
#include <stdlib.h>
#include "sflag.h"
#include "sflags.h"
#include "lflags.h"
#include "sendsys.h"
#include "pflags.h"
#include "mobile.h"
#include "bprintf.h"
#include "log.h"
#include "parse.h"
#include "special.h"
#include "verbs.h"
int jail_check(int plx, int level)
{ return (ltstflg(ploc(plx),LFL_JAIL) && (plev(mynum) < level));
}
void sflagmessage(char *str,Boolean fal)
{ bprintf("&+w[&+w%s &+w= &+w%s&+w]&*\n",str,((fal) ? "On" : "Off"));
}
Boolean can_cast_sleep(int plr)
{ if (psitting(plr) == 2 && plev(plr) < LVL_ARCHWIZARD)
{ bprintf("You can't cast that spell while sleeping.\n");
return False;
}
else if (psitting(plr) == 3 && plev(plr) < LVL_ARCHWIZARD)
{ bprintf("You can't cast that spell while in trance.\n");
return False;
}
return True;
}
A_COMMAND(deafcom)
{
int a;
if (!can_cast_sleep(mynum))
return;
if (jail_check(mynum,LVL_ARCHWIZARD))
{ bprintf("You can't cast spells from here.\n");
return;
}
else if (pdrunk(mynum) > 7 && plev(mynum) < LVL_APPREN)
{ bprintf("In your drunken state you mix up the words of the spell and it reflects!\n");
ssetflg(mynum,SFL_DEAF);
return;
}
if ((a = vicf2 (SPELL_REFLECTS, 4)) != -1)
{
if (do_okay (mynum, a, PFL_NOMAGIC))
{
sendf (a, "&+wYou have been magically deafened!&+w\n");
ssetflg (a, SFL_DEAF);
mudlog("%s DEAFENed %s.", pname(mynum), pname(a));
}
else
{
bprintf("&+wYou can't just deafen %s at will, you know!&*\n", pname(a));
sendf (a, "&+w%s tried to deafen you!&*\n", see_name (a, mynum));
}
}
}
A_COMMAND(blindcom)
{
int a;
if (!can_cast_sleep(mynum))
return;
if (jail_check(mynum,LVL_ARCHWIZARD) )
{ bprintf("You can't cast spells from here.\n");
return;
}
else if (pdrunk(mynum) > 7 && plev(mynum) < LVL_APPREN)
{ bprintf("With your double vision you cast the spell on yourself!\n");
ssetflg(mynum,SFL_BLIND);
return;
}
if ((a = vicf2 (SPELL_REFLECTS, 4)) != -1)
{
if (do_okay (mynum, a, PFL_NOMAGIC))
{
sendf (a, "&+wYou have been struck magically blind!&*\n");
ssetflg (a, SFL_BLIND);
mudlog("%s BLINDed %s.", pname(mynum), pname(a));
}
else
{
bprintf("&+wYou can't just blind %s at will, you know!&*\n", pname(a));
sendf (a, "&+w%s tried to blind you!&*\n", see_name (a, mynum));
}
}
}
A_COMMAND(curecom)
{
int a;
if (!can_cast_sleep(mynum))
return;
if (jail_check(mynum,LVL_ARCHWIZARD) )
{ bprintf("You can't cast spells from here.\n");
return;
}
if (EMPTY (item1))
{
bprintf ("Cure who?\n");
return;
}
if ((a = vicf2 (SPELL_PEACEFUL, 8)) >= 0)
{
if (a >= 0 && a <= numchars)
{ sclrflg (a, SFL_DUMB);
sclrflg (a, SFL_CRIPPLED);
sclrflg (a, SFL_BLIND);
sclrflg (a, SFL_DEAF);
sclrflg (a, SFL_DRUNK);
if (a < max_players)
pdrunk(a) = 0;
if (a != mynum)
sendf (a, "&+wAll of your ailments have been cured by %s.&*\n", pname(mynum));
if (mob_fun(a) != NULL)
{ param_s.plx = mynum;
param_s.pl = a;
param_s.ret = 1;
param_s.loc = ploc(mynum);
param_s.misc = VERB_CURE;
mob_fun(a)(E_ONMISC);
if (param_s.ret != 1)
return;
}
if (a < max_players)
mudlog("%s CUREd %s.", pname(mynum), pname(a));
}
}
}
A_COMMAND(dumbcom)
{
int a;
if (!can_cast_sleep(mynum))
return;
if (jail_check(mynum,LVL_ARCHWIZARD) )
{ bprintf("You can't cast spells from here.\n");
return;
}
if ((a = vicf2 (SPELL_REFLECTS, 4)) >= 0)
{
if (do_okay (mynum, a, PFL_NOMAGIC))
{
sendf (a, "&+wYou have been struck magically dumb!&*\n");
ssetflg (a, SFL_DUMB);
mudlog("%s has MUTEd %s.", pname(mynum), pname(a));
}
else
{
sendf (a, "&+w%s tried to mute you!&*\n", see_name (a, mynum));
bprintf("&+wYou can't just mute %s at will, you know!&*\n", pname(a));
}
}
}
A_COMMAND(cripplecom)
{
int a;
if (!can_cast_sleep(mynum))
return;
if (jail_check(mynum,LVL_ARCHWIZARD) )
{ bprintf("You can't cast spells from here.\n");
return;
}
if ((a = vicf2 (SPELL_REFLECTS, 4)) >= 0)
{
if (do_okay (mynum, a, PFL_NOMAGIC))
{
sendf (a, "&+wYou have been magically crippled!&*\n");
ssetflg (a, SFL_CRIPPLED);
mudlog("%s has CRIPPLEd %s.", pname(mynum), pname(a));
}
else
{
sendf (a, "&+w%s tried to cripple you!&*\n", see_name (a, mynum));
bprintf("&+wYou can't just cripple %s at will, you know!&*\n", pname(a));
}
}
}
void setsflag(int flag,char *str)
{ int r;
if ((r=ststflg(mynum, flag)))
sclrflg(mynum,flag);
else
ssetflg(mynum, flag);
sflagmessage(str,!r);
}
A_COMMAND(aloofcom)
{ setsflag(SFL_ALOOF,"Ignore Mortal actions");
}
A_COMMAND(noslaincom)
{ setsflag(SFL_NOSLAIN,"Ignore Slain messages");
}
A_COMMAND(quietcom)
{ setsflag(SFL_QUIET,"Quiet mode");
}
A_COMMAND(oldlogincom)
{ setsflag(SFL_OLDLOGIN,"Old Style Login");
}
A_COMMAND(nobeepcom)
{ setsflag(SFL_NOBEEP,"No Beeps");
}
A_COMMAND(nobattlecom)
{ setsflag(SFL_NOBATTLE,"No Battles");
}
A_COMMAND(nopuffcom)
{ setsflag(SFL_NOPUFF,"No Puff messages");
}
A_COMMAND(autoeatcom)
{ setsflag(SFL_AUTOEAT,"Auto eat before flee");
}
A_COMMAND(colorcom)
{ setsflag(SFL_COLOR,"Color Mode");
}
A_COMMAND(noblinkcom)
{ setsflag(SFL_NOBLINK,"No Blinking Text");
}
A_COMMAND(busycom)
{ setsflag(SFL_BUSY,"Busy");
}
A_COMMAND(compactcom)
{ setsflag(SFL_COMPACT,"Compact Mode");
}
A_COMMAND(noinvencom)
{ setsflag(SFL_NOINVEN,"No Inventories");
}
A_COMMAND(autoexitcom)
{ setsflag(SFL_AUTOEXIT,"Auto exits");
}
A_COMMAND(saybackcom)
{ setsflag(SFL_SAYBACK,"Say back messages");
}
A_COMMAND(briefcom)
{ setsflag(SFL_BRIEF,"Brief Mode");
}
A_COMMAND(shortexitcom)
{ setsflag(SFL_SHORTEXIT,"Short Exits");
}
A_COMMAND(noweathercom)
{ setsflag(SFL_NOWEATHER,"No Weather Messages");
}
A_COMMAND(nofingercom)
{ setsflag(SFL_NOFINGER,"Private Email");
}
A_COMMAND(awaycom)
{
if (ststflg(mynum, SFL_AWAY))
{
send_msg(DEST_ALL,MODE_BRACKET|MODE_QUIET,Max(LVL_APPREN,pvis(mynum)),LVL_MAX,mynum,
NOBODY, "\001p%s\003 has returned to the keyboard",pname(mynum));
sclrflg(mynum, SFL_AWAY);
bprintf("&+w[&+wAway &+w= &+wOff&+w]&*\n");
}
else
{
getreinput(globalbuf);
if (EMPTY(globalbuf))
strncpy(cur_player->awaymsg,"no particular reason.",SETIN_MAX);
else
strncpy(cur_player->awaymsg,globalbuf,SETIN_MAX);
ssetflg(mynum, SFL_AWAY);
bprintf("&+w[&+wAway &+w= &+wOn &+w: &+w%s&+w]&*\n",cur_player->awaymsg);
send_msg(DEST_ALL, MODE_BRACKET|MODE_QUIET, Max(LVL_APPREN,pvis(mynum)), LVL_MAX,
mynum, NOBODY, "\001p%s\003 has left the keyboard. Reason: %s",pname(mynum),cur_player->awaymsg);
}
}
A_COMMAND(codecom)
{
if (!ptstflg(mynum, PFL_MAYCODE))
{
bprintf ("&+wSorry&*, but you are not allowed to code.\n");
return;
}
if (!ststflg (mynum, SFL_CODING))
ssetflg (mynum, SFL_CODING);
else
sclrflg (mynum, SFL_CODING);
sflagmessage("Coding",ststflg(mynum,SFL_CODING));
}
PUBLIC A_COMMAND(nocommcom)
{ int x;
if (pl1 == -1 || pl1 == mynum)
{ setsflag(SFL_NOCOMM,"NoComm");
x = mynum;
}
else if (pl1 < 0 || pl1 > max_players)
{ bprintf("Invalid player or player not found.\n");
return;
}
else if (ststflg(pl1,SFL_NOCOMM))
{ bprintf("%s can now use the channels again.\n",pname(pl1));
sendf(pl1,"You may now use the public channels again.\n");
sclrflg(pl1,SFL_NOCOMM);
x= pl1;
}
else
{ bprintf("%s can't use the public channels from now on.\n",pname(pl1));
sendf(pl1,"You have been banned from all public channels.\n");
ssetflg(pl1,SFL_NOCOMM);
x = pl1;
}
if (ststflg(x,SFL_NOCOMM))
{ ssetflg(x,SFL_NO_GOD);
ssetflg(x,SFL_NO_DGOD);
ssetflg(x,SFL_NO_AWIZ);
ssetflg(x,SFL_NO_WIZ);
ssetflg(x,SFL_NO_GOSSIP);
ssetflg(x,SFL_NO_CHAT);
ssetflg(x,SFL_NOSHOUT);
ssetflg(x,SFL_I_NOGOSSIP);
}
else
{ sclrflg(x,SFL_NO_GOD);
sclrflg(x,SFL_NO_DGOD);
sclrflg(x,SFL_NO_AWIZ);
sclrflg(x,SFL_NO_WIZ);
sclrflg(x,SFL_NO_GOSSIP);
sclrflg(x,SFL_NO_CHAT);
sclrflg(x,SFL_NOSHOUT);
sclrflg(x,SFL_I_NOGOSSIP);
}
}
/****************************************************************************
** NOSHOUT
** parameter:
** none : stops player from hearing shouts
** player name: If wiz, sets/unsets wiz priviledge from someone
****************************************************************************/
PUBLIC A_COMMAND(noshoutcom)
{ int x;
if (plev (mynum) < LVL_APPREN)
{
erreval ();
return;
}
if ((x = pl1) == -1 || x == mynum)
{
if (ststflg (mynum, SFL_NOSHOUT))
{
bprintf ("You can hear &+wshouts&* again.\n");
sclrflg (mynum, SFL_NOSHOUT);
}
else
{
bprintf ("From now on you won't hear &+wshouts.&*\n");
ssetflg (mynum, SFL_NOSHOUT);
}
}
else if (plev (x) >= LVL_APPREN)
{
if (ststflg (x, SFL_NOSHOUT))
{
bprintf ("%s can hear &+wshouts&* again.\n", pname (x));
sclrflg (x, SFL_NOSHOUT);
}
else
{
bprintf ("From now on %s won't hear &+wshouts.&*\n", pname (x));
ssetflg (x, SFL_NOSHOUT);
}
}
else if (ststflg (x, SFL_NOSHOUT))
{
bprintf ("%s is allowed to &+wshout&* again.\n", pname (x));
sclrflg (x, SFL_NOSHOUT);
}
else
{
bprintf ("From now on %s cannot &+wshout.&*\n", pname (x));
ssetflg (x, SFL_NOSHOUT);
}
}