/*

filename    commands
password    release
changedby   Whistler
EmailAdd     whistler@valhalla.com
request     compile
version     5
END HEADER*/

#include

%zone                                  commands
reset RESET_NOT

weather 1040

creators {"Whistler"}

notes
"This is the commands zone. Dont let any rooms point to this zone, or use
any objects from this zone without special permission. Do not slime objects from
this zone."

help
"This zone is not intended for players."
#define  CLAN_NAME   "$clan_name"
%dil

dilbegin do_purse(arg : string);
var
u : unitptr;
s : string;
code
{
sendtext("Your purse contains:&n", self);
s := "   ";

u := findsymbolic(self,"platinum_piece@basis",FIND_UNIT_INVEN);
if(u) s := s+u.title+"&n&s3";

u := findsymbolic(self,"gold_piece@basis",FIND_UNIT_INVEN);
if(u) s := s+u.title+"&n&s3";

u := findsymbolic(self,"silver_piece@basis",FIND_UNIT_INVEN);
if(u) s := s+u.title+"&n&s3";

u := findsymbolic(self,"copper_piece@basis",FIND_UNIT_INVEN);
if(u) s := s+u.title+"&n&s3";

u := findsymbolic(self,"iron_piece@basis",FIND_UNIT_INVEN);
if(u) s := s+u.title+"&n";

if(s == "   ") sendtext("Nothing!&n", self);
else sendtext(s, self);

send_done("purse",self,null,null,0,arg,null);

quit;
}
dilend

dilbegin zoneptr get_zone(s : string);
var
zn : zoneptr;
code
{

zn := zhead();

while(zn)
{

if(zn.name == s)
 break;

zn := zn.next;
}


return(zn); /* will return null if no zone found */
}
dilend

dilbegin do_goto(arg : string);
external
integer may_tele_away@function(u : unitptr);
unitptr unit_char@function(u : unitptr);
zoneptr get_zone(s : string);
var
zonestr : string;
tgt : unitptr;
i : integer;
z : zoneptr;
ins : unitptr;
code
{

if(self.type != UNIT_ST_PC)
 quit;

if(arg == "")
{
 sendtext("You must supply a unit name or zone reference.&n", self);
 quit;
}

if("@" in arg)
{
 tgt := findsymbolic(arg);
 while((tgt.type != UNIT_ST_ROOM) and
      (not isset(tgt.manipulate,MANIPULATE_ENTER)))
      tgt := tgt.outside;

 goto got_one;
}

tgt := findunit(self,arg,FIND_UNIT_GLOBAL,null);

if(tgt != null)
{
 while((tgt.type != UNIT_ST_ROOM) and
      (not isset(tgt.manipulate,MANIPULATE_ENTER)))
      tgt := tgt.outside;

}
else
{

 z := get_zone(arg);
 
 if(not z) /* Lets search for a room in the cur. zone */
 {
  arg := arg+"@"+self.zone;
  tgt := findsymbolic(arg);
 }
 else tgt := z.rooms;
 
 }
 
:got_one:

if(not tgt)
{
 sendtext("No such place around.&n", self);
 quit;
}

if(isset(tgt.flags,UNIT_FL_PRIVATE))
{
 ins := tgt.inside;
 i := 0;
 
 while(ins)
 {
  if(ins.type == UNIT_ST_PC)
   i := i + 1;
   
  ins := ins.next;
 }
 
 if(i > 1)
 {
  sendtext("There's a private conversation going on in that room.&n",self);
  quit;
 }
}

ins := unit_char@function(tgt);

if(ins == self)
{
 sendtext("Recursive goto. Would destroy the universe.&n",self);
 quit;
}

i := may_tele_away@function(tgt);

if(i == FALSE)
 sendtext("WARNING - this is a no teleport environment.&n", self);

if(self.extra.["$bamfout"].descr != "")
 act(self.extra.["$bamfout"].descr,A_HIDEINV, self, null, null, TO_ROOM);
else
 act("$1n disappears into thin air.",
  A_HIDEINV, self, null, null, TO_ROOM);
 
 link(self,tgt);
 
if(self.extra.["$bamfin"].descr != "")
 act(self.extra.["$bamfin"].descr,A_HIDEINV, self, null, null, TO_ROOM);
else
 act("$1n appears from thin air.",
  A_HIDEINV, self, null, null, TO_ROOM);

exec("look", self);

send_done("goto",self,null,tgt,0,arg,null);
quit;
}
dilend

dilbegin do_quests(arg : string);
var
ex : extraptr;
str : string;
code
{

ex := self.quests;
str := "";

if(arg != "")
{

sendtext("Quests containing '"+arg+"'.&n", self);

while(ex != null)
{
 if((left(ex.names.[0],1) != "$") and
    (arg in ex.names.[0]))
 {
 
  str := str+ex.names.[0]+"&n";
 }
 
 ex := ex.next;
}

if(str == "") str := "None.&n";

str := textformat(str);
pagestring(str,self);
}
else
{

while(ex != null)
{

if(left(ex.names.[0],1) != "$")
{
 str := str+ex.names.[0]+"&n";
}
ex := ex.next;
}

if(str == "") str := "You have not completed any quests.&n";

str := textformat(str);
pagestring(str,self);

}
send_done("quests",self,null,null,0,arg,null);
quit;
}
dilend


dilbegin do_news(arg : string);
var
err : integer;
news : string;
code
{

err := loadstr("news",news);

if(err > 0)
{
       sendtext("&n", self); /* start on a new line */
       news := textformat(news);
       pagestring(news,self);
}

send_done("news",self,null,null,0,arg,null);

quit;
}
dilend

dilbegin do_contrib(arg : string);
var
err : integer;
contrib : string;
code
{

err := loadstr("contrib",contrib);

if(err > 0)
{
       sendtext("&n", self); /* start on a new line */
       contrib := textformat(contrib);
       pagestring(contrib,self);
}

send_done("contrib",self,null,null,0,arg,null);

quit;
}
dilend

dilbegin do_credits(arg : string);
var
err : integer;
credits : string;
code
{

err := loadstr("credits",credits);

if(err > 0)
{
       sendtext("&n", self); /* start on a new line */
       credits := textformat(credits);
       pagestring(credits,self);
}

send_done("credits",self,null,null,0,arg,null);

quit;
}
dilend

dilbegin do_wizlist(arg : string);
var
err : integer;
wizlist : string;
code
{

err := loadstr("wizlist",wizlist);

if(err > 0)
{
       sendtext("&n", self); /* start on a new line */
       wizlist := textformat(wizlist);
       pagestring(wizlist,self);
}

send_done("wizlist",self,null,null,0,arg,null);

quit;
}
dilend

dilbegin do_not_here(arg : string);
code
{

sendtext("Sorry, but you cannot do that here!&n", self);

quit;
}
dilend

dilbegin send_to_world(s : string);
var
u : unitptr;
code
{

u := ghead();

while(u.type == UNIT_ST_PC)
{
sendtext(s,u);
u := u.gnext;
}

return;
}
dilend

dilbegin rebooting(s : string);
external
send_to_world(s : string);
var
j : integer;
u : unitptr;
str : string;
i : integer;
code
{
i := atoi(s);
if(i == 0) goto go_now;

if(i > 1) str := "minutes";
else str := "minute";


/* Only tell the players it will reboot if it's under 20 */
if(i < 20)
send_to_world("&c+rThe mud will reboot in "+itoa(i)+
              " "+str+".&[default]&n");

heartbeat := PULSE_SEC * SECS_PER_REAL_MIN;

while(i > 1)
{
wait(SFB_TICK, TRUE);

if((i == 10) or (i == 5))
send_to_world("&c+rThe mud will reboot in "+itoa(i)+
" minutes.&[default]&n");

i := i - 1;
}


j := SECS_PER_REAL_MIN;

heartbeat := PULSE_SEC;

while(j > 0)
{

wait(SFB_TICK, TRUE);

if(j == 30)
send_to_world("&c+rThe mud will reboot in 30 seconds.&[default]&n");

if(j == 10)
send_to_world("&c+rThe mud will reboot in 10 seconds.&[default]&n");

j := j - 1;
}

:go_now:
send_to_world("Rebooting...&n");
reboot;
quit;
}
dilend

dilbegin cmd_reboot(arg : string);
external
send_to_world(s : string);
var
void : unitptr;
i : integer;
str : string;
code
{


/* No need to double check for the void, if basis isn't in the
  game, the game is not running :P */
void := findroom("void@basis");


if(arg == "")
{
if(dilfind("rebooting@commands",void))
{
sendtext("There is a reboot in progress, use the cancel option.&n",self);
quit;
}
dilcopy("rebooting@commands("+itoa(1)+")", void);
sendtext("Reboot set for 1 minute.&n", self);
quit;
}
else if("now" in arg)
{
dilcopy("rebooting@commands("+itoa(0)+")", void);
quit;
}
else if("cancel" in arg)
{
if(dilfind("rebooting@commands",void))
{
i := dildestroy("rebooting@commands",void);
sendtext("Reboot cancelled.&n", self);
send_to_world("The reboot has been halted..&n");
}
else
{
sendtext("There is no reboot scheduled.&n", self);
}
quit;
}
else
{
str := getword(arg);
if(atoi(str) > 0)
{
if(dilfind("rebooting@commands",void))
{
sendtext("There is a reboot in progress, use the cancel option.&n",self);
quit;
}
sendtext("Reboot set for "+str+" minutes.&n", self);
dilcopy("rebooting@commands("+str+")",void);
quit;
}

sendtext("Usage: &n&c+rReboot&n&c+yReboot now&n"+
"&c+mReboot cancel&n&c+gReboot #&cw(in minutes)&[default]&n", self);
quit;
}

quit;
}
dilend


dilbegin integer two_handed(i : integer);
var
wpns : intlist;
tmp : integer;
code
{

/* all the two handed weapons */
wpns := {WPN_BATTLE_AXE,WPN_WAR_MATTOCK,WPN_GREAT_SWORD,WPN_BATTLE_MACE,
WPN_BATTLE_CLUB,WPN_FLAIL,WPN_HALBERD,WPN_BARDICHE,WPN_SCYTHE,WPN_TRIDENT,
WPN_FIGHTING_STAFF,WPN_LANCE,WPN_GREAT_AXE,WPN_BATTLE_SWORD,WPN_WAR_MAUL};

/* well this is not supported right now, so lets go the long route
if(i in wpns) return(TRUE);
else return(FALSE);
*/

tmp := 0;

while(tmp <= length(wpns))
{
if(i == wpns.[tmp]) return(TRUE);

tmp := tmp + 1;
}

return(FALSE);

}
dilend


dilbegin string eq_string(i : integer,ting : unitptr);
external
       integer two_handed(i : integer);
var
two : integer;
code
{

if(i == WEAR_FINGER_R)
       return("worn on right finger");
else if(i == WEAR_FINGER_L)
       return("worn on left finger");
else if((i == WEAR_NECK_1) or (i == WEAR_NECK_2))
       return("worn around neck");
else if(i == WEAR_BODY)
       return("worn on body");
else if(i == WEAR_HEAD)
       return("worn on head");
else if(i == WEAR_LEGS)
       return("worn on legs");
else if(i == WEAR_FEET)
       return("worn on feet");
else if(i == WEAR_HANDS)
       return("worn on hands");
else if(i == WEAR_ARMS)
       return("worn on arms");
else if(i == WEAR_SHIELD)
       return("worn as shield");
else if(i == WEAR_ABOUT)
       return("worn about body");
else if(i == WEAR_WAIST)
       return("worn about waist");
else if((i == WEAR_WRIST_R) or (i == WEAR_WRIST_L))
       return("worn around wrist");
else if(i == WEAR_WIELD)
{
       two := two_handed(ting.value[0]);
       if(two == TRUE)
       return("two hand wielded");
       else
       return("wielded");
}
else if(i == WEAR_HOLD)
       return("held");
else if(i == WEAR_CHEST)
       return("worn across chest");
else if(i == WEAR_BACK)
       return("worn on back");
else if(i == WEAR_EAR_L)
       return("worn on left ear");
else if(i == WEAR_EAR_R)
       return("worn on right ear");
else if((i == WEAR_ANKLE_L) or (i == WEAR_ANKLE_R))
       return("worn on ankle");
else
       return("report to an admin");
}
dilend

dilbegin do_equipment(arg : string);
external
       string eq_string(i : integer,ting : unitptr);
       string get_eq_in_order();
var
obj : unitptr;
str : string;
cnt : integer;
len : integer;
pge : string;
code
{

if(arg == "")
{
pge := "You are using:&n";

obj := self.inside;

while(obj != null)
{
if(obj.equip)
{
 str := eq_string(obj.equip,obj);
 len := 22 - length(str);
 pge := pge+"&c+w<&[default]"+str+"&c+w>&[obj_title]"+
        "&&s"+itoa(len)+obj.title+"&n&[default]";


 cnt := cnt + 1;
}

obj := obj.next;
}

if(cnt < 1)
       pge := pge+"Nothing!&n";

pge := textformat(pge);

sendtext(pge, self);
}
else if(arg == "all")
{

str := get_eq_in_order();

str := textformat(str);

sendtext(str,self);
}

send_done("equipment",self,null,null,0,arg,null);
quit;
}
dilend


dilbegin string get_eq_in_order();
external
       string eq_string(i : integer,ting : unitptr);
       integer two_handed(i : integer);
var
ret : string;
il  : intlist;
i   : integer;
str : string;
obj : unitptr;
len : integer;
two : integer;
code
{

/* Equipment in order from head to toe */
il := {WEAR_HEAD,WEAR_EAR_R,WEAR_EAR_L,WEAR_NECK_1,WEAR_NECK_2,WEAR_BACK,
WEAR_ABOUT,WEAR_ARMS,WEAR_WRIST_R,WEAR_WRIST_L,WEAR_HANDS,WEAR_FINGER_R,
WEAR_FINGER_L,WEAR_WIELD,WEAR_HOLD,WEAR_SHIELD,WEAR_BODY,WEAR_CHEST,WEAR_WAIST,
WEAR_LEGS,WEAR_ANKLE_R,WEAR_ANKLE_L,WEAR_FEET};

i := 0;
ret := "You are using:&n";

while(i < length(il))
{

if(il.[i] == WEAR_HOLD)
{
if(equipment(self,WEAR_SHIELD))
{
i := i + 1;
continue;
}

obj := equipment(self,WEAR_WIELD);
if(obj)
{
two := two_handed(obj.value[0]);
if(two == TRUE)
{
       i := i + 1;        
       continue;
       }
      }
}
else if((il.[i] == WEAR_SHIELD) and (equipment(self,WEAR_SHIELD) == null))
{
       i := i + 1;
       continue;
}

obj := equipment(self,il.[i]);
str := eq_string(il.[i],obj);
len := 22 - length(str);

if(obj != null)
ret := ret+"&c+w<&[default]"+str+
"&c+w>&[obj_title]&&s"+itoa(len)+obj.title+"&[default]&n";
else
ret := ret+"&c+w<&[default]"+str+
"&c+w>&[obj_title]&&s"+itoa(len)+"-Nothing-&[default]&n";

i := i + 1;
}

return(ret);

}
dilend




dilbegin do_quit(arg : string);
var
err : integer;

goodbye : string;
exq : extraptr;
u : unitptr;
code
{

heartbeat := PULSE_SEC;
/*
if (excmdstr!="quit"){
sendtext ("You must type 'quit' no less to quit!&n",self);
quit;
}
*/

if(self.type != UNIT_ST_PC) quit;

if(self.position == POSITION_FIGHTING)
{
sendtext("Not while fighting!&n", self);
quit;
}

exq := "$PK_TIMER" in self.extra;

if((realtime-atoi(exq.descr)) <= 300)
{
sendtext("You are not permitted to log off so soon "+
         "after a pk fight.&n",self);
quit;
}

foreach(UNIT_ST_PC,u)
{

if(u != self)
{
 if(visible(u,self))
  sendtext(self.name+" has left the game.&n",u);
}
}


err := loadstr("goodbye",goodbye);

if(err > 0)
{
       goodbye := textformat(goodbye);
       sendtext("&n&n"+goodbye, self);
}

sendtext("Goodbye, friend.. Come back soon!&n", self);

gamestate(self, GS_QUIT);
quit;
}
dilend

dilbegin aware do_password (arg:string);
var
prmt:string;
firstpwd:string;

i:integer;
tlist:stringlist;

code
{
/*
if (excmdstr!="password"){
sendtext ("You must type 'password', no less to be able to set your password!&n",self);
quit;
}
 */

if(self.type != UNIT_ST_PC) quit;
arg:="";
prmt:=self.prompt;
self.prompt:="Enter new password:  ";
wait (SFB_CMD,self==activator);
block;
tlist:=getwords (excmdstr);
if (length(tlist)>1){
sendtext ("Password must be only one word.  Try again.&n",self);
self.prompt:=prmt;
quit;
}
if (length(excmdstr)<5){
sendtext ("Password to short. Password must be 5 characters or longer.  Try again.&n",self);
self.prompt:=prmt;
quit;
}

if (length(excmdstr)>16){
sendtext ("Password to long. Try again.&n",self);
self.prompt:=prmt;
quit;
}

firstpwd:=excmdstr;
self.prompt:="Enter password again:  ";
wait (SFB_CMD,self==activator);
block;
if (excmdstr!=firstpwd){
sendtext ("Passwords do not match try again.&n",self);
self.prompt:=prmt;
quit;
}
set_password(self,excmdstr);
sendtext("Changed your Password to '"+excmdstr+"' Please write it down!&n",self);
self.prompt:=prmt;

quit;
}
dilend

dilbegin aware do_delete (arg:string);
var
temp:string;
err:integer;
code
{

/*
if (excmdstr!="delete"){
sendtext("You must type the full command 'delete' for this to work!&n",self);
quit;
}
*/

if(self.type != UNIT_ST_PC) quit;

if (self.level>200)
goto admin_delete;

:char_delete:
if (arg!="self forever")
 {
 sendtext ("To delete your char type:  'delete self forever'&n",self);
 quit;
 }

err:=loadstr("delete.txt",temp);

if (err<1)
goto no_insure;

sendtext (temp,self);

sendtext ("If your sure you still want to delete your character, 'say delete me'&n",self);
sendtext ("Doing anything else will abort the deletion.&n",self);

wait (SFB_CMD, self==activator);
if (command ("say"))

if (argument=="delete me")
if (self.extra.[CLAN_RANK]!=null)
 exec ("cdefect",self);
 delete_player(self.name);

sendtext("Deletion aborted&n",self);

quit;

:no_insure:
 if (self.extra.[CLAN_RANK]!=null)
 exec ("cdefect",self);
  delete_player(self.name);

quit;
:admin_delete:
if (arg=="self forever")
 goto char_delete;
if (arg==""){
sendtext("You must supply a characters name to delete one.&n",self);
quit;
}

if (arg==self.name){
sendtext ("To delete self you need to type 'delete self forever'&n",self);
quit;
}

if (not isplayer(arg))
{
sendtext (arg+" is not a character.&n",self);
quit;
}
dilcopy ("god_delete@clans("+arg+")",self);

sendtext (arg+" has been deleted.&n",self);
quit;
}
dilend


dilbegin do_motd(arg : string);
var
err : integer;
motd : string;
code
{

err := loadstr("motd",motd);

if(err > 0)
{
       sendtext("&n", self); /* start on a new line */
       motd := textformat(motd);
       pagestring(motd,self);
}

send_done("motd",self,null,null,0,arg,null);

quit;
}
dilend


dilbegin dig(arg : string);
var
u : unitptr;
i : integer;
f : integer;
code
{

sendtext("Ok.&n", self);

foreach(UNIT_ST_OBJ | UNIT_ST_NPC | UNIT_ST_PC,u)
{
if(isset(u.flags,UNIT_FL_BURIED))
{
sendtext("Bingo! You discover something.&n", self);
unset(u.flags, UNIT_FL_BURIED);
i := dildestroy("buried_timer@commands",u);
f := TRUE;
break;
}

}

send_done("dig",self,u,null,0,arg,null);

quit;
}
dilend

/* Timer for buried objects */
dilbegin buried_timer(amount : integer); /*Amount in real time minutes */
var
time : integer;
code
{

if(self.type != UNIT_ST_OBJ) quit; /* shrug..I don't know */
if(not (isset(self.flags, UNIT_FL_BURIED))) quit;
if((self.nameidx+"@"+self.zoneidx) == "corpse@basis") quit;


heartbeat := PULSE_SEC * SECS_PER_REAL_MIN;
time := amount;

while(time > 0)
{
wait(SFB_TICK, TRUE);

time := time - 1;
}

if(isset(self.flags, UNIT_FL_BURIED)) destroy(self);
quit;
}
dilend


/* Made by whistler, modified/tested by Mesmer */
dilbegin bury (arg:string);
var
count:integer;
 item:unitptr;
 str : string;
 code
 {
 count:=0;
 if (arg=="") {
 act ("Bury what?", A_ALWAYS,self,null,null,TO_CHAR);
 quit;
 }

if (self.fighting!=null) {
 act ("No Way! Your fighting for your
life!",A_ALWAYS,self,null,null,TO_CHAR);
 quit;
 }

if (self.outside.type!=UNIT_ST_ROOM) {
 act ("You can't bury stuff here.",A_ALWAYS,self,null,null,TO_CHAR);
 quit;
 }
if (arg!="all") {
/* Now the pain, find the item */
str := arg; /*findunit likes to eat it*/
if("." in arg)
item := findunit(self,arg,FIND_UNIT_INVEN | FIND_UNIT_SURRO,null);
if((item != null) and (visible(self,item)) and
  (not isset(item.flags,UNIT_FL_BURIED))) goto item_found;

item := findunit(self,arg,FIND_UNIT_INVEN | FIND_UNIT_SURRO,null);
if((item != null) and (visible(self,item)) and
  (not isset(item.flags,UNIT_FL_BURIED))) goto item_found;

foreach(UNIT_ST_OBJ,item)
{
if(str in item.names)
{
 if((isset(item.flags,UNIT_FL_BURIED)) or
    (not (visible(self,item))))
continue;
 else
 {
 count := 1;
 break;
 }
}
}

if(count != 1)
{
act("Nothing like that here to bury.",
A_ALWAYS, self, null, null, TO_CHAR);
quit;
}

:item_found:
 if ( (not(isset (item.manipulate,MANIPULATE_TAKE))) or
      (item.type != UNIT_ST_OBJ)) {
   act ("You can't bury that.",A_ALWAYS,self,null,null,TO_CHAR);
   quit;
   }
 act ("$1n buries $3n.",A_SOMEONE,self,null,item,TO_REST);
 act ("You bury $3n.",A_SOMEONE,self,null,item,TO_CHAR);
 set (item.flags,UNIT_FL_BURIED);
 dilcopy("buried_timer@commands(60)", item);
 link (item,self.outside);
 send_done("bury",self,item,null,0,arg,null);
 quit;
 }
else
 {
 foreach (UNIT_ST_OBJ,item){
   if (((item.outside!=self.outside) or
     (item.outside==self)) or
     (not (visible (self,item))))continue;
 if (not(isset (item.manipulate,MANIPULATE_TAKE))) continue;
 act ("$1n buries $3n.",A_SOMEONE,self,null,item,TO_REST);
 act ("You bury $3n.",A_SOMEONE,self,null,item,TO_CHAR);
 set (item.flags,UNIT_FL_BURIED);
 dilcopy("buried_timer@commands(60)", item);
 link (item,self.outside);
 send_done("bury",self,item,null,0,arg,null);
 count:=count+1;
 }

if (count==0) {
   act ("Nothing here to bury.", A_ALWAYS,self,null,null,TO_CHAR);}
 quit;
 }

quit;
}
dilend

dilbegin cmd_copy(arg : string);
var
u: unitptr;
s: string;

code
{

     s := getword(arg);

     if (s == "room")
     u := self.outside;

  else if (s == "self")
     u := self;

  else if ("@" in s)
     {
     u := findsymbolic(s);

     if (u.type != UNIT_ST_ROOM)
        {
        sendtext("Copying on symbolic units other than rooms "+
           "is denied.&n", self);
        quit;
        }
     }

  else
     {
     arg := s + " " + arg;
     u := findunit(self, arg, FIND_UNIT_HERE, null);
     }

  if (u)
  {
 if (u.zoneidx=="treasure")
 {
  act ("You can not copy to that.",A_ALWAYS, self,null,null,TO_CHAR);
 quit;
    }
     dilcopy(arg, u);
     act("Attempted to copy "+arg+" to unit "+u.name, A_ALWAYS, self, null,
null, TO_CHAR);
  }
  else
    act("No such unit found to copy a dil upon.", A_ALWAYS, self, null,
null, TO_CHAR);

quit;
}
dilend

dilbegin cmd_zap(arg : string);
var
u: unitptr;
s: string;
i: integer;

code
{

  s := getword(arg);

  if (s == "room")
     {
     u := self.outside;
     }

  else if (s == "self")
     {
     u := self;
     }

  else if ("@" in s)
     {
     u := findsymbolic(s);

     if (u.type != UNIT_ST_ROOM)
        {
        sendtext("Copying on symbolic units other than rooms "+
           "is denied.&n", self);
        quit;
        }
     }

  else
     {
     arg := s + " " + arg;
     u := findunit(self, arg, FIND_UNIT_HERE, null);
     }

  if (u)
  {
 if (u.zoneidx=="treasure")
 {
  act ("You can not zap from that.", A_ALWAYS, self,null,null,TO_CHAR);
 quit;
 }

     s := getword(arg);
     i := dildestroy(s, u);

     if (i)
        act("DIL successfully removed.", A_ALWAYS, self, null, null,
TO_CHAR);
     else
        act("Unable to remove the DIL in question.",A_ALWAYS, self, null,
null, TO_CHAR);
  }
  else
    act("No such unit found to zap.", A_ALWAYS, self, null, null, TO_CHAR);

quit;
}
dilend


/* Mesmer = Lazy */
#define DO_ACT(ACT) act(ACT, A_SOMEONE, self, null, null, TO_CHAR);

dilbegin do_stand(arg : string);
code
{

 /* horse ?*/
 if(self.outside.type & (UNIT_ST_NPC | UNIT_ST_PC))
 {
  DO_ACT("Not here you don't.")
  return;
 }

/*
   Skills.def will prevent this action unless you position is > resting
*/

 if(self.position == POSITION_FIGHTING)
 {
  DO_ACT("Do you not consider fighting as standing?")
  return;
 }
 else if(self.position == POSITION_STANDING)
  {
   DO_ACT("You are already standing.")
   return;
  }
 else if(self.position == POSITION_SITTING)
 {
  DO_ACT("You stand up.")
  act("$1n clambers on $1s feet.", A_HIDEINV, self, null, null, TO_REST);
  self.position := POSITION_STANDING;

   send_done("stand",self,null,null,0,arg,null);


  return;
 }
 else if(self.position == POSITION_RESTING)
 {
  DO_ACT("You stop resting, and stand up.")
  act("$1n stops resting, and clambers on $1s feet.", A_HIDEINV, self,
null, null, TO_REST);
  self.position := POSITION_STANDING;

   send_done("stand",self,null,null,0,arg,null);


  return;
 }
 else /* shrug, ask papi */
 {
  DO_ACT("You stop floating around, and put your feet on the ground.")
  act("$1n stops floating around, and puts $1s feet on the ground.",
  A_HIDEINV, self, null, null, TO_REST);
  self.position := POSITION_STANDING;

   send_done("stand",self,null,null,0,arg,null);


  return;
 }

return;

}
dilend

dilbegin do_sit(arg : string);
code
{

if(self.position == POSITION_STANDING)
 {
  DO_ACT("You sit down.")
  act("$1n sits down.",
     A_HIDEINV, self, null, null, TO_REST);
  self.position := POSITION_SITTING;

   send_done("sit",self,null,null,0,arg,null);


  }
else if(self.position == POSITION_SITTING)
 {
  DO_ACT("You are sitting already.")
 }
else if(self.position == POSITION_RESTING)
 {
  DO_ACT("You stop resting, and sit up.")
  act("$1n stops resting.",
    A_HIDEINV, self, null, null, TO_REST);
  self.position := POSITION_SITTING;

   send_done("sit",self,null,null,0,arg,null);


 }
else if(self.position == POSITION_FIGHTING)
 {
  DO_ACT("Sit down while fighting? are you MAD?")
 }
else
 {
  DO_ACT("You stop floating around, and sit down.")
  act("$1n stops floating around, and sits down.",A_HIDEINV, self, null,
null, TO_REST);
  self.position := POSITION_SITTING;

   send_done("sit",self,null,null,0,arg,null);


 }

return;

}
dilend

dilbegin do_rest(arg : string);
code
{

 if(self.position == POSITION_STANDING)
  {
   DO_ACT("You sit down and rest your tired bones.")
   act("$1n sits down and rests.", A_HIDEINV, self, null, null, TO_REST);
   self.position := POSITION_RESTING;

   send_done("rest",self,null,null,0,arg,null);


  }
 else if(self.position == POSITION_SITTING)
 {
   DO_ACT("You rest your tired bones.")
   act("$1n rests.", A_HIDEINV, self, null, null, TO_REST);
   self.position := POSITION_RESTING;

   send_done("rest",self,null,null,0,arg,null);

 }
 else if(self.position == POSITION_RESTING)
 {
  DO_ACT("You are already resting.")
 }
 else if(self.position == POSITION_FIGHTING)
 {
  DO_ACT("Rest while fighting? are you MAD?")
 }
 else
 {
  DO_ACT("You stop floating around, and stop to rest your tired bones.")
  act("$1n stops floating around, and rests.",
    A_HIDEINV, self, null, null, TO_REST);
  self.position := POSITION_RESTING;

   send_done("rest",self,null,null,0,arg,null);

 }

return;
}
dilend

dilbegin do_sleep(arg : string);
code
{

 if((self.position == POSITION_STANDING) or
    (self.position == POSITION_RESTING) or
    (self.position == POSITION_SITTING))
 {
  DO_ACT("You go to sleep.")
  act("$1n lies down and falls asleep.",
     A_HIDEINV, self, null, null, TO_REST);
  self.position := POSITION_SLEEPING;

   send_done("sleep",self,null,null,0,arg,null);

 }
 else if(self.position == POSITION_SLEEPING)
 {
  sendtext("You are already sound asleep.&n", self);
 }
 else if(self.position == POSITION_FIGHTING)
 {
  DO_ACT("Sleep while fighting? are you MAD?")
 }
 else
 {
  DO_ACT("You stop floating around, and lie down to sleep.")
  act("$1n stops floating around, and lie down to sleep.",A_HIDEINV, self,
null, null, TO_REST);
  self.position := POSITION_SLEEPING;

   send_done("sleep",self,null,null,0,arg,null);

 }

return;

}
dilend

dilbegin do_wake(arg : string);
var
vict: unitptr;

code
{

if(arg == "")
 {
  if(self.position > POSITION_SLEEPING)
   DO_ACT("You are already awake.")
    else
    {
     sendtext("You awaken, and start resting.&n",self);
     act("$1n awakens.", A_HIDEINV, self, null, null, TO_REST);
     self.position := POSITION_RESTING;

   send_done("wake",self,null,null,0,arg,null);

    }
   return;
  }
else
{
 if(self.position == POSITION_SLEEPING)
  DO_ACT("You can't wake people up if you are asleep yourself!")
  else
  {
    vict := findunit(self, arg, FIND_UNIT_SURRO, null);

   if((vict == null) or (not(vict.type & (UNIT_ST_NPC | UNIT_ST_PC)))
      or not(visible(self,vict)))
   {
    DO_ACT("You do not see that person here.")
    return;
   }

   if(vict == self)
   {
    DO_ACT("If you want to wake yourself up, just type 'wake'")
    return;
   }

   if(vict.position < POSITION_SLEEPING)
    {
     act("You can't wake $3m up!",
       A_SOMEONE, self, null, vict, TO_CHAR);
     return;
    }

  if(vict.position == POSITION_SLEEPING)
   {
    vict.position := POSITION_RESTING;
    act("You wake $3m up.",
       A_SOMEONE, self, null, vict, TO_CHAR);
    act("$3n is awakened by $1n.",
       A_SOMEONE, self, null, vict, TO_NOTVICT);
    act("You are awakened by $1n.", A_SOMEONE, self, null, vict, TO_VICT);

   send_done("wake",vict,null,self,0,arg,null);


   }
  return;
 }
 return;
}
}
dilend


dilbegin cmd_clear(arg:string);
code
{
sendtext ("&h",self);
return ;

}
dilend

dilbegin stringlist shell (s:stringlist);
var
ln:integer;
imax:integer;
i:integer;
iVal:string;
inc:integer;
j:integer;
code
{
iMax:=length(s);
inc:=0;

while (inc < iMax)
inc := inc *3+1;

inc:=inc/3;
while(inc > 0)
{
i:=inc;
while (i < iMax)
 {
 iVal := s.[i];
 j:=i;
 while(j > (inc-1))
  {
  if(iVal < s.[j - inc])
   {
   s.[j] := s.[j - inc];
   }
  else
   break;
  j:=j-inc;
  }
 s.[j] := iVal;
 i:=i+1;
 }
inc := inc /3;
}

return (s);
}
dilend

dilbegin comm_dil(arg : string);
external
stringlist shell (s:stringlist);
var
newlist:stringlist;
istart:integer;
 cmd : cmdptr;
 i : integer;
cmdlist:stringlist;
imax:integer;
ln:integer;
buff:string;
code
{
istart:=0;
  cmd := chead();
while (cmd)
{
if ((cmd.level<=self.level) and
(cmd.type!=TYPE_SOCIAL) and
(cmd.type!=TYPE_SKILL))
addstring (cmdlist,cmd.name);
cmd := cmd.next;
}

newlist:=shell(cmdlist);
i:=0;
sendtext ("The following comands are available:&n&n",self);
buff:="";
iMax:=length (newlist);
while (i {
if (i  buff :=buff+"&s5";
 ln:=length(newlist.[i]);
ln:=15-ln;
buff:=buff+newlist.[i]+"&&s"+itoa(ln);
}
    else
    {
     buff:=buff+"&n";
    break;
    }
if (i+1  ln:=length(newlist.[i+1]);
ln:=15-ln;
buff:=buff+newlist.[i+1]+"&&s"+itoa(ln);
}
    else
    {
     buff:=buff+"&n";
    break;
    }
if (i+2  ln:=length(newlist.[i+2]);
ln:=15-ln;
buff:=buff+newlist.[i+2]+"&&s"+itoa(ln);
    }
    else
    {
     buff:=buff+"&n";
    break;
    }
if (i+3 buff:=buff+newlist.[i+3]+"&n";
    }
    else
    {
     buff:=buff+"&n";
    break;
    }
i:=i+4;
}
buff:=textformat(buff);
pagestring (buff,self);

  quit;
}
dilend


dilbegin soc_dil(arg : string);
external
stringlist shell (s:stringlist);
var
buff:string;
newlist:stringlist;
 cmd : cmdptr;
 i : integer;
ln:integer;
cmdlist:stringlist;
imax:integer;
code
{
  cmd := chead();
while (cmd)
{
if ((cmd.level<=self.level) and
(cmd.type==TYPE_SOCIAL))
addstring (cmdlist,cmd.name);
cmd := cmd.next;
}
sendtext ("The following socials are available:&n&n",self);

newlist:=shell(cmdlist);
i:=0;
buff:="";
iMax:=length (newlist);
while (i {
if (i  buff :=buff+"&s5";
 ln:=length(newlist.[i]);
ln:=15-ln;
buff:=buff+newlist.[i]+"&&s"+itoa(ln);
}
    else
    {
     buff:=buff+"&n";
    break;
    }
if (i+1  ln:=length(newlist.[i+1]);
ln:=15-ln;
buff:=buff+newlist.[i+1]+"&&s"+itoa(ln);
}
    else
    {
     buff:=buff+"&n";
    break;
    }
if (i+2  ln:=length(newlist.[i+2]);
ln:=15-ln;
buff:=buff+newlist.[i+2]+"&&s"+itoa(ln);
    }
    else
    {
     buff:=buff+"&n";
    break;
    }
if (i+3 buff:=buff+newlist.[i+3]+"&n";
    }
    else
    {
     buff:=buff+"&n";
    break;
    }
i:=i+4;
}
buff:=textformat(buff);
pagestring (buff,self);

  quit;
}
dilend

dilbegin ski_dil(arg : string);
external
stringlist shell (s:stringlist);
var
buff:string;
newlist:stringlist;
 cmd : cmdptr;
 i : integer;
ln:integer;
cmdlist:stringlist;
imax:integer;
code
{
  cmd := chead();
while (cmd)
{
if ((cmd.level<=self.level) and
(cmd.type==TYPE_SKILL))
addstring (cmdlist,cmd.name);
cmd := cmd.next;
}

addstring (cmdlist,"dual wield");
addstring (cmdlist,"shield");
addstring(cmdlist,"climb");
addstring (cmdlist,"leadership");
sendtext ("The following skills are available:&n&n",self);

newlist:=shell(cmdlist);
i:=0;
buff:="";
iMax:=length (newlist);
while (i {
if (i  buff :=buff+"&s5";
 ln:=length(newlist.[i]);
ln:=15-ln;
buff:=buff+" "+newlist.[i]+" &&s"+itoa(ln);
}
    else
    {
     buff:=buff+"&n";
    break;
    }
if (i+1  ln:=length(newlist.[i+1]);
ln:=15-ln;
buff:=buff+" "+newlist.[i+1]+" &&s"+itoa(ln);
}
    else
    {
     buff:=buff+"&n";
    break;
    }
if (i+2 buff:=buff+" "+newlist.[i+2]+"&n";
    }
    else
    {
     buff:=buff+"&n";
    break;
    }
i:=i+3;
}
buff:=textformat(buff);
pagestring (buff,self);

  quit;
}
dilend

dilbegin wizhelp(arg : string);
external
stringlist shell (s:stringlist);
var
buff:string;
newlist:stringlist;
 cmd : cmdptr;
 i : integer;
ln:integer;
cmdlist:stringlist;
imax:integer;
code
{
  cmd := chead();
while (cmd)
{
if ((cmd.level<=self.level) and
(cmd.level>=200) and
(cmd.type!=TYPE_SOCIAL))
addstring (cmdlist,cmd.name+"<"+itoa(cmd.level)+">");
cmd := cmd.next;
}
sendtext ("The following Admin commands are available:&n&n",self);

newlist:=shell(cmdlist);
i:=0;
buff:="";
iMax:=length (newlist);
while (i {
if (i  buff :=buff+"&s5";
 ln:=length(newlist.[i]);
ln:=18-ln;
buff:=buff+newlist.[i]+"&&s"+itoa(ln);
}
    else
    {
     buff:=buff+"&n";
    break;
    }
if (i+1  ln:=length(newlist.[i+1]);
ln:=18-ln;
buff:=buff+newlist.[i+1]+"&&s"+itoa(ln);
}
    else
    {
     buff:=buff+"&n";
    break;
    }
if (i+2  ln:=length(newlist.[i+2]);
ln:=18-ln;
buff:=buff+newlist.[i+2]+"&&s"+itoa(ln);
    }
    else
    {
     buff:=buff+"&n";
    break;
    }
if (i+3 buff:=buff+newlist.[i+3]+"&n";
    }
    else
    {
     buff:=buff+"&n";
    break;
    }
i:=i+4;
}
buff:=textformat(buff);
pagestring (buff,self);

  quit;
}
dilend

dilbegin wizsoc(arg : string);
external
stringlist shell (s:stringlist);
var
buff:string;
newlist:stringlist;
 cmd : cmdptr;
 i : integer;
ln:integer;
cmdlist:stringlist;
imax:integer;
code
{
  cmd := chead();
while (cmd)
{
if ((cmd.level<=self.level) and
(cmd.level>=200) and
(cmd.type==TYPE_SOCIAL))
addstring (cmdlist,cmd.name+"<"+itoa(cmd.level)+">");
cmd := cmd.next;
}

newlist:=shell(cmdlist);
i:=0;
sendtext ("The following Admin socials are available:&n&n",self);
buff:="";
iMax:=length (newlist);
while (i {
if (i  buff :=buff+"&s5";
 ln:=length(newlist.[i]);
ln:=18-ln;
buff:=buff+newlist.[i]+"&&s"+itoa(ln);
}
    else
    {
     buff:=buff+"&n";
    break;
    }
if (i+1  ln:=length(newlist.[i+1]);
ln:=18-ln;
buff:=buff+newlist.[i+1]+"&&s"+itoa(ln);
}
    else
    {
     buff:=buff+"&n";
    break;
    }
if (i+2  ln:=length(newlist.[i+2]);
ln:=18-ln;
buff:=buff+newlist.[i+2]+"&&s"+itoa(ln);
    }
    else
    {
     buff:=buff+"&n";
    break;
    }
if (i+3 buff:=buff+newlist.[i+3]+"&n";
    }
    else
    {
     buff:=buff+"&n";
    break;
    }
i:=i+4;
}
buff:=textformat(buff);
pagestring (buff,self);

  quit;
}
dilend




dilbegin aware cmd_bugs(st : string);
var
  t : string;
  z : unitptr;
  i : integer;
code
{
if (self.type!=UNIT_ST_PC)
return;
  sendtext("Enter your bug reports. You have approximately 4000 "+
           "characters to work with. Note that if you input only a "+
           "single word or nothing at all, it will abort.&n", self);
  beginedit(self);
  wait(SFB_EDIT, self == activator);
  t := argument;
  if (length(getwords(t)) < 2)
  {
     sendtext("Insufficient report. Exiting.&n", self);
     quit;
  }
  z := self.outside;
  while (z.type != UNIT_ST_ROOM)
     z := z.outside;
  t := z.nameidx+"@"+z.zoneidx+" ["+self.name+"] "+asctime(realtime)+
       argument+"&n&n";
  t := textformat(t);
  i := flog("bugs", t, "a");
  sendtext("Thank you. They will be corrected.&n", self);
  quit;
}
dilend


dilbegin aware cmd_ideas(st : string);
var
  t : string;
  z : unitptr;
  i : integer;
code
{
if (self.type!=UNIT_ST_PC)
return;
  sendtext("Enter your ideas. You have approximately 4000 characters "+
           "to work with. Note that if you input only a single word or "+
           "nothing at all, it will abort.&n", self);
  beginedit(self);
  wait(SFB_EDIT, self == activator);
  t := argument;
  if (length(getwords(t)) < 2)
  {
     sendtext("Insufficient report. Exiting.&n", self);
     quit;
  }
  z := self.outside;
  while (z.type != UNIT_ST_ROOM)
     z := z.outside;
  t := z.nameidx+"@"+z.zoneidx+" ["+self.name+"] "+asctime(realtime)+
       argument+"&n&n";
  t := textformat(t);
  i := flog("ideas", t, "a");
  sendtext("Thank you for your comments.&n", self);
  quit;
}
dilend

dilbegin aware cmd_typos(st : string);
var
  t : string;
  z : unitptr;
  i : integer;
code
{
if (self.type!=UNIT_ST_PC)
return;
  sendtext("Enter your typo reports. You have approximately 4000 "+
           "characters to work with. Note that if you input only a "+
           "single word or nothing at all, it will abort.&n", self);
  beginedit(self);
  wait(SFB_EDIT, self == activator);
  t := argument;
  if (length(getwords(t)) < 2)
  {
     sendtext("Insufficient report. Exiting.&n", self);
     quit;
  }
  z := self.outside;
  while (z.type != UNIT_ST_ROOM)
     z := z.outside;
  t := z.nameidx+"@"+z.zoneidx+" ["+self.name+"] "+asctime(realtime)+
       argument+"&n&n";
  t := textformat(t);
  i := flog("typos", t, "a");
  sendtext("Thank you. They will be corrected.&n", self);
  quit;
}
dilend


dilbegin string racestring (i:integer);
code
{

if (i == RACE_HUMAN)
return("human");
else if (i == RACE_ELF)
return("elf");
  else if (i == RACE_DWARF)
   return("dwarf");
else if (i == RACE_HALFLING)
return("halfling");
else if (i == RACE_GNOME)
return("gnome");
else if (i == RACE_HALF_ORC)
return("half-orc");
else if (i == RACE_HALF_OGRE)
  return("half-ogre");
else if (i == RACE_HALF_ELF)
return("half-elf");
else if (i == RACE_BROWNIE)
return("brownie");
else if (i == RACE_GROLL)
return("groll");
else if (i == RACE_DARK_ELF)
return("darkelf");
else if (i==RACE_GIANT)
return("giant");
  else if (i == RACE_BIRD)
 return ("phoenix");
else if (i== RACE_SNAKE)
return ("viper");
else if (i == RACE_VAMPIRE)
return ("vampire");
else if (i == RACE_DRAGON_RED)
return ("red dragon");
else if (i == RACE_ELEMENTAL_FROST)
return ("ice elemental");
else if (i == RACE_LION)
return("lion");
else if (i == RACE_SHADOW_DEVIL)
return ("shadow demon");
else if (i == RACE_CAT)
return ("black panther");
else if (i == RACE_DINOSAUR)
return ("basilisk");

return ("Not A Race");
}
dilend

dilbegin string wpn_rating (wpn:integer);
code
{
if (wpn<10)
return ("You're utterly hopeless with ");
else if (wpn<25)
return ("You're impossible with ");
else if (wpn<40)
return ("You're poor with ");
else  if (wpn<50)
return ("You're good with ");
else if (wpn<70)
return("You're skilled with ");
else if (wpn<90)
return ("You're specialized with ");
else if (wpn < 100)
return ("You're supreme with ");
else if (wpn<150)
return ("You're expert with ");
else
return ("You're godly with ");

}
dilend

dilbegin string ski_rating (ski:integer);
code
{
if (ski<10)
return("You're utterly hopeless with ");
else if (ski<25)
 return("You're impossible with ");
else if (ski<40)
 return("You're poor with ");
else if (ski<50)
 return("You're good with");
else if (ski<70)
 return("You're skilled with");
else if (ski<90)
 return("You're specialized with");
else if (ski<100)
 return("You're supreme with ");
else if (ski<150)
 return("You're expert with ");
else
 return("You're godly with ");

}
dilend

dilbegin string sp_rating (sp:integer);
code
{
if (sp<=10)
return ("You might remember ");
else if (sp<=25)
 return ("You can almost remember ");
else if (sp<=40)
 return ("You can remember ");
else if (sp<=50)
 return ("You have practiced ");
else if (sp<=70)
 return ("You have learned ");
else  if (sp<=90)
 return ("You're master of ");
else if (sp<=100)
 return ("You're expert with ");
else
 return ("You're godly with ");

}dilend





dilbegin gtitle (arg:string);
var
pname:string;
pc:unitptr;
code
{
if (self.level<200)
{
sendtext ("You don't have access tot he 'title' command.&n",self);
quit;
}

pname:=getword(arg);

pc:=findunit(self,pname,FIND_UNIT_WORLD,null);
if (pc==null)
{
sendtext("No such person found.&n", self);
quit;
}

if ((pc.type!=UNIT_ST_PC) or
(not(visible(self,pc))))
{
sendtext("No such person found.&n", self);
quit;
}

log (self.name+" set "+pc.name+"'s  title to "+arg);
arg:=arg+"&[default]";
arg:=textformat(arg);
pc.title:=arg;
sendtext ("You set "+pc.name+"'s title to '"+arg+"'",self);
quit;
}
dilend

dilbegin aware describe (arg:string);
var
side:string;
oneword:stringlist;
location:string;
ln:integer;
args:stringlist;
temp:string;
i:integer;
x:extraptr;
code
{

if (self.type!=UNIT_ST_PC)
quit;
if (self.position {
act ("Recover first and then you can describe your body
parts.",A_ALWAYS,self,null,null,TO_CHAR);
quit;
}

args:=getwords(arg);
ln:=length(args);
if ((ln<1) or (ln>2))
{
sendtext ("No such location to describe.",self);
quit;
}
else if (ln>1)
 goto two_word;

:one_word:
if ((arg==left("help",length(arg))) or
(arg==""))
goto hlp_dscr;
oneword:={"arms","butt","ears","eyes","face","feet","General","hair","hands"
,

"head","legs","mouth","neck","nose","nostrils","teeth","toes","tounge"};

i:=0;
ln:=length(args.[0]);
temp:="ERROR";
while (i<18)
{
if (args.[0]==left(oneword.[i],ln))
 {
 temp:=oneword.[i];
 break;
 }
i:=i+1;
}

if (temp=="ERROR")
{
sendtext ("No such location to describe.",self);
quit;
}

goto describe;

:two_word:
oneword:={"arm","leg","foot","hand","eye","ear"};
temp:="ERROR";
ln:=length(args.[0]);
if (args.[0] == left("left",ln))
side:="left";
else if (args.[0] == left("right",ln))
side:="right";
else
{
sendtext ("No such location to describe.",self);
quit;
}

i:=0;
while (i<6)
{
if (args.[1]==left(oneword.[i],ln))
 {
 temp:=oneword.[i];
 break;
 }
i:=i+1;
}

if (temp=="ERROR")
{
sendtext ("No such location to describe.",self);
quit;
}

temp:=side+" "+temp;

:describe:
if (temp=="General")
location:="";
else
location:=temp;

x:=location in self.extra;
if (x!=null)
if (location=="")
sendtext("your Current description for your body is:
&n"+x.descr+"&n",self);
else
 sendtext("your Current description for your "+location+"is:
&n"+x.descr+"&n",self);


if (location=="")
sendtext ("Enter a text you would like others to see when they look at your
body.&n",self);
else
sendtext ("Enter a text you would like others to see when they look at your
"+location+".&n",self);

beginedit (self);
wait(SFB_EDIT,self==activator) ;
temp:=textformat(argument);
oneword:={""};
subextra(self.extra,location);
addstring (oneword, location);
addextra (self.extra,oneword,temp);
sendtext ("Description added.&n",self);
quit;
:hlp_dscr:

sendtext ("&nCorrect usage of 'describe':&n&n",self);
sendtext ("describe &n&n",self);
sendtext(" being one of the following:&n&n",self);
sendtext( "arms        butt        ears        eyes&n"+
    "face        feet        General     hair&n"+
    "hands      head        left arm    left leg&n"+
    "left foot   left hand   left eye    left ear&n"+
    "legs        mouth       neck        nose&n"+
    "nostrils    right arm   right leg   right foot&n"+
    "right hand  right eye   right ear   teeth&n"+
    "toes        tounge&n&n",self);
sendtext ("Example:  &n&n",self);
sendtext ("describe left leg&n",self);
quit;
}
dilend

dilbegin apply_poison (pc:unitptr,pois:integer,amount:integer);
code
{

if ((pois>0) and (pc.level<200))
{
act("Oops, it tasted rather strange ?!!?",
A_SOMEONE, pc, null, null, TO_CHAR);
act("$1n chokes and utters some strange sounds.",
 A_HIDEINV, pc, null, null, TO_REST);

 dilcopy("spl_poison@spells("+itoa(amount*pois)+")", pc);
}


return;
}
dilend

dilbegin integer dv(d_obj:unitptr,s:string);
var
x:extraptr;
code
{
if (s=="thirst")
{
x:="$drink_thirst" in d_obj.extra;
if (x==null)
 return (0);
else if (x.descr=="")
 return (0);
else
 return (atoi(x.descr));
}
else if (s=="full")
{
x:="$drink_full" in d_obj.extra;
if (x==null)
 return (0);
else if (x.descr=="")
 return (0);
else
 return (atoi(x.descr));
}
else if (s=="drunk")
{
x:="$drink_drunk" in d_obj.extra;
if (x==null)
 return (0);
else if (x.descr=="")
 return (0);
else
 return (atoi(x.descr));
}

return (0);
}
dilend

dilbegin gain_cond(pc:unitptr,cond:string, i:integer);
var
dr:integer;/*drunk*/
code
{
dr:=pc.drunk;

if (pc.type!=UNIT_ST_PC)
return;
if ((cond=="thirst") and (pc.thirst>=48))
return;
else if (cond=="thirst")
{
pc.thirst:=pc.thirst+i;
if (pc.thirst>24)
 pc.thirst:=24;
if (pc.thirst<-96)
  pc.thirst:=-96;
if (pc.thirst>3)
 return;
if (pc.thirst>-4)
 sendtext("You are thirsty.&n",pc);
else if (pc.thirst>-8)
 sendtext("You are very thirsty.&n",pc);
else if (pc.thirst>-12)
 sendtext("You are dehydrated.&n",pc);
}
else if ((cond=="full") and (pc.full>=48))
return;
else if (cond=="full")
{
pc.full:=pc.full+i;
if (pc.full>24)
 pc.full:=24;
 if (pc.full<-96)
  pc.full:=-96;
if (pc.full>3)
 return;
if (pc.full>-4)
sendtext("You are hungry.&n",pc);
else if (pc.full>-8)
sendtext("You are very hungry.&n",pc);
else if (pc.full>-12)
sendtext("You are starving.&n",pc);
}
else if ((cond=="drunk") and (pc.drunk>=48))
return;
else if (cond=="drunk")
{
pc.drunk:=pc.drunk+i;
if ((pc.drunk  sendtext ("You sober up!&n",pc);
if (pc.drunk>24)
 pc.drunk:=24;
 if (pc.drunk<0)
  pc.drunk:=0;/*you can't get any more sober than this*/
  if (pc.drunk>11)
   sendtext ("You are seeing double!&n",pc);
else if (pc.drunk>7)
 sendtext("You are feeling very light headed.&n",pc);
else if (pc.drunk>3)
 sendtext ("You are getting tipsy.",pc);
}

return;
}
dilend

dilbegin sub_drink_info(d_obj:unitptr);
var
x:extraptr;
code
{
setweight(d_obj,d_obj.weight+(-(d_obj.value[0])));
d_obj.value[0]:=0;
d_obj.value[3]:=0;
substring (d_obj.names,d_obj.names.[length (d_obj.names)-1]);
subextra (d_obj.extra,"$drink_color");
subextra (d_obj.extra,"$drink_thirst");
subextra (d_obj.extra,"$drink_full");
subextra (d_obj.extra,"$drink_drunk");
return ;
}
dilend

dilbegin do_drink (arg:string);
external
sub_drink_info (u:unitptr);
apply_poison (pc:unitptr,pois:integer,amount:integer);
gain_cond(pc:unitptr,cond:string,i:integer);
integer dv (d_obj:unitptr,s:string);
var
d_obj:unitptr;
amount:integer;
i:integer;
pois:integer;
code
{
if (arg=="")
{
sendtext("What do you want to drink?&n", self);
quit;
}

d_obj:=findunit(self,arg,FIND_UNIT_HERE,null);
if (d_obj==null)
{
act("You can't find it!", A_SOMEONE, self, null, null, TO_CHAR);
quit;
}

if ((d_obj.type!=UNIT_ST_OBJ) or (d_obj.objecttype!=ITEM_DRINKCON))
{
act("You can not drink from that.", A_SOMEONE, self, null, null, TO_CHAR);
quit;
}

if (d_obj.value[0]<-1)
{
act ("Drink Container Error report to an admin.",
A_ALWAYS,self,null,null,TO_CHAR);
quit;
}

if (d_obj.value[0]==-1)
amount:=rnd(3, 10);
else if (self.level>=200)
 amount:=10;
else
amount:=rnd(3,10);

if (d_obj.value[0] amount:=d_obj.value[0];

if (amount < 0) /* Straange... Only value "0" should be negative*/
   amount := 0;

if (d_obj.value[0]<=0)
{
act("The $2N is empty.",
 A_SOMEONE, self, d_obj, null, TO_CHAR);
quit;
}

if (self.level<200)
{
if (self.drunk>=24)
 {
 /* The pig is drunk */
 act("You simply fail to reach your mouth!", A_SOMEONE, self, null, null,
TO_CHAR);
  act("$1n tried to drink but missed $1s mouth!",A_HIDEINV, self, null,
null, TO_REST);
 quit;
 }

if (self.thirst>=24)
 {
 /* Stomach full */
 act("Your stomach can't contain anymore!", A_SOMEONE, self, null, null,
TO_CHAR);
 quit;
 }
}

if ((d_obj.value[0]>=0) and (amount >=d_obj.value[0]))
amount:=d_obj.value[0];

act("$1n drinks $3t from $2n.",
A_HIDEINV, self, d_obj,d_obj.names.[length(d_obj.names)-1], TO_REST);
act("You drink the $2t.",
A_SOMEONE, self,d_obj.names.[length(d_obj.names)-1] , null, TO_CHAR);
i:=dv(d_obj,"drunk");
gain_cond(self, "drunk",((i*amount)/4));
i:=dv(d_obj,"full");
gain_cond(self, "full",((i*amount)/4));
i:=dv(d_obj,"thirst");
gain_cond(self, "thirst",((i*amount)/4));
pois:=d_obj.value[3];
apply_poison(self,pois,amount);
if (d_obj.capacity>0)
{
 /* empty the container, and no longer poison. */
d_obj.value[0]:=d_obj.value[0]-amount;
setweight(d_obj, d_obj.weight-amount); /* Subtract amount */
if (d_obj.value[0]<=0)
 {
sub_drink_info(d_obj);
}
}

if (self.drunk>10)
act("You feel drunk.", A_ALWAYS, self, null, null, TO_CHAR);

if (self.thirst<15)
act("You still feel thirsty.", A_ALWAYS, self, null, null, TO_CHAR);

if (self.full<15)
act("You still feel hungry.", A_ALWAYS, self, null, null, TO_CHAR);
send_done ("drink",self,d_obj,null,pois,"",null);
quit;
}
dilend

dilbegin do_eat (arg:string);
external
apply_poison (pc:unitptr,pois:integer,amount:integer);
gain_cond(pc:unitptr,cond:string,i:integer);
var
food:unitptr;
pois:integer;
amount:integer;
code
{
if (arg=="")
{
sendtext("What do you want to eat?&n",self);
quit;
}

food:=findunit (self,arg,FIND_UNIT_HERE,null);
if (food==null)
{
act("You've got no such food.", A_SOMEONE, self, null, null, TO_CHAR);
quit;
}
else if ((food.type==UNIT_ST_OBJ) and (food.objecttype==ITEM_FOOD) and
(self.level<200))
{
if ((self.type==UNIT_ST_PC) and (self.level<200) and (self.full>=24))
 {
 act("You are too full to eat more!",A_SOMEONE, self, null, null, TO_CHAR);
 quit;
 }
if (food.value[0]<=0)
 {
 act("There is nothing left to eat.", A_SOMEONE, self, food, null,
TO_CHAR);
 quit;
 }

 amount:=food.value[0];

act("$1n eats $2n.",
A_HIDEINV, self,   food, null, TO_REST);
act("You eat $2n.",   A_SOMEONE, self, food, null, TO_CHAR);

gain_cond(self, "full", amount);

pois:=food.value[3];
apply_poison(self,pois,amount);

food.value[0]:=food.value[0]-amount;
}
else if ((self.level<200) or (food.type==UNIT_ST_ROOM))
{
act("Your stomach refuses to eat that!?!",
 A_SOMEONE, self, null, null, TO_CHAR);
 quit;
 }
else
{
act("$1n eats $2n.",  A_HIDEINV, self, food, null, TO_REST);
act("You eat $2n.",   A_HIDEINV, self, food, null, TO_CHAR);
}

if (self.level<200)
{

if (self.drunk>10)
act("You feel drunk.", A_ALWAYS, self, null, null, TO_CHAR);

if (self.thirst<15)
act("You still feel thirsty.",  A_ALWAYS, self, null, null, TO_CHAR);

if (self.full<15)
act("You still feel hungry.",   A_ALWAYS, self, null, null, TO_CHAR);
 }
send_done ("eat",self,food,null,pois,"",null);
destroy (food);
quit;
}
dilend

dilbegin do_sip(arg:string);
external
sub_drink_info (u:unitptr);
apply_poison (pc:unitptr,pois:integer,amount:integer);
gain_cond(pc:unitptr,cond:string,i:integer);
integer dv (d_obj:unitptr,s:string);
var
i:integer;
pois:integer;
d_obj:unitptr;
amount:integer;
code
{
if (arg=="")
act("What do you want to sip?",
 A_SOMEONE, self, null, null, TO_CHAR);
d_obj:=findunit(self,arg,FIND_UNIT_HERE,null);
if (d_obj==null)
{
act("You can't find such a thing.",
 A_SOMEONE, self, null, null, TO_CHAR);
quit;
}
else if ((d_obj.type!=UNIT_ST_OBJ) and (d_obj.objecttype!=ITEM_DRINKCON))
{
act("You can't sip from that.",
 A_SOMEONE, self, null, null, TO_CHAR);
quit;
}

amount:=1;
if (d_obj.value[0]<=0)
{
act("The $2N is empty.",
 A_SOMEONE, self, d_obj, null, TO_CHAR);
quit;
}

if (self.level<200)
{
if (self.drunk>=24)
 {
 /* The pig is drunk */
 act("You simply fail to reach your mouth!", A_SOMEONE, self, null, null,
TO_CHAR);
  act("$1n tried to sip but missed $1s mouth!",A_HIDEINV, self, null, null,
TO_REST);
 quit;
 }

if (self.thirst>=24)
 {
 /* Stomach full */
 act("Your stomach can't contain anymore!", A_SOMEONE, self, null, null,
TO_CHAR);
 quit;
 }
}

if ((d_obj.value[0]>=0) and (amount >=d_obj.value[0]))
amount:=d_obj.value[0];

act("$1n sips $3t from $2n.",
A_HIDEINV, self, d_obj,d_obj.names.[length(d_obj.names)-1], TO_REST);
act("You sip the $2t.",
A_SOMEONE, self,d_obj.names.[length(d_obj.names)-1] , null, TO_CHAR);

i:=dv(d_obj,"drunk");
gain_cond(self, "drunk",(i*amount)/4);
i:=dv(d_obj,"full");
gain_cond(self, "full",(i*amount)/4);
i:=dv(d_obj,"thirst");
gain_cond(self, "thirst",(i*amount)/4);

pois:=d_obj.value[3];
apply_poison(self,pois,amount);

if (d_obj.capacity>0)
{
 /* empty the container, and no longer poison. */
d_obj.value[0]:=d_obj.value[0]-amount;
setweight(d_obj, d_obj.weight-amount); /* Subtract amount */
if (d_obj.value[0]<=0)
 {

sub_drink_info(d_obj);
}
}
if (self.drunk>10)
act("You feel drunk.",
 A_ALWAYS, self, null, null, TO_CHAR);

if (self.thirst<15)
act("You still feel thirsty.",
 A_ALWAYS, self, null, null, TO_CHAR);

if (self.full<15)
act("You still feel hungry.",
 A_ALWAYS, self, null, null, TO_CHAR);
quit;
}
dilend

dilbegin do_taste(arg:string);
external
sub_drink_info (u:unitptr);
apply_poison (pc:unitptr,pois:integer,amount:integer);
gain_cond(pc:unitptr,cond:string,i:integer);
integer dv (d_obj:unitptr,s:string);
var
pois:integer;
food:unitptr;
amount:integer;
i:integer;
code
{
if (arg=="")
{
sendtext("What do you want to taste?&n",self);
quit;
}

food:=findunit (self,arg,FIND_UNIT_HERE,null);
if (food==null)
{
act("You've got no such food.",
A_SOMEONE, self, null, null, TO_CHAR);
quit;
}

if (food.type!=UNIT_ST_OBJ)
{
act("You can't taste from that.",
 A_SOMEONE, self, null, null, TO_CHAR);
 quit;
 }

if ((food.objecttype!=ITEM_FOOD) and (food.objecttype!= ITEM_DRINKCON))
{
act("Taste that?!? Your stomach refuses!", A_SOMEONE, self, null, null,
TO_CHAR);
quit;
}

amount:=1;

if (food.objecttype==ITEM_DRINKCON)
 {
 if (food.value[0]<=0)
  {
  act("The $2N is empty.",
   A_SOMEONE, self, food, null, TO_CHAR);
  quit;
  }

 if (self.level<200)
  {
  if (self.drunk>=24)
   {
   /* The pig is drunk */
   act("You simply fail to reach your mouth!", A_SOMEONE, self, null, null,
TO_CHAR);
   act("$1n tried to sip but missed $1s mouth!",A_HIDEINV, self, null,
null, TO_REST);
   quit;
    }

  if (self.thirst>=24)
   {
   /* Stomach full */
   act("Your stomach can't contain anymore!",A_SOMEONE, self, null, null,
TO_CHAR);
   quit;
   }
  }

 if ((food.value[0]>=0) and (amount >=food.value[0]))
  amount:=food.value[0];

 act("$1n tastes $3t from $2n.", A_HIDEINV, self,
food,food.names.[length(food.names)-1], TO_REST);
 act("You sip the $2t.", A_SOMEONE, self,food.names.[length(food.names)-1]
, null, TO_CHAR);

 i:=dv(food,"drunk");
 gain_cond(self, "drunk",(i*amount)/4);
 i:=dv(food,"full");
 gain_cond(self, "full",(i*amount)/4);
 i:=dv(food,"thirst");
 gain_cond(self, "thirst",(i*amount)/4);
 pois:=food.value[3];
apply_poison(self,pois,amount);
 if (food.capacity>0)
  {
  /* empty the container, and no longer poison. */
food.value[0]:=food.value[0]-amount;
setweight(food, food.weight-amount); /* Subtract amount */
if (food.value[0]<=0)
 {   /* The last bit */
setweight(food,food.weight+(-(food.value[0])));
food.value[0]:=0;
 food.value[3]:=0;
 substring (food.names,food.names.[length(food.names)-1]);
 }
}

}
else/*food*/
{
if ((self.type==UNIT_ST_PC) and (self.level<200) and (self.full>=24))
 {
 act("You are too full to taste more!",
  A_SOMEONE, self, null, null, TO_CHAR);
 quit;
 }
if (food.value[0]<=0)
 {
 act("There is nothing left to taste.",A_SOMEONE, self, food, null,
TO_CHAR);
 quit;
 }

if (amount> food.value[0])
 amount:=food.value[0];

act("$1n tastes $2n.", A_HIDEINV, self, food, null, TO_REST);
act("You taste $2n.", A_SOMEONE, self, food, null, TO_CHAR);

gain_cond(self, "full", amount);

pois:=food.value[3];
apply_poison(self,pois,amount);

food.value[0]:=food.value[0]-amount;
if (food.value[0]<=0)
 destroy (food);
else if ((self.level<200) or (food.type==UNIT_ST_ROOM))
act("Your stomach refuses to taste that!?!",A_SOMEONE, self, null, null,
TO_CHAR);
else
{
act("$1n tastes $2n.", A_HIDEINV, self, food, null, TO_REST);
act("You taste $2n.", A_HIDEINV, self, food, null, TO_CHAR);
destroy (food);
 quit;
}
}


if (self.drunk>10)
act("You feel drunk.", A_ALWAYS, self, null, null, TO_CHAR);

if (self.thirst<15)
act("You still feel thirsty.",  A_ALWAYS, self, null, null, TO_CHAR);

if (self.full<15)
act("You still feel hungry.", A_ALWAYS, self, null, null, TO_CHAR);
quit;
}
dilend



dilbegin do_pour (arg:string);
external
sub_drink_info (u:unitptr);
integer dv (d_obj:unitptr,s:string);
var
f_obj:unitptr;
t_obj:unitptr;
org:string;
amount:integer;
tx:extraptr;

fx:extraptr;
dx:extraptr;
cx:extraptr;
code
{
if (arg=="")
{
act("What do you want to pour from?",
 A_SOMEONE, self, null, null, TO_CHAR);
 quit;
 }

f_obj:=findunit(self,arg,FIND_UNIT_HERE,null);
if (f_obj==null)
{
act("You can't find it!",
 A_SOMEONE, self, null, null, TO_CHAR);
quit;
}

if ((f_obj.type!=UNIT_ST_OBJ) or (f_obj.objecttype!=ITEM_DRINKCON))
{
act("You can not pour from that.",A_SOMEONE, self, null, null, TO_CHAR);
quit;
}

if (f_obj.value[0]<=0)
{
act("The $2N is empty.", A_SOMEONE, self, f_obj, null, TO_CHAR);
quit;
}

if (arg=="")
{
act("Where do you want it? Out or in what?",A_SOMEONE, self, null, null,
TO_CHAR);
quit;
}
if (arg==" out")
{
if (f_obj.outside!=self)
 {
 act("You must carry it in order to empty it.", A_SOMEONE, self, null,
null, TO_CHAR);
 quit;
 }

if (f_obj.capacity==-1)
 {
 act("It is impossible to empty $2n.", A_SOMEONE, self, f_obj, null,
TO_CHAR);
 quit;
 }

act("$1n empties $2n.",A_HIDEINV, self, f_obj, null, TO_ROOM);
act("You empty $2n.",A_SOMEONE, self, f_obj, null, TO_CHAR);

sub_drink_info(f_obj);
send_done ("pour",self,f_obj,self.outside,0,"",null);
quit;
}

t_obj:=findunit(self,arg,FIND_UNIT_HERE,null);
if (t_obj==null)
{
act ("You can't find that to pour into.", A_ALWAYS,self,null,null,TO_CHAR);
quit;
}

if (t_obj==f_obj)
{
act("You can't pour it into itself!",A_SOMEONE, self, null, null, TO_CHAR);
quit;
}

if ((t_obj.type!=UNIT_ST_OBJ) or (t_obj.objecttype!=ITEM_DRINKCON))
{
act("You can't pour anything into that.", A_SOMEONE, self, null, null,
TO_CHAR);
quit;
}

if ((t_obj.value[0]!=0) and
(t_obj.names.[length(t_obj.names)-1]!=f_obj.names.[length(f_obj.names)-1]))
{
act("There is already another liquid in it!", A_SOMEONE, self,null,
null,TO_CHAR);
quit;
}

if (t_obj.capacity<=t_obj.value[0])
{
act("There is no room for more.",A_SOMEONE, self, null, null, TO_CHAR);
quit;
}


act("You pour the $2t into $3n.",A_SOMEONE,
self,f_obj.names.[length(f_obj.names)-1], t_obj,TO_CHAR);

if (t_obj.value[0]==0)
{
tx:="$drink_thirst" in f_obj.extra;
if (tx==null)
 {
 :error:
 log ("Drink container error on "+f_obj.nameidx+"@"+f_obj.zoneidx);
 act ("Drink container error do to new container code replace your
container.",
  A_ALWAYS, self,null,null,TO_CHAR);
 quit;
 }

fx:="$drink_full" in f_obj.extra;
if (fx==null)
 goto error;

cx:="$drink_color" in f_obj.extra;
if (cx==null)
 goto error;
dx:="$drink_drunk" in f_obj.extra;
if (dx==null)
 goto error;

subextra (t_obj.extra,"$drink_color");
subextra (t_obj.extra,"$drink_thirst");
subextra (t_obj.extra,"$drink_full");
subextra (t_obj.extra,"$drink_drunk");
addextra (t_obj.extra,cx.names,cx.descr);
addextra (t_obj.extra,tx.names,tx.descr);
addextra (t_obj.extra,fx.names,fx.descr);
addextra (t_obj.extra,dx.names,dx.descr);
addstring (t_obj.names,f_obj.names.[length (f_obj.names)-1]);
}


if (f_obj.value[0]==-1)
{
if (t_obj.capacity==0)
 amount:=0;
else
 amount:=t_obj.capacity-t_obj.value[0];
}
else if (t_obj.value[0]==-1)
amount:=f_obj.value[0];
else

{
amount:=t_obj.capacity-t_obj.value[0];
if (f_obj.value[0]  amount:=f_obj.value[0];
if (amount <0)
 amount:=0;
}

if (f_obj.value[0]>=0)
{
f_obj.value[0]:=f_obj.value[0]-amount;
setweight (f_obj, f_obj.weight-amount);
}

if (t_obj.value[0]>=0)
{
t_obj.value[0]:=t_obj.value[0]+amount;
setweight (t_obj,t_obj.weight+amount);
}

 /* Then the poison boogie */
if (f_obj.value[3]>t_obj.value[3])
t_obj.value[3]:=rnd(f_obj.value[3],t_obj.value[3]);

if (f_obj.value[0]==0)
{
sub_drink_info(f_obj);
}

send_done ("pour",self,f_obj,t_obj,0,"",null);
quit;
}
dilend

#define SPLIT_CHARS UNIT_ST_PC

dilbegin do_split(arg: string);

external string coinstring@function(coins: integer, typ: string, ext:
integer);
        integer transfercoins@function (a: unitptr, t: unitptr,
                                        coins: integer, typ: string);
var mast : unitptr;
   sel  : integer;

   in_gr: integer;
   kids : integer;
   coins: integer;
   spval: integer;
   ctype: string;
   done : integer;

   u    : unitptr;
   ms   : string;
   s    : string;
   tmp  : string;
   i    : integer;
   l    : integer;

//    beta_list: stringlist;

code
{

// Not used til something gets wrong
/* beta_list := {"Stormtamer", "Whistler", "Tooth", "Ginger", "Jashiree",
"Aelf",
   "Tiggy", "Gothmog"};

if (not (self.name in beta_list)) // Hardcoded list for beta testing
   {
   sendtext("Sorry, this command is under evaluation.&n", self);
   return;
   }
*/
arg:= getword(arg);
sel:= arg in {"iron", "copper", "silver", "gold", "platinum", "all"};

if (sel <= 0)
   sel := arg in {"ip", "cp", "sp", "gp", "pp"};

if (sel <= 0) /* still not found */
   {
   act ("You can only split iron, copper, silver, gold, or platinum pieces
"+
       "(or all of them).", A_ALWAYS, self, null, null, TO_CHAR);
   return;
   }

sel:= sel - 1;
kids:= 1; /* We expect at least one splitter, self */

if (self.master)
   {
   if (self.master.master)
       {
       mast := self;
       in_gr := FALSE;
       }

   else if (not isset (self.charflags, CHAR_GROUP) or
       not isset(self.master.charflags, CHAR_GROUP))
       {
       mast := self;
       in_gr := FALSE;
       }

   else
       {
       mast := self.master;
       in_gr := TRUE;

       foreach (UNIT_ST_PC|UNIT_ST_NPC, u)
           {
           if (u == self) continue;
           if ((u.master != mast) and (u != mast)) continue;
           if (not isset(u.charflags, CHAR_GROUP)) continue;

           kids := kids + 1; /* To know how many groupies there are in room
*/
           }

       }
   }

else
   {
   mast := self;

   if (not self.follower)
       in_gr := FALSE;

   else if (not isset(self.charflags, CHAR_GROUP))
       in_gr := FALSE;

   else foreach (SPLIT_CHARS, u)
       {
       if (u == self) continue;
       if (not visible(self, u)) continue;

       if (u.master != mast) continue;
       if (not isset(u.charflags, CHAR_GROUP)) continue;

       in_gr := TRUE;
       kids := kids + 1;
       }
   }

if (not in_gr)
   {
   act("You become rather picky with your loot.",A_ALWAYS, self, null,
null, TO_CHAR);
   act("$1n peers around, greedily playing with $1s money.",A_HIDEINV,
self, null, null, TO_REST);
   return;
   }

i:= flog ("split.log", asctime(realtime)+": "+self.name+" called the split
"+
       "command ("+itoa(sel)+")&n", "a");

if (sel == 5)
   goto split_all;

if (sel == 0)
   ctype := IRON_PIECE;
if (sel == 1)
   ctype := COPPER_PIECE;
if (sel == 2)
   ctype := SILVER_PIECE;
if (sel == 3)
   ctype := GOLD_PIECE;
if (sel == 4)
   ctype := PLATINUM_PIECE;

coins:= purse(self, ctype);

if (coins < kids) /* There are less coins of that type than group members */
   {
   act("Splitting "+itoa(coins)+" coins evenly between "+itoa(kids)+
       " people might be quite a puzzle...",A_ALWAYS, self, null, null,
TO_CHAR);
   return;
   }

spval:= coins / kids;

ms:= coinstring@function (coins, ctype, TRUE);

tmp:= ms;
s:= getword(tmp);
s:= tmp; /* To get the "platinum pieces" or such, without the amount */

ms:= coinstring@function (spval, ctype, TRUE);

act ("You start splitting your "+s+" between your group members.",
   A_ALWAYS, self, null, null, TO_CHAR);
act ("$1n starts splitting $1s "+s+".",A_HIDEINV, self, null, null,
TO_REST);

foreach (SPLIT_CHARS, u)
   {

   if (u == self)
       {
       act("You keep "+ms+" for yourself.",A_ALWAYS, self, null, null,
TO_CHAR);
       continue;
       }

   if (not visible(self, u)) continue;

   if ( ((u.master != mast) and (u != mast)) or
       not isset(u.charflags, CHAR_GROUP))
       continue; /* Not a grouped */

   act ("You give $3n "+ms+".", A_HIDEINV, self, null, u, TO_CHAR);
   act ("$1n gives $3n "+ms+".", A_HIDEINV, self, null, u, TO_NOTVICT);
   act ("$1n gives you "+ms+".", A_HIDEINV, self, null, u, TO_VICT);

   i := flog ("split.log", asctime(realtime)+": "+self.name+" split "+
       itoa(coins)+" "+ctype+" to "+ms+" (to "+u.name+")&n", "a");

   i := transfercoins@function (self, u, spval, ctype);

   if (i == FALSE)
       act("You realize something is wrong with $1n's money.",
           A_HIDEINV, self, null, u, TO_VICT);
   }

i:= flog ("split.log", asctime(realtime)+": "+self.name+" returned from the
"+
   "split command.&n", "a");
return;

:split_all:

act ("You start splitting your money between your group members.",
   A_ALWAYS, self, null, null, TO_CHAR);
act ("$1n starts splitting $1s money.",
   A_HIDEINV, self, null, null, TO_REST);


l:= MAX_MONEY;
ms:= "";

while (l >= 0)
   {
   if (l == 0)
       ctype := IRON_PIECE;
   if (l == 1)
       ctype := COPPER_PIECE;
   if (l == 2)
       ctype := SILVER_PIECE;
   if (l == 3)
       ctype := GOLD_PIECE;
   if (l == 4)
       ctype := PLATINUM_PIECE;

   coins := purse(self, ctype);

   if (coins < kids)
       {
       l := l - 1;
       continue;
       }

   spval := coins / kids;
   s := coinstring@function (spval, ctype, TRUE);

   if (ms == "")
       ms := s;

   else
       ms := ms + ", " + s;

   foreach (SPLIT_CHARS, u)
       {

       if (u == self)
           continue;

       if (not visible(self, u)) continue;

       if ( ((u.master != mast) and (u != mast)) or
       not isset(u.charflags, CHAR_GROUP))
       continue; /* Not a grouped */

       i := transfercoins@function (self, u, spval, ctype);

       if (i == FALSE)
act("You realize something is wrong with $1n's money.",A_HIDEINV, self,
null, u, TO_VICT);

       i := flog ("split.log", asctime(realtime)+": "+self.name+" split "+
           itoa(coins)+" "+ctype+" to "+s+" (to "+u.name+")&n", "a");

       }

   done := TRUE;
   l := l - 1;
   }

foreach (SPLIT_CHARS, u)
   {
   if (u == self)
       {
       act("You keep "+ms+" for yourself.",A_ALWAYS, self, null, null,
TO_CHAR);
       continue;
       }

   if (not visible(self, u)) continue;

   if ( ((u.master != mast) and (u != mast)) or
       not isset(u.charflags, CHAR_GROUP))
       continue; /* Not a grouped */

   act ("You give $3n "+ms+".", A_HIDEINV, self, null, u, TO_CHAR);
   act ("$1n gives $3n "+ms+".", A_HIDEINV, self, null, u, TO_NOTVICT);
   act ("$1n gives you "+ms+".", A_HIDEINV, self, null, u, TO_VICT);
   }

if (not done)
   {
   act("You realize you do not have enough money to split it between all "+
       "your party members.", A_ALWAYS, self, null, null, TO_CHAR);
   act("$1n seems to realize $1s purse is empty.",
       A_HIDEINV, self, null, null, TO_REST);
   }

i:= flog ("split.log", asctime(realtime)+": "+self.name+" returned from the
"+
       "split command.&n", "a");
return;

}

dilend

dilbegin no_shout (arg : string);

var
  pc       : unitptr;

  pcname   : string;
  time_str : string;
  type_str : string;

  i        : integer;
  ns_time  : integer;

code
{
  block;
  if ("New Player Helper" in self.quests) goto proceed;


  if (self.level < 200)
  {
     act("Arglebargle, glop-glyf!?!",
         A_ALWAYS, self, null, null, TO_CHAR);
     quit;
  }

:proceed:
  pcname := getword(arg);

  pc := findunit(self, pcname, FIND_UNIT_WORLD, null);

  if ((pc == null) or (pc.type != UNIT_ST_PC) or (pc.minv > self.level))
  {
     act("No such PC in the world.",
         A_ALWAYS, self, null, null, TO_CHAR);
     quit;
  }

  if (self.level <= pc.level)
  {
     act("I don't think $3e would appreciate that.",A_ALWAYS, self, null,
pc, TO_CHAR);
     quit;
  }
if (("New Player Helper" in self.quests) and (pc.level > 20))
 {
act ("that person is not a newbie this only works for level 20 and down.",
 A_ALWAYS, self, null, null, TO_CHAR);
quit;
}

  if (isset(pc.pcflags, PC_NOSHOUTING))
  {
     act("Noshouting removed from $3n.",A_ALWAYS, self, null, pc, TO_CHAR);
     act("Your sore throat suddenly clears up.",A_ALWAYS, pc, null, null,
TO_CHAR);
     subextra(pc.quests, "$noshout");
     unset(pc.pcflags, PC_NOSHOUTING);
     i := dildestroy("no_shouted@commands", pc);
     log("NOSHOUT: " + self.name + " removed the noshout on " +
         pc.name + ".");
     quit;
  }

  time_str := getword(arg);
  type_str := getword(arg);

  /* Default noshout time is 30 real minutes */
  if (time_str == "")
  {
     ns_time := (PULSE_SEC * SECS_PER_REAL_HOUR) / 2;
     time_str := "30";
     type_str := "min";
     goto no_shout;
  }

  ns_time := atoi(time_str);

  if (not(ns_time))
  {
     act("Invalid time period.",A_ALWAYS, self, null, null, TO_CHAR);
     goto syntax;
  }

  if (type_str in "mins")
  {
     ns_time := ns_time * PULSE_SEC * SECS_PER_REAL_MIN;
     goto no_shout;
  }

  else if (type_str in "hours")
  {
     ns_time := ns_time * PULSE_SEC * SECS_PER_REAL_HOUR;
     goto no_shout;
  }

  else goto syntax;

:no_shout:

  set(pc.pcflags, PC_NOSHOUTING);
  act("Noshouting set on $3n.",A_ALWAYS, self, null, pc, TO_CHAR);
  act("You suddenly get a sore throat!",A_ALWAYS, pc, null, null, TO_CHAR);
  dilcopy("no_shouted@commands(" + itoa(ns_time) + ")", pc);
  addextra(pc.quests, {"$noshout"}, self.name + " " + asctime(realtime));
  log("NOSHOUT: " + self.name + " noshouted " + pc.name + " for " +
      time_str + " " + type_str + ".");

  quit;

:syntax:
     act("Syntax: 'Noshout player 1 hour' or 'Noshout player 25 min'." +
         "&nNote time is real time, not mud time.",A_ALWAYS, self, null,
null, TO_CHAR);
     quit;
}
dilend /* revoke */

dilbegin recall aware no_shouted (ns_time : integer);

var
  ticks_so_far : integer;
  hours: integer;
  mins: integer;
  secs: integer;
  td: string;
  tl: string;

code
{
  ticks_so_far := 0;
  heartbeat := (PULSE_SEC * SECS_PER_REAL_MIN) / 3;
  interrupt (SFB_CMD, (command("noshouted") and (self == activator)),
shou);

:re_tick:
  wait(SFB_TICK, TRUE);
  ticks_so_far := ticks_so_far + heartbeat;
  if (ticks_so_far >= ns_time) goto end;
  else goto re_tick;

:end:
  unset(self.pcflags, PC_NOSHOUTING);
  act("Your sore throat clears up.",A_ALWAYS, self, null, null, TO_CHAR);
  subextra(self.quests, "$noshout");
  log("NOSHOUT: " + self.name + "'s noshout has worn off.");
  quit;

:shou:
block;
hours:= 0;mins := 0;td := "";tl := "";
secs:= ticks_so_far / 4;

while (secs >= 3600) {
secs := secs - 3600;
hours := hours + 1;
}
while (secs >= 60) {
secs := secs - 60;
mins := mins + 1;
}

td:= itoa(hours) + " hours, "+itoa(mins)+" minutes, "+itoa(secs)+
 " seconds";

hours:= 0; mins := 0;
secs:= ns_time / 4;

while (secs >= 3600) {
secs := secs - 3600;
hours := hours + 1;
}
while (secs >= 60) {
secs := secs - 60;
mins := mins + 1;
}

tl:= itoa(hours) + " hours, "+itoa(mins)+" minutes, "+itoa(secs)+
 " seconds";

act ("You have "+td+" done off your noshout, out of "+tl+" to do.",
 A_ALWAYS,self,null,null,TO_CHAR);

goto re_tick;

}
dilend /* no_shouted */




dilbegin who_dil ( arg: string );
var
 buff:string;
gld:string;
rc:string;
ln:integer;
u:unitptr;
ply_list:stringlist;
i:integer;
temp:string;
temps:string;
tempp:string;
       path_guild : string;
x:extraptr;
ox:extraptr;
       gex : extraptr;

code
{
u:=ghead();
if (arg=="")
{
arg:="Players:";
temp:="--------";
temps:="player";
tempp:="players";
goto who_all;
}
else if (arg in "newbie")
{
if ("New Player Helper" in self.quests)
 {
 arg:="Newbies:";
 temp:="--------";
 temps:="newbie";
 tempp:="newbies";
 goto who_newbie;
 }
else
 {
 act ("Only the newbie council can check newbies online.",A_ALWAYS,self,null,null,TO_CHAR);
 quit;
 }
}
else if (arg in "guide")
{
arg:="Newbie Helpers:";
temp:="---------------";
temps:="helper";
tempp:="helpers";
goto who_guide;
}
else if (arg in "builder")
{
arg:="Valhalla Builders:";
temp:="------------------";
temps:="builder";
tempp:="builders";
goto who_builder;
}
else if (arg in "clan")
{
arg:="Clan Members:";
temp:="-------------";
temps:="member";
tempp:="members";
goto who_clan;
}
else if (arg in "admin")
{
arg:="Valhalla Admins:";
temp:="----------------";
 temps:="admin";
 tempp:="admins";
goto who_admin;
}

arg:="Players:";
temp:="--------";
temps:="player";
tempp:="players";

:who_all:
while (u.type==UNIT_ST_PC)
{
if (visible(self,u))
{
if (u.level >= OVERSEER_LEVEL)
 gld:="(Admin)";
 else if (u.level>=CREATOR_LEVEL)
  gld:="(Creator)";
 else if (u.level>IMMORTAL_LEVEL)
  gld:="(Immortal)";
  else gld:="";

buff:="&[who_name]"+u.name+"&[default] &[who_title]"+u.title+"&[default]"+gld+"&[default] ";
if (u.minv>0)
 buff:=buff+"&[who_inv][ WIZINV "+itoa(u.minv)+" ]&[default] ";
 else if (isaff(u, ID_INVISIBILITY))
 buff:=buff+"&[who_inv][ INV ]&[who]";
 if ("valhalla builder" in u.quests)
  buff:=buff+" * Builder *&[default]";
 if ("New Player Helper" in u.quests)
  buff:=buff+" * Guide *&[default]";  
buff:=buff+" &n";
addstring (ply_list,buff);
}
u:=u.gnext;
}
goto p_who;
:who_newbie:
while (u.type==UNIT_ST_PC)
{
if ((visible(self,u)) and
(u.level <= 20))
{
if (u.level >= OVERSEER_LEVEL)
 gld:="(Admin)";
 else if (u.level>=CREATOR_LEVEL)
  gld:="(Creator)";
 else if (u.level>IMMORTAL_LEVEL)
  gld:="(Immortal)";
  else gld:="";

buff:="&[who_name]"+u.name+"&[default] &[who_title]"+u.title+"&[default]"+gld+"&[default] ";
if (u.minv>0)
 buff:=buff+"&[who_inv][ WIZINV "+itoa(u.minv)+" ]&[default] ";
 else if (isaff(u, ID_INVISIBILITY))
 buff:=buff+"&[who_inv][ INV ]&[who]";
 if ("valhalla builder" in u.quests)
  buff:=buff+" * Builder *&[default]";
 if ("New Player Helper" in u.quests)
  buff:=buff+" * Guide *&[default]";
buff:=buff+" &n";
addstring (ply_list,buff);
}
u:=u.gnext;
}
goto p_who;
:who_admin:
while (u.type==UNIT_ST_PC)
{
if ((visible(self,u)) and
(u.level >= 253))
{
if (u.level >= OVERSEER_LEVEL)
 gld:="(Admin)";
 else if (u.level>=CREATOR_LEVEL)
  gld:="(Creator)";
 else if (u.level>IMMORTAL_LEVEL)
  gld:="(Immortal)";
  else gld:="";

buff:="&[who_name]"+u.name+"&[default] &[who_title]"+u.title+"&[default]"+gld+"&[default] ";
if (u.minv>0)
 buff:=buff+"&[who_inv][ WIZINV "+itoa(u.minv)+" ]&[default] ";
 else if (isaff(u, ID_INVISIBILITY))
 buff:=buff+"&[who_inv][ INV ]&[who]";
 if ("valhalla builder" in u.quests)
  buff:=buff+" * Builder *&[default]";
 if ("New Player Helper" in u.quests)
  buff:=buff+" * Guide *&[default]";

buff:=buff+" &n";
addstring (ply_list,buff);
}
u:=u.gnext;
}
goto p_who;
:who_guide:
while (u.type==UNIT_ST_PC)
{
if ((visible(self,u)) and
("New Player Helper" in u.quests))
{
if (u.level >= OVERSEER_LEVEL)
 gld:="(Admin)";
 else if (u.level>=CREATOR_LEVEL)
  gld:="(Creator)";
 else if (u.level>IMMORTAL_LEVEL)
  gld:="(Immortal)";
  else gld:="";

buff:="&[who_name]"+u.name+"&[default] &[who_title]"+u.title+"&[default]"+gld+"&[default] ";
if (u.minv>0)
 buff:=buff+"&[who_inv][ WIZINV "+itoa(u.minv)+" ]&[default] ";
 else if (isaff(u, ID_INVISIBILITY))
 buff:=buff+"&[who_inv][ INV ]&[who]";
 if ("New Player Helper" in u.quests)
  buff:=buff+" * Guide *&[default]";

buff:=buff+" &n";
addstring (ply_list,buff);
}
u:=u.gnext;
}
:who_builder:
while (u.type==UNIT_ST_PC)
{
if ((visible(self,u)) and
("valhalla builder" in u.quests))
{
if (u.level >= OVERSEER_LEVEL)
 gld:="(Admin)";
 else if (u.level>=CREATOR_LEVEL)
  gld:="(Creator)";
 else if (u.level>IMMORTAL_LEVEL)
  gld:="(Immortal)";
  else gld:="";

buff:="&[who_name]"+u.name+"&[default] &[who_title]"+u.title+"&[default]"+gld+"&[default] ";
if (u.minv>0)
 buff:=buff+"&[who_inv][ WIZINV "+itoa(u.minv)+" ]&[default] ";
 else if (isaff(u, ID_INVISIBILITY))
 buff:=buff+"&[who_inv][ INV ]&[who]";
 if ("valhalla builder" in u.quests)
  buff:=buff+" * Builder *&[default]";
buff:=buff+" &n";
addstring (ply_list,buff);
}
u:=u.gnext;
}
:who_clan:
while (u.type==UNIT_ST_PC)
{
x:=CLAN_NAME in self.extra;
if (x==null)
{
u:=u.gnext;
continue;
}
ox:=CLAN_NAME in u.extra;
if (ox==null)
{
u:=u.gnext;
continue;
}
if (ox.descr!=x.descr)
{
u:=u.gnext;
continue;
}
if (visible(self,u))
{
if (u.level >= OVERSEER_LEVEL)
 gld:="(Admin)";
 else if (u.level>=CREATOR_LEVEL)
  gld:="(Creator)";
 else if (u.level>IMMORTAL_LEVEL)
  gld:="(Immortal)";
  else gld:="";

buff:="&[who_name]"+u.name+"&[default] &[who_title]"+u.title+"&[default]"+gld+"&[default] ";
if (u.minv>0)
 buff:=buff+"&[who_inv][ WIZINV "+itoa(u.minv)+" ]&[default] ";
 else if (isaff(u, ID_INVISIBILITY))
 buff:=buff+"&[who_inv][ INV ]&[who]";
 if ("valhalla builder" in u.quests)
  buff:=buff+" * Builder *&[default]";
 if ("New Player Helper" in u.quests)
 buff:=buff+" * Guide *&[default]";
buff:=buff+" &n";
addstring (ply_list,buff);
}
u:=u.gnext;
}
:p_who:
buff:="";
ln:=length(ply_list);
buff:="&[who]"+arg+"&[default]&n";
buff:=buff+"&[who]"+temp+"&[default]&n";
if (ln<=0)
buff:=buff+"None&n";
else
{
i:=0;
while (i {
buff:=buff+ply_list.[i];
i:=i+1;
}
}
if (ln==1)
buff:=buff+"&[who]There is " +itoa(ln)+ " "+temps+" visible to you.&[default]";
else
buff:=buff+"&[who]There are " +itoa(ln)+ " "+tempp+" visible to you.&[default]";;


pagestring(buff,self);
quit;
}
dilend


dilbegin string sizestring(cm : integer);
var
  ftn : integer;
  fts : string;
  inn : integer;
  ins : string;
code
{
  /* One inch equals 2,54 cm. There are 12 inches (30.48 cm) to a foot */
  ftn := cm / 30;
  inn := (10*(cm % 30))/25;
  if (ftn == 1)
    fts := "one foot";
  else if (ftn > 1)
    fts := itoa(ftn)+" feet";
  else
    fts := "";

  if (inn == 1)
    ins := "one inch";
  else if (inn > 1)
    ins := itoa(inn)+" inches";
  else
    ins := "";

  if (fts != "")
  {
     if (ins != "")
       fts := fts + " and ";
  }
  else
  {
     if (inn < 1)
ins := "less than an inch";
  }

  return (fts + ins);
}
dilend
dilbegin string weightstring(p : integer);
var
  s : string;
code
{
  if (p == 1)
    s := "one pound";
  else if (p > 1)
    s := itoa(p)+" pounds";
  else
    s := "less than a pound";

  return (s);
}
dilend




dilbegin affect(arg:string);
var
spl_aff:stringlist;
i:integer;
ln:integer;
code
{
  if (isaff(self, ID_BLESS))
addstring(spl_aff,"Bless&n");
if (isaff(self, ID_DETECT_ALIGN))
addstring(spl_aff,"Detect Alignment&n");
if (isaff(self, ID_DETECT_INVISIBLE))
addstring(spl_aff,"Detect Invisibility&n");
if (isaff(self, ID_DETECT_MAGIC))
addstring(spl_aff,"Detect Magic&n");
if (isaff(self, ID_DETECT_POISON))
addstring(spl_aff,"Detect Poison&n");
if (isaff(self, ID_DETECT_UNDEAD))
addstring(spl_aff,"Detect Undead&n");
if (isaff(self, ID_DETECT_CURSE))
addstring(spl_aff,"Detect Curse&n");
if (isaff(self, ID_DETECT_LIFE))
addstring(spl_aff,"Detect Life&n");
if (isaff(self, ID_INVISIBILITY))
addstring(spl_aff,"Invisibility&n");
if (isaff(self, ID_HOLD))
addstring(spl_aff,"Hold&n");
if (isaff(self, ID_MAGIC_LIGHT))
addstring(spl_aff,"Magic Light&n");
if (isaff(self, ID_MAGIC_DARK))
addstring(spl_aff,"Magic Dark&n");
if (isaff(self, ID_SPL_RAISE_MAG))
addstring(spl_aff,"Raise Magic&n");
if (isaff(self, ID_SPL_RAISE_DIV))
addstring(spl_aff,"Raise Divine&n");
if (isaff(self, ID_SPL_RAISE_STR))
addstring(spl_aff,"Raise Strength&n");
if (isaff(self, ID_SPL_RAISE_DEX))
addstring(spl_aff,"Raise Dexterity&n");
if (isaff(self, ID_SPL_RAISE_CON))
addstring(spl_aff,"Raise Constitution&n");
if (isaff(self, ID_SPL_RAISE_CHA))
addstring(spl_aff,"Raise Charisma&n");
if (isaff(self, ID_SPL_RAISE_BRA))
addstring(spl_aff,"Raise Brain&n");
if (isaff(self, ID_SPL_RAISE_HPP))
addstring(spl_aff,"Raise Hit Points&n");
if (isaff(self, ID_SPL_RAISE_DIVINE))
addstring(spl_aff,"Raise Divine Sphere&n");
if (isaff(self, ID_SPL_RAISE_SUMMONING))
addstring(spl_aff,"Raise Summoning Sphere&n");
if (isaff(self, ID_SPL_RAISE_MIND))
addstring(spl_aff,"Raise Mind Sphere&n");
if (isaff(self, ID_SPL_RAISE_HEAT))
addstring(spl_aff,"Raise Heat Sphere&n");
if (isaff(self, ID_SPL_RAISE_COLD))
addstring(spl_aff,"Raise Cold Sphere&n");
if (isaff(self, ID_SPL_RAISE_CELL))
addstring(spl_aff,"Raise Electricity Sphere&n");
if (isaff(self, ID_SPL_RAISE_INTERNAL))
addstring(spl_aff,"Raise Poison Sphere&n");
if (isaff(self, ID_SPL_RAISE_EXTERNAL))
addstring(spl_aff,"Raise Acid Sphere&n");
if (isaff(self, ID_POISON))
addstring(spl_aff,"Poison&n");
if (isaff(self, ID_SPEED))
addstring(spl_aff,"Magic Speed&n");
if (isaff(self, ID_LIFE_PROTECTION))
       addstring(spl_aff,"Life Protection&n");
if (isaff(self, ID_SANCTUARY))
       addstring(spl_aff,"Sanctuary&n");
if (isaff(self, ID_PROT_EVIL))
       addstring(spl_aff,"Protection from Evil&n");
if (isaff(self, ID_PROT_GOOD))
       addstring(spl_aff,"Protection from Good&n");
if (isaff(self, ID_BLIND_CHAR))
       addstring(spl_aff,"Blind&n");
if (isaff(self, ID_FEAR))
       addstring(spl_aff,"Fear&n");
if (isaff(self, ID_SLEEP))
       addstring(spl_aff,"Sleep&n");
if (isaff(self, ID_CURSE))
       addstring(spl_aff,"Curse&n");
if (isaff(self, ID_INSANITY))
       addstring(spl_aff,"Madness&n");
if (isaff(self, ID_SUSTAIN))
       addstring(spl_aff,"Sustained from Hunger&n");
if (isaff(self, ID_PLAGUE))
       addstring(spl_aff,"Plague&n");
if (isaff(self, ID_ENERGY_DRAIN))
       addstring(spl_aff,"Energy Drain&n");
if (isaff(self, ID_CONFUSION))
       addstring(spl_aff,"Confusion&n");
if (isaff(self, ID_NATURAL_ARMOUR))
       addstring(spl_aff,"Magical Natural Armor&n");
if (isaff(self, ID_FOCUS))
       addstring(spl_aff,"Focus&n");
ln:=length (spl_aff);

if (ln<1)
{
act ("You are not affected by magic.",
 A_ALWAYS,self,null,null,TO_CHAR);
 goto hide_sneak ;
 }
i:=0;
act ("You are affected by:&n",
A_ALWAYS,self,null,null,TO_CHAR);

while (i {
sendtext (spl_aff.[i],self);
i:=i+1;
}

:hide_sneak:

if ((isset(self.charflags, CHAR_HIDE)) and (isset(self.charflags,
CHAR_SNEAK))){
sendtext ("&nYou are hiding and sneaking.&n",self);}
else if (isset(self.charflags, CHAR_HIDE)){
sendtext ("&nYou are hiding.&n",self);}
else if (isset(self.charflags, CHAR_SNEAK)){
sendtext ("&nYou are sneaking.&n",self);}
quit;
}
dilend


dilbegin report(arg:string);
var
u: unitptr;
code
{
if(self.type!=UNIT_ST_PC)
quit;

if(arg==""){
 act(self.name+" reports: "+itoa(self.hp)+"/"+itoa(self.max_hp)+
   " Hitpoints, "+itoa(self.endurance)+"/"+itoa(self.max_endurance)+
   " Endurance, "+itoa(self.mana)+"/"+itoa(self.max_mana)+" Mana",
   A_SOMEONE, self, null, null, TO_REST);
 act("You report: "+itoa(self.hp)+"/"+itoa(self.max_hp)+
   " Hitpoints, "+itoa(self.endurance)+"/"+itoa(self.max_endurance)+
   " Endurance, "+itoa(self.mana)+"/"+itoa(self.max_mana)+" Mana",
   A_ALWAYS, self, null, null, TO_CHAR);
}
else if(arg=="group") {
foreach (UNIT_ST_PC, u)
{
if(u==self)
{
 act("You report: "+itoa(self.hp)+"/"+itoa(self.max_hp)+
   " Hitpoints, "+itoa(self.endurance)+"/"+itoa(self.max_endurance)+
   " Endurance, "+itoa(self.mana)+"/"+itoa(self.max_mana)+" Mana"+
   " to the group.", A_ALWAYS, self, null, null, TO_CHAR);
}
else if(u.master==self)
{
 act("$1n reports: "+itoa(self.hp)+"/"+itoa(self.max_hp)+
   " Hitpoints, "+itoa(self.endurance)+"/"+itoa(self.max_endurance)+
   " Endurance, "+itoa(self.mana)+"/"+itoa(self.max_mana)+" Mana"+
   " to the group.", A_SOMEONE, self, null, u, TO_VICT);
}
else if(u==self.master) {
 act("$1n reports: "+itoa(self.hp)+"/"+itoa(self.max_hp)+
   " Hitpoints, "+itoa(self.endurance)+"/"+itoa(self.max_endurance)+
   " Endurance, "+itoa(self.mana)+"/"+itoa(self.max_mana)+" Mana"+
   " to the group.", A_SOMEONE, self, null, u, TO_VICT);
}
else if(u.master==self.master)
{
 act("$1n reports: "+itoa(self.hp)+"/"+itoa(self.max_hp)+
   " Hitpoints, "+itoa(self.endurance)+"/"+itoa(self.max_endurance)+
   " Endurance, "+itoa(self.mana)+"/"+itoa(self.max_mana)+" Mana"+
   " to the group.", A_SOMEONE, self, null, u, TO_VICT);
}
}
}
else
{
u:=findunit(self, arg, FIND_UNIT_SURRO, null);
if(u==null)
{
  act("That person is not here.", A_ALWAYS, self, null, null, TO_CHAR);
}
else
{
 act("$1n reports: "+itoa(self.hp)+"/"+itoa(self.max_hp)+
   " Hitpoints, "+itoa(self.endurance)+"/"+itoa(self.max_endurance)+
   " Endurance, "+itoa(self.mana)+"/"+itoa(self.max_mana)+" Mana"+
   " to you.", A_SOMEONE, self, null, u, TO_VICT);
 act("You report: "+itoa(self.hp)+"/"+itoa(self.max_hp)+
   " Hitpoints, "+itoa(self.endurance)+"/"+itoa(self.max_endurance)+
   " Endurance, "+itoa(self.mana)+"/"+itoa(self.max_mana)+" Mana"+
   " to $3n.", A_ALWAYS, self, null, u, TO_CHAR);
}
}
 quit;
}
dilend

dilbegin transfer(arg : string);
var
dest_s: unitptr;
dest_t: unitptr;
tgt: unitptr;
str: string;

code
{

if(arg == "")
 {
  act("&n&c+wUsage &c+n: &cmtransfer &c+c<&ccperson&c+c>
       &cmtransfer &c+c<&ccperson&c+c> &c+c<&ccplace&c+c>
       &cmtransfer &c+c<&ccperson&c+c> <&ccroom&c+c@&cczone&c+c>
       &cmtransfer &c+c<&ccall&c+c> &cwUse with care!&[default]",
      A_ALWAYS, self, null, null, TO_CHAR);
  quit;
 }

 if((arg == "all") or (arg == "all now"))
 goto transall;

tgt := findunit(self,arg,FIND_UNIT_GLOBAL,null);

if((tgt == null) or (not(visible(self,tgt))))
 {
  act("No such person found.",A_ALWAYS, self, null, null, TO_CHAR);
  quit;
 }

if(tgt == self)
 {
  act("DOH", A_ALWAYS, self, null, null, TO_CHAR);
  quit;
 }

if(not(tgt.type & (UNIT_ST_PC|UNIT_ST_NPC)))
{
 act("Transfer is for players and mobiles only!",A_ALWAYS, self, null,
null, TO_CHAR);
 quit;
}

if(arg == "") /* lone transfer..ex. transfer domino */
{
 dest_s := self.outside;
 dest_t := tgt.outside;

 if((("$NO_TRANS" in dest_s.extra) or ("NO_TRANS" in dest_t.extra)) and
     (self.level < 250))
 {
  act("Sorry, you are unable to transfer that person.", A_ALWAYS, self,
null, null, TO_CHAR);
  quit;
 }

 if((isset(tgt.pcflags,PC_SPIRIT)) and (self.level < 250))
 {
  act("You are unable to transfer dead persons.",A_ALWAYS, self, null,
null, TO_CHAR);
  quit;
 }

act("Ok.", A_ALWAYS, self, null, null, TO_CHAR);
act("$1n disappears in a mushroom cloud.", A_SOMEONE, tgt, null, null,
TO_REST);
act("$3n has transfered you!",A_SOMEONE, tgt, null, self, TO_CHAR);
link(tgt,dest_s);
exec("look", tgt);
act("$1n appears in a puff of smoke.",A_SOMEONE, tgt, null, null, TO_REST);
quit;
}
else if("@" in arg) /* transfer domino temple@udgaard */
{
 dest_s := findroom(arg);
 if(dest_s == null)
 {
  act("No such room!", A_ALWAYS, self, null, null, TO_CHAR);
  quit;
 }
 dest_t := tgt.outside;

 if(("NO_TRANS" in dest_t.extra) and
     (self.level < 250))
 {
  act("Sorry, you are unable to transfer that person.",A_ALWAYS, self,
null, null, TO_CHAR);
  quit;
 }

 if((isset(tgt.pcflags,PC_SPIRIT)) and (self.level < 250))
 {
  act("You are unable to transfer dead persons",A_ALWAYS, self, null, null,
TO_CHAR);
  quit;
 }

 act("Ok.", A_ALWAYS, self, null, null, TO_CHAR);
 act("$1n disappears in a mushroom cloud.",A_SOMEONE, tgt, null, null,
TO_REST);
 act("$3n has transfered you!",A_SOMEONE, tgt, null, self, TO_CHAR);
 link(tgt,dest_s);
 exec("look", tgt);
 act("$1n appears in a puff of smoke.",A_SOMEONE, tgt, null, null,
TO_REST);
 quit;
}
else /* transfer domino boobar the giantslayer */
 {
  dest_s := findunit(self,arg, FIND_UNIT_WORLD, null);

  if(dest_s == null)
  {
   act("No such place to transfer $3n to!",A_ALWAYS, self, null, tgt,
TO_CHAR);
   quit;
  }

if(dest_s.type != UNIT_ST_ROOM)
 {
  while(dest_s.type != UNIT_ST_ROOM)
    dest_s := dest_s.outside;
 }

 dest_t := tgt.outside;

 if(("NO_TRANS" in dest_t.extra) and
     (self.level < 250))
 {
  act("Sorry, you are unable to transfer that person.", A_ALWAYS, self,
null, null, TO_CHAR);
  quit;
 }

 if((isset(tgt.pcflags,PC_SPIRIT)) and (self.level < 250))
 {
  act("You are unable to transfer dead persons",A_ALWAYS, self, null, null,
TO_CHAR);
  quit;
 }

 act("Ok.", A_ALWAYS, self, null, null, TO_CHAR);
 act("$1n disappears in a mushroom cloud.",A_SOMEONE, tgt, null, null,
TO_REST);
 act("$3n has transfered you!",A_SOMEONE, tgt, null, self, TO_CHAR);
 link(tgt,dest_s);
 exec("look", tgt);
 act("$1n appears in a puff of smoke.", A_SOMEONE, tgt, null, null,
TO_REST);
 quit;
}

:transall:

 if(arg != "all now")
 {
  act("You must type &cctransfer all now&[default].",A_ALWAYS, self, null,
null, TO_CHAR);
  quit;
 }

 act("Ok.", A_ALWAYS, self, null, null, TO_CHAR);

tgt := ghead();

while(tgt.type == UNIT_ST_PC)
{

 if((visible(self,tgt)) and (tgt != self))
 {

  act("$1n disappears in a mushroom cloud.",A_SOMEONE, tgt, null, null,
TO_REST);
  act("$3n has transfered you!",A_SOMEONE, tgt, null, self, TO_CHAR);
  link(tgt, self.outside);
  exec("look", tgt);
  act("$1n appears in a puff of smoke.",A_SOMEONE, tgt, null, null,
TO_REST);
 }

tgt := tgt.gnext;
}


quit;
}
dilend


dilbegin assist(arg : string);
var
  u : unitptr;
  s : string;
code
{
if(arg=="") {
 act("Assist who??",A_SOMEONE,self,null,null,TO_CHAR);
 quit; }
u:=findunit(self,arg,FIND_UNIT_SURRO,null);
secure(u,losthim);
if(u==null) {
 act("No such person by that name!.",A_SOMEONE,self,null,null,TO_CHAR);
 quit; }
if(u==self) {
 act("Assist yourself?  Your in pretty bad shape if your the only one who
can help you.",A_SOMEONE,self,null,null,TO_CHAR);
 quit; }
if(self.fighting) {
 act("No way! You are too busy fighting for your
life!",A_ALWAYS,self,null,null,TO_CHAR);
 quit; }
if(u.fighting==null) {
 act("Assist $3n? $3e isn't fighting anything.",
     A_SOMEONE,self,null,u,TO_CHAR);
 quit; }
if((self.type==UNIT_ST_PC) and (u.fighting.type==UNIT_ST_PC)) {
 if(not(isset(u.fighting.pcflags,PC_PK_RELAXED))) {
   act("You cannot do this until $3n has signed the book of blood.",
       A_SOMEONE,self,null,u.fighting,TO_CHAR);
   quit; }
 if(not(isset(self.pcflags,PC_PK_RELAXED))) {
   act("You are not allowed to do this until you sign the book of blood.",
       A_ALWAYS,self,null,u.fighting,TO_CHAR);
   quit; } }
act("You bravely come to $3n's assistance.",
A_SOMEONE,self,null,u,TO_CHAR);
act("$1n bravely comes to your assistance.",
A_SOMEONE,self,null,u,TO_VICT);
act("$1n bravely comes to $3n's assistance.",
A_SOMEONE,self,null,u,TO_NOTVICT);
set_fighting(self,u.fighting);

:losthim:
quit;
}
dilend

/*Quaff dil
Made by Mesmer for the Realms Of The Past MUD
realms.pdt.net 4242
*/

dilbegin quaff_dil(arg : string);
var
potion: unitptr;
n: integer;

code
{

if(arg == "")
{
act("What do you want to quaff?",A_ALWAYS, self, null, null, TO_CHAR);
quit;
}

potion := findunit(self,arg,FIND_UNIT_IN_ME,null);

if(potion == null)
{
act("You do not have that item.",A_ALWAYS, self, null, null, TO_CHAR);
quit;
}

if(potion.objecttype != ITEM_POTION)
{
act("You can only quaff potions.",A_ALWAYS, self, null, null, TO_CHAR);
quit;
}

potion.spells[SPL_ALL] := potion.value[0];

if(self.position == POSITION_FIGHTING) change_speed(self,PULSE_VIOLENCE*2);

act("You quaff $2t which dissolves.", A_ALWAYS, self, potion.title, null,
TO_CHAR);
act("$1N quaffs $2t.",
     A_SOMEONE, self,potion.title, null, TO_REST);
n := cast_spell(potion.value[1],self,potion,self,"");
n := cast_spell(potion.value[2],self,potion,self,"");
n := cast_spell(potion.value[3],self,potion,self,"");
destroy(potion);
quit;

}
dilend


dilbegin donate(arg:string);
var
clan:integer;
d_rooms:stringlist;
room_idx:string;
room:       unitptr;
item:       unitptr;
num:       integer;
i:integer;
here:unitptr;
x:extraptr;
amount:integer;
check:unitptr;
code
{
clan:=0;

:start:
d_rooms:={"udonate@midgaard","mdonate@midgaard","ndonate@nymgaard"};
room_idx:=self.outside.nameidx+"@"+self.outside.zoneidx;
if (room_idx in d_rooms)
 {
 act("You may not donate while in a donations room!",A_ALWAYS, self, null,
null, TO_CHAR);
   quit;
 }

item:= findunit(self, arg, FIND_UNIT_INVEN, null);
if (not(item.type == UNIT_ST_OBJ))
 {
 act("You do not have anything like that in your inventory.",A_ALWAYS,
self, null, null, TO_CHAR);
   quit;
 }
 if ("midgaard" in arg)
 room := findroom("mdonate@midgaard");
 else if ("nymgaard" in arg)
 room := findroom("ndonate@nymgaard");
else
 room := findroom("udonate@udgaard");
if (clan!=1)
{
num := rnd(1, 200);
if (num > 195)
  {
  if (item.cost >= 75000)
    {
    experience(+75, self);
    act("You are rewarded 75 experience for your act.",A_ALWAYS, self,
null, null, TO_CHAR);
    }else if (item.cost >= 50000)
      {
      experience(+35, self);
      act("You are rewarded 35 experience for your act.",A_ALWAYS, self,
null, null, TO_CHAR);
      }
    }

i:=0;
here:=room.inside;
while ((here!=null) and (i<5))
  {
  if (here.idx==item.idx)i:=i+1;
  here:=here.next;
  }

  act("You donate $2n to those in need.",A_ALWAYS, self, item, null,
TO_CHAR);
  act("$1n donates $2n to those in need.",A_SOMEONE, self, item, null,
TO_REST);

  if (i<5)
    {
  item.cost := 0;
  link(item, room);
  act("A Glowing red portal appears hovering in the air, $2n"+
    " emerges from it and drops to the floor.",A_ALWAYS, room.inside, item,
null, TO_ALL);
    }
    else
     destroy (item);
   }
 quit;
}
dilend

/* The cuff skill.

  The skill is implemented on the hand cuffs themselves.

*/

dilbegin cuff(arg : string);
code
{
  act("You seem to be missing a pair of hand cuffs.",A_ALWAYS, self, null,
null, TO_CHAR);
  quit;
}
dilend


dilbegin evaluate(arg : string);

external
  string sizestring@commands(cm : integer);
  string weightstring@commands(cm : integer);

var
  u : unitptr;
  s : string;
  degrade : integer;
code
{
  if (arg == "")
  {
     act("What do you wish to evaluate?",A_SOMEONE, self, null,
null,TO_CHAR);
     quit;
  }

  u := findunit(self, arg, FIND_UNIT_HERE, null);

  if ((u == null) or not visible(self, u))
  {
     act("No such thing by that name!", A_SOMEONE, self, null,
null,TO_CHAR);
     quit;
  }

  if (u.type != UNIT_ST_OBJ)
  {
     act("You can't evaluate $3m.",A_SOMEONE, self, null, u, TO_CHAR);
     quit;
  }

  s := weightstring@commands(u.weight);
  act("The $3N weighs "+s+".",A_SOMEONE, self, null, u, TO_CHAR);

  if ((u.manipulate & (MANIPULATE_WEAR_FINGER | MANIPULATE_WEAR_NECK  |
  MANIPULATE_WEAR_BODY   | MANIPULATE_WEAR_HEAD  |
  MANIPULATE_WEAR_LEGS   | MANIPULATE_WEAR_FEET  |
  MANIPULATE_WEAR_HANDS  | MANIPULATE_WEAR_ARMS  |
  MANIPULATE_WEAR_SHIELD | MANIPULATE_WEAR_ABOUT |
  MANIPULATE_WEAR_WAIST  | MANIPULATE_WEAR_WRIST |
  MANIPULATE_WIELD       | MANIPULATE_WEAR_EAR   |
  MANIPULATE_WEAR_BACK   | MANIPULATE_WEAR_CHEST |
  MANIPULATE_WEAR_ANKLE)) or
      (u.objecttype == ITEM_WEAPON))
  {
     s := sizestring@commands(u.height);
     act("$3e has been made to fit a person of "+s+".",A_SOMEONE, self,
null, u, TO_CHAR);
  }

  if ((u.max_hp > 0) and (u.hp > 0))
  {
     degrade := (100*u.hp) / u.max_hp;

     if (degrade >= 90)
s := "in an excellent condition.";
     else if (degrade >= 75)
s := "in a good condition.";
     else if (degrade >= 50)
s := "worn.";
     else if (degrade >= 30)
s := "in a poor condition";
     else if (degrade >= 10)
s := "in a horrible condition.";
     else
s := "nearly broken.";
  }
  else if (u.hp == -1) // indestructible (able?)
    s := "in an excellent condition.";
  else
    s := "broken.";

  act("The $3N appears to be "+s,
      A_ALWAYS, self, null, u, TO_CHAR);

  if (u.objecttype == ITEM_ARMOR)
    on u.value[0] goto clothes,leather,leather,metal,metal;
  else if (u.objecttype == ITEM_SHIELD)
    goto metal;
  else if (u.objecttype == ITEM_WEAPON)
    goto metal;
  else if (u.objecttype == ITEM_WORN)
    goto clothes;
  else
  {
     if ((u.manipulate & (MANIPULATE_WEAR_FINGER | MANIPULATE_WEAR_NECK  |
       MANIPULATE_WEAR_BODY   | MANIPULATE_WEAR_HEAD  |
       MANIPULATE_WEAR_LEGS   | MANIPULATE_WEAR_FEET  |
       MANIPULATE_WEAR_HANDS  | MANIPULATE_WEAR_ARMS  |
       MANIPULATE_WEAR_SHIELD | MANIPULATE_WEAR_ABOUT |
       MANIPULATE_WEAR_WAIST  | MANIPULATE_WEAR_WRIST |
       MANIPULATE_WIELD       | MANIPULATE_WEAR_EAR   |
       MANIPULATE_WEAR_BACK   | MANIPULATE_WEAR_CHEST |
       MANIPULATE_WEAR_ANKLE)) == 0)
     {
        goto nextstep;
     }
     goto metal; /* What else can one do? */
  }
  goto nextstep;

  :clothes:
  act ("Refitting the size of it, requires tailoring
skills.",A_ALWAYS,self,null, null,TO_CHAR);
  goto nextstep;

  :leather:
  act ("Refitting the size of it, requires leahter working
skills.",A_ALWAYS,self,null, null,TO_CHAR);
  goto nextstep;

  :metal:
  act ("Refitting the size of it, requires metal
skills.",A_ALWAYS,self,null, null,TO_CHAR);
  goto nextstep;

  :nextstep:

  /* Eventually add

     Material Lore
     Appraisal
     Spell Lore
   */

  quit;
}
dilend

dilbegin ditch(arg : string);
var
  u : unitptr;
  s : string;
code
{
  if (arg == "")
  {
     act("They are not here.",A_SOMEONE, self, null, null,TO_CHAR);
     quit;
  }

  u := findunit(self, arg, FIND_UNIT_WORLD, null);
  secure(u,losthim);

  if ((u == null) or not visible(self, u))
  {
     act("No such person by that name!.",A_SOMEONE, self, null, null,
TO_CHAR);
     quit;
  }
if (not (visible(self,u)))
  {
     act("No such person by that name!.",A_SOMEONE, self, null, null,
TO_CHAR);
     quit;
  }
  if ((u.master == self) and  (u.type == UNIT_ST_NPC))
  {
     act("$1n tries to ditch $3n but fails miserably.", A_SOMEONE, self,
null, u, TO_NOTVICT);
     act("You can not ditch $3n.",A_SOMEONE, self,null,u, TO_CHAR);
     quit;
  }
  if ((u.master == self) and  (u.type == UNIT_ST_PC))
  {
     act("$1n has ditched $3n.", A_SOMEONE, self, null, u, TO_NOTVICT);
     act("$1n has ditched you.",A_SOMEONE,self, null,u, TO_VICT);
     act("You have ditched $3n.",A_SOMEONE, self,null,u, TO_CHAR);
     exec("follow self",u);
     quit;
  }
  else
  {
     act("$2n is not following you",A_SOMEONE, self, u, null, TO_CHAR);
     quit;
  }

  :losthim:
  quit;
}
dilend


%rooms


                                  command_room
title "The Commands Room"
descr
"Token room."
movement SECT_INSIDE
flags {UNIT_FL_NO_WEATHER}
ALWAYS_LIGHT
end

%end