mud/help/
mud/items/
mud/map/
mud/monsters/
mud/players/
#the NorthlandsMUD a perl based mud. Please enjoy and share this great software with
#anyone who wants it. 
#Copyright (C) 2000  Peter Smith creator@operamail.com
#This program is free software; you can redistribute it and/or
#modify it under the terms of the GNU General Public License
#as published by the Free Software Foundation; either version 2
#of the License, or (at your option) any later version.
#
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
#GNU General Public License for more details.

#You should have received a copy of the GNU General Public License
#along with this program; if not, write to the Free Software
#Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.


sub talk{
		shift (@input);
		say("$user{$client}{name} says, \"@input\"");
		}
sub stats {
		$outbuffer{$client}.="You are $user{$client}{name}, a $elements[$user{$client}{element}] Elemental\r\n";
		$outbuffer{$client}.="Strength: $user{$client}{str}\r\nAgility: $user{$client}{agi}\r\nRelfex: $user{$client}{agi}\r\nConstitution:$user{$client}{con}\r\n";
		$outbuffer{$client}.="Character Development Points: $user{$client}{cp}";
		$outbuffer{$client}.="\r\n$prompt";
		}
sub experience {
		foreach $b (keys %{$user{$client}{exp}}){
			$outbuffer{$client}.="\u$b Skills:\r\n";
			foreach $a (keys %{$user{$client}{exp}{$b}}){
				if ($a eq "total"){
					next;
					}
				my $z;
				$z=$user{$client}{exp}{$b}{$a}{ranks};
				$outbuffer{$client}.="\u$a:  $z  -  ";
				#print "\nc=$user{$client}{exp}{$b}{$a}{expneeded}\na=$a\nb=$b\n";
				unless (defined($user{$client}{exp}{$b}{$a}{expcur}) and defined($user{$client}{exp}{$b}{$a}{expneeded})){
					print "can't do that\n";
					$outbuffer{$client}.="\r\n$prompt";
					return 1;
					}
				$z=int(($user{$client}{exp}{$b}{$a}{expcur}/$user{$client}{exp}{$b}{$a}{expneeded})*100);
				$outbuffer{$client}.="$z% ";
				my $maxpool=$user{$client}{disc}*100;
			
				if ($user{$client}{exp}{$b}{$a}{pool}){
					if ($user{$client}{exp}{$b}{$a}{pool}>=$maxpool){
						$z="locked";
						}
					else{
						$z="learning";
						if ($user{$client}{exp}{$b}{$a}{pool}>=600){
							$z="considering";
							}
						if ($user{$client}{exp}{$b}{$a}{pool}>=900){
							$z="thinking";
							}
						if ($user{$client}{exp}{$b}{$a}{pool}>=1200){
							$z="pondering";
							}
						if ($user{$client}{exp}{$b}{$a}{pool}>=1500){
							$z="contemplating";
							}
						if ($user{$client}{exp}{$b}{$a}{pool}>=1800){
							$z="reasoning";
							}
						if ($user{$client}{exp}{$b}{$a}{pool}>=2100){
							$z="reflecting";
							}
						if ($user{$client}{exp}{$b}{$a}{pool}>=2400){
							$z="speculating";
							}
						if ($user{$client}{exp}{$b}{$a}{pool}>=2700){
							$z="mastering";
							}
						}
					}
				else{
					$z="clear";
					}
				$outbuffer{$client}.=ucfirst $z."\r\n";
				}
			}
		
		$outbuffer{$client}.="$prompt";
		}	
sub lookcommand {
		if (@input==1){
			look();
			return 1;
			}
		if (@input==3){
			shift @input;
			}
		elsif (@input==2){
			$input[0]="at";
			}
		else {
			$outbuffer{$clinet}.="can't go deep yet\r\n$prompt";
			return;
			}
		my $a;
		my $location;
		print "finding $input[1] in $user{$client}{room}\r\n";
		if ($a=locateitem($user{$client}{room},$input[1])){
			
			if ($input[0] ne "at"){
				$location="$input[0]"."desc";	
				}
			else {
				$location="desc";
				}	
			if ($item{$a}{$location}){
				$outbuffer{$client}.="$item{$a}{$location}\r\n$prompt";
				}
			else {
				$outbuffer{$client}.="Can't look there\r\n$prompt";
				}
			return 1;
			}
		foreach $a (keys %{$room[$user{$client}{room}]{in}}){
				#print "$a\n";
				if ($user{$a}{name}=~/$input[1]/i){
					$outbuffer{$client}.="$user{$a}{desc}\r\n$prompt";
					return 1;
					}
				}
		if ($a=locateitemhands($input[1])){
			$outbuffer{$client}.="$item{$a}{desc}\r\n$prompt";
			return 1;
			}
		if ($a=locateitembody($input[1])){
			$outbuffer{$client}.="$item{$a}{desc}\r\n$prompt";
			return 1;
			}
		$outbuffer{$client}.="I couldn't find what you were refering too, be sure to specifiy, look at/in/on/under/behind etc.\r\n$prompt";	
		}
sub locateroomplayer {
my $string=shift;
foreach $a (keys %{$room[$user{$client}{room}]{in}}){
	if ($user{$a}{name}=~/$string/i){
		print "found it\n";
		return $a;
		}
	}
print "a=$string";
return 0;		
}
sub unhide {
		if (&roundcheck) {
			return 0;
			}
		unless ($user{$client}{hiding} eq "yes"){
			$outbuffer{$client}.="You aren't hiding\r\n$prompt";
			return 1;
			}
		$outbuffer{$client}.="You come out of hiding\r\n$prompt";
		$user{$client}{hiding}=undef;
		}
sub hide {
		if (&roundcheck) {
			return 0;
			}
		if (defined($user{$client}{hiding})){
			$outbuffer{$client}.="You are already hiding\r\n$prompt";
			return 1;
			}
		unless ($room[$user{$client}{room}]{hidedifficulty}){
			$outbuffer{$client}.="you can't hide here.\r\n$prompt";
			return 1;
			}
		if (defined($user{$client}{exp}{streetsmarts}{hiding})){
		#print "AAAAAAAAAAAAAAAAAAA\n";
			if (rand($room[$user{$client}{room}]{hidedifficulty})<$user{$client}{exp}{streetsmarts}{hiding}{ranks}){
				$outbuffer{$client}.="You slip into the shadows stealthily\r\nIt took 5 seconds\r\n$prompt";
				$user{$client}{round}+=5;
				$user{$client}{hiding}="yes";
				my $e=(($room[$user{$client}{room}]{hidedifficulty}-($user{$client}{exp}{streetsmarts}{hiding}{ranks}))*20);			
				if ($e<=0){
					$outbuffer{$client}.="You didn't find any challenge in that at all\r\n$prompt";
					#return 1;
					}
				else {
					addexp("hiding","streetsmarts",$e);
					
#					$outbuffer{$client}.="adding $e experience to hiding $room[$user{$client}{room}]{hidedifficulty}*2 $user{$client}{exp}{streetsmarts}{hiding}{ranks} \r\n$prompt";
					}
				return 1;
				}
			else {
				$outbuffer{$client}.="You fail to slip into the shadows\r\n$prompt";
				addexp("hiding","streetsmarts",$room[$user{$client}{room}]{hidedifficulty}-$user{$client}{exp}{streetsmarts}{hiding}{ranks});		
				
				}
			}
		else {
			$outbuffer{$client}.="You fail to slip into the shadows.\r\n$prompt";
			addexp("hiding","streetsmarts",$room[$user{$client}{room}]{hidedifficulty}*2);
#			$user{$client}{exp}{streetsmarts}{hiding}{ranks}=5;
			}
		}
sub north {
		if ($room[$user{$client}{room}]{exits}{North}){
			move($room[$user{$client}{room}]{exits}{North},"$user{$client}{name} walks North","$user{$client}{name} walks in");
			}
		else {
			$outbuffer{$client}.="You can't go that way\r\n$prompt";
			}	
		}
sub south {
		if ($room[$user{$client}{room}]{exits}{South}){
			move($room[$user{$client}{room}]{exits}{South},"$user{$client}{name} walks South","$user{$client}{name} walks in");
			}
		else {
			$outbuffer{$client}.="You can't go that way\r\n$prompt";
			}	
		}
sub east {
		if ($room[$user{$client}{room}]{exits}{East}){
			move($room[$user{$client}{room}]{exits}{East},"$user{$client}{name} walks East","$user{$client}{name} walks in");
			}
		else {
			$outbuffer{$client}.="You can't go that way\r\n$prompt";
			}	
		}
sub west {
		if ($room[$user{$client}{room}]{exits}{West}){
			move($room[$user{$client}{room}]{exits}{West},"$user{$client}{name} walks West","$user{$client}{name} walks in");
			}
		else {
			$outbuffer{$client}.="You can't go that way\r\n$prompt";
			}	
		}
sub ne {
		if ($room[$user{$client}{room}]{exits}{NorthEast}){
			move($room[$user{$client}{room}]{exits}{NorthEast},"$user{$client}{name} walks North-East","$user{$client}{name} walks in");
			}
		else {
			$outbuffer{$client}.="You can't go that way\r\n$prompt";
			}	
		}
sub se {
		if ($room[$user{$client}{room}]{exits}{SouthEast}){
			move($room[$user{$client}{room}]{exits}{SouthEast},"$user{$client}{name} walks South-East","$user{$client}{name} walks in");
			}
		else {
			$outbuffer{$client}.="You can't go that way\r\n$prompt";
			}	
		}
sub nw {
		if ($room[$user{$client}{room}]{exits}{NorthWest}){
			move($room[$user{$client}{room}]{exits}{NorthWest},"$user{$client}{name} walks North-West",
			"$user{$client}{name} walks in");
			}
		else {
			$outbuffer{$client}.="You can't go that way\r\n$prompt";
			}	
		}
sub sw {
		if ($room[$user{$client}{room}]{exits}{SouthWest}){
			move($room[$user{$client}{room}]{exits}{SouthWest},"$user{$client}{name} walks South-West","$user{$client}{name} walks in");
			}
		else {
			$outbuffer{$client}.="You can't go that way\r\n$prompt";
			}	
		}
sub out {
if ($room[$user{$client}{room}]{exits}{out}){
	move($room[$user{$client}{room}]{exits}{out},"$user{$client}{name} walks out","$user{$client}{name} walks in");
	}
else {
	$outbuffer{$client}.="You can't go that way\r\n$prompt";
	}	
}
sub quit {
		$outbuffer{$client}.="Thanx for playing, have fun now.\r\n";
		$client->send($outbuffer{$client},0);
		
		&delete($client);
		return;
		}


sub login {
	$request=ucfirst("\L$request");
	$outbuffer{$client}.= "Hello, $request. ";
	unless (-e "players/$request"){
		$outbuffer{$client}.="I haven't seen you around here before\r\n";
		$outbuffer{$client}.="Ok, your gonna need a password then. please tell me it:";
		$user{$client}{name}=$request;
		$type{$client}="create1";
		}
	else {
		$outbuffer{$client}.= "What's your password?";
		$type{$client} ="password";
		$user{$client}{name}=$request;
		}
	return;
	}
sub create1 {
			$user{$client}{password}="$request";
			$outbuffer{$client}.="Very well, now tell me your element:\r\nValid Choices:\r\n1) Earth\r\n2) Air\r\n3) Water\r\n4) Fire\r\n5) Life\r\n";
			$type{$client}="create2";
			return;
			}
sub create2 {
	$request--;
	unless (defined($elements[$request])){
		$outbuffer{$client}.="Please choose from the list\r\n$prompt";
		return;
		}
	$user{$client}{element}="$request";
	$user{$client}{resistance}{$request}+=.20;

	$outbuffer{$client}.="Very well you are a $elements[$request] elemental then. You may choose one skill for a starting bonus. Choose wisely:\r\n1) Magic\r\n2) Weapons\r\n3) Armor\r\n4) Survival\r\n5) Streetsmarts\r\n6) Character points\r\n";
	$type{$client}="create3";
	return
	}
sub create3 {
	if ($request==1){
		$outbuffer{$client}.="You recieve as your bonus 4 points of Primary Magic";
		$user{$client}{exp}{magic}{primary}{ranks}+=4;
		$user{$client}{exp}{magic}{primary}{expcur}=0;
		$user{$client}{exp}{magic}{primary}{expneeded}=8000;
		$user{$client}{exp}{magic}{primary}{pool}=0;
		$user{$client}{round}=0;
		}
	elsif ($request==2){
				$outbuffer{$client}.="You recieve as your bonus 4 points of General Weapons";
				$user{$client}{exp}{weapons}{general}{ranks}+=4;
				$user{$client}{exp}{weapons}{general}{expcur}=0;
				$user{$client}{exp}{weapons}{general}{expneeded}=8000;
				$user{$client}{exp}{weapons}{general}{pool}=0;
				}
			elsif ($request==3){
				$outbuffer{$client}.="You recieve as your bonus 4 points of Armor";
				$user{$client}{exp}{armor}{general}{ranks}+=4;
				$user{$client}{exp}{armor}{general}{expcur}=0;
				$user{$client}{exp}{armor}{general}{expneeded}=8000;
				$user{$client}{exp}{armor}{general}{pool}=0;
				}
			elsif ($request==4){
				$outbuffer{$client}.="You recieve as your bonus 4 points of survival. 2 to foraging and 2 to skinning.";
				$user{$client}{exp}{survival}{foraging}{ranks}+=2;
				$user{$client}{exp}{survival}{foraging}{expcur}=0;
				$user{$client}{exp}{survival}{foraging}{expneeded}=8000;
				$user{$client}{exp}{survival}{foraging}{pool}=0;
				$user{$client}{exp}{survival}{skinning}{ranks}+=2;
				$user{$client}{exp}{survival}{skinning}{expcur}=0;
				$user{$client}{exp}{survival}{skinning}{expneeded}=8000;
				$user{$client}{exp}{survival}{skinning}{pool}=0;
				}
			elsif ($request==5){
				$outbuffer{$client}.="You recieve as your bonus 4 points of Streetsmarts";
				$user{$client}{exp}{streetsmarts}{perception}{ranks}=2;
				$user{$client}{exp}{streetsmarts}{perception}{expcur}=0;
				$user{$client}{exp}{streetsmarts}{perception}{expneeded}=8000;
				$user{$client}{exp}{streetsmarts}{perception}{pool}=0;
				
				$user{$client}{exp}{streetsmarts}{gambling}{ranks}=2;
				$user{$client}{exp}{streetsmarts}{gambling}{expcur}=0;
				$user{$client}{exp}{streetsmarts}{gambling}{expneeded}=8000;
				$user{$client}{exp}{streetsmarts}{gambling}{pool}=0;
				
				}
			elsif ($request==6){
				$outbuffer{$client}.="You recieve as your bonus 30 Character Points";
				$user{$client}{cp}+=30;
				}
			else {
				$outbuffer{$client}.="huh?";

				}
			unless (loadplayer("new",$client)){
				print "error loading new\r\n";
				}
			addtoroom("1",$client);
			$outbuffer{$client}.="\r\nWe're giving you some stats now. You can use your CP to train them more elsewhere.\r\nIn the future we'll give you some control here to, but for now everyone starts the same\r\n";
			createdone();
			return;
			}
sub createdone {
			$type{$client}="normal";
			say2("A young elemental spawns before your very eyes.",$user{$client}{room},"",$client);
			look();
			return;
			}
sub password {
			print "checking Password";
			unless (loadplayer("$user{$client}{name}","$client")){
				$outbuffer{$client}.="\r\nWhoops that was wrong who were you again?\r\n";
				$user{$client}="";
				$type{$client}="login";
				next;
				}
			else {
				unless ($request=~/^$user{$client}{password}$/i){
					$outbuffer{$client}.="Nope that's not your password\r\nWho are you?\r\n$request - $user{$client}{password}\r\n:";
					delete $user{$client};
					$type{$client}="login";
					return 0;
					}
				$outbuffer{$client}.="\r\nWelcome to the Northlands. \r\n";
				$type{$client}="normal";
				say("$user{$client}{name} apears in a flash of brilliant light.");
				$room[$user{$client}{room}]{in}{$client}=$user{$client}{name};
				look();
				return;
				}
			
			}
sub health {
	$outbuffer{$client}.="Your current status is: \r\nYour body feels ";
	if ($user{$client}{vitality}==0){
		$outbuffer{$client}.="dead";
		}
	elsif (($user{$client}{vitality}/$user{$client}{vitalitymax})==1){
		$outbuffer{$client}.= "Great";
		}
	elsif (($user{$client}{vitality}/$user{$client}{vitalitymax})>=.9){
		$outbuffer{$client}.= "bruised";
		}
	elsif (($user{$client}{vitality}/$user{$client}{vitalitymax})>=.8){
		$outbuffer{$client}.= "slightly battered";
		}
	elsif (($user{$client}{vitality}/$user{$client}{vitalitymax})>=.7){
		$outbuffer{$client}.= "wounded";
		}
	elsif (($user{$client}{vitality}/$user{$client}{vitalitymax})>=.6){
		$outbuffer{$client}.= "battered";
		}
	elsif (($user{$client}{vitality}/$user{$client}{vitalitymax})>=.5){
		$outbuffer{$client}.= "badly battered";
		}
	elsif (($user{$client}{vitality}/$user{$client}{vitalitymax})>=.4){
		$outbuffer{$client}.= "badly hurt";
		}
	elsif (($user{$client}{vitality}/$user{$client}{vitalitymax})>=.3){
		$outbuffer{$client}.= "terrible";
		}
	elsif (($user{$client}{vitality}/$user{$client}{vitalitymax})>=.2){
		$outbuffer{$client}.= "like this clearly isn't your day";
		}
	elsif (($user{$client}{vitality}/$user{$client}{vitalitymax})>=0){
		$outbuffer{$client}.= "like you stand before the mouth of death as it prepares to consume you";
		}
	elsif (($user{$client}{vitality}/$user{$client}{vitalitymax})<0){
		$outbuffer{$client}.= "dead";
		}
	$outbuffer{$client}.="\r\n";
	foreach $a (keys %{$user{$client}{health}}){
		my $b=$user{$client}{health}{$a}{requires};
#		print "$b..$a\n";
		if ($b){
			if ($user{$client}{health}{$b}{hp}>0){		
				if (my $line=healthcheck($a)){
					$badhealth=1;
					$outbuffer{$client}.="Your \u$a has $line. ";
					}
				}
			}
		else {
			if (my $line=healthcheck($a)){
					$badhealth=1;
					$outbuffer{$client}.="Your \u$a has $line. ";
					}
				}
			}
		unless ($badhealth==1){
			$outbuffer{$client}.="Perfect health\r\n";
			}
	$outbuffer{$client}.="\r\n$prompt";
	return;
	}
sub healthcheck {
my $a=shift;
my $line;
my $b="0";
if ($user{$client}{health}{$a}{inthp}/$user{$client}{health}{$a}{maxinthp}<1){
	$b=1;
	$line="internal wounds";
	}
if ($user{$client}{health}{$a}{intbleeding}){
	if ($b==1){
		$line.=" causing internal bleeding";
		}
	else {
		$line= "internal bleeding ";
		}
	}
if ($user{$client}{health}{$a}{hp}/$user{$client}{health}{$a}{maxhp}<1){
	if ($b==1){
		$line.=" compounded by external wounds";
		}
	else {
		$b=1;
		$line="external Wounds";
		}
	}
if ($user{$client}{health}{$a}{bleeding}){
	if ($b==1){
		$line.=" causing external bleeding";
		}
	else {
		$line= "External bleeding";
		}
	}
return $line;
}	
sub sit {
if (roundcheck()){
	return;
	}
if ($user{$client}{position} eq "sit"){
	$outbuffer{$client}.="You already are sitting\r\n$prompt";
	return;
	}
unless ($input[1]){
	say ("$user{$client}{name} sits down");
	$user{$client}{position} = "sit";
	$user{$client}{roomdesc}= "$user{$client}{name} is sitting here";
	return;
	}
if ($input[1] eq "on"){
	shift @input;
	}
#my $a=locateitemfloor($user{$client}{room},$input[1]);
my $a;
unless ($a=locateitemfloor($user{$client}{room},$input[1])){
	$outbuffer{$client}.="can't find that\r\n$prompt";
	return;
	}
unless ($a){
	return;
	}
if (defined($item{$a}{allowsit})){
	if (defined($item{$a}{sit})){
		&{$item{$a}{sit}};
		return;
		}
	else {
		say("$user{$client}{name} sits on $item{$a}{name}");
		$user{$client}{position} = "sit";
		$user{$client}{roomdesc}= "$user{$client}{name} is sitting on $item{$a}{name}";
		return;
		}
	}
else {
	$outbuffer{$client}.="You can't sit on that\r\n$prompt";
	return;
	}
}
sub stand {
if (roundcheck()){
	return;
	}
if (($user{$client}{position} eq "stand") or (!$user{$client}{position})){
	$outbuffer{$client}.="You already are standing\r\n$prompt";
	return;
	}
say ("$user{$client}{name} stands up");
$user{$client}{position} = "stand";
$user{$client}{roomdesc}= undef;
}
sub lay {
if (roundcheck()){
	return;
	}
if ($user{$client}{position} eq "lay"){
	$outbuffer{$client}.="You are already laying down.\r\n$prompt";
	return;
	}
say ("$user{$client}{name} lays down");
$user{$client}{position} = "lay";
$user{$client}{roomdesc}= "$user{$client}{name} is laying around lazily";
}
sub help {
unless ($input[1]){
	$input[1]="help";
	}
if ($input[1] eq "commands"){
	$outbuffer{$client}.="Current commands available to you are:\r\n @{$commandlist{$type{$client}}}";
	$outbuffer{$client}.="\r\nCurrent valid topics are:\r\n @{$commandlist{helptopics}}\r\n$prompt";
	return;
	}
if ($commands{helptopics}{$input[1]}) {
	do_help("help/$commands{helptopics}{$input[1]}");
	return;
	}
if ($commands{basic}{$input[1]}){
	do_help("help/$commands{basic}{$input[1]}");
	return;
	}
unless ($commands{$type{$client}}{$input[1]}){
	$outbuffer{$client}.="No help on that topic\r\n$prompt";
	return;
	}
unless (-e "help/$commands{$type{$client}}{$input[1]}"){
	$outbuffer{$client}.="No help for that command yet available\r\n$prompt";
	return;
	}
do_help("help/$commands{$type{$client}}{$input[1]}");
	
}
sub do_help {
my $a=shift;
unless (open(HELP, "$a")){
	$outbuffer{$client}.="error opening help file. $!";
	return;
	}
local $/;
$a=<HELP>;
$outbuffer{$client}.="$a\r\n$prompt";
close(HELP);
}
sub  go {
if ($room[$user{$client}{room}]{exits}{$input[1]}){
			move($room[$user{$client}{room}]{exits}{$input[1]},"$user{$client}{name} walks out","$user{$client}{name} walks in");
			}
		else {
			$outbuffer{$client}.="You can't go that way\r\n$prompt";
			}	
		}
sub inventory{
$a=$client;
#print "a=$a\n";
my $e=0;
my $hold="";
my $line="";
my $f=0;
foreach $b (keys %{$user{$a}{health}}){
	#print "\$b=$b\n";
	foreach $c (keys %{$user{$a}{health}{$b}{wear}}){
		#print "\$c=$c\n";
		if ($user{$a}{health}{$b}{wear}{$c}){
			if ($e==1){
				$line.=", $item{$user{$a}{health}{$b}{wear}{$c}}{pre} $item{$user{$a}{health}{$b}{wear}{$c}}{name} on your $c";
				}
			else {
				$e=1;
				$line.="$item{$user{$a}{health}{$b}{wear}{$c}}{pre} $item{$user{$a}{health}{$b}{wear}{$c}}{name} on your $c";
				}
			}
		}
	if ($user{$a}{health}{$b}{hold}){
		if ($f==1){
			$hold.=", $item{$user{$a}{health}{$b}{hold}}{pre} $item{$user{$a}{health}{$b}{hold}}{name} in your $b";
			}
		else {
			$f=1;
			$hold.="$item{$user{$a}{health}{$b}{hold}}{pre} $item{$user{$a}{health}{$b}{hold}}{name} in your $b";
			}
		}
	}
if ($hold){
	$outbuffer{$client}.="You are holding $hold\r\n";	
	}

if ($line){
	$outbuffer{$client}.="You are wearing $line\r\n$prompt";
	}
else {
	$outbuffer{$client}.="You are naked!\r\n$prompt";
	}
}

sub get {
unless ($a=locateitemfloor($user{$client}{room},$input[1])){
	$outbuffer{$client}.="I can't find what your refering to.\r\n$prompt";
	return 0;
	}
if ($item{$a}{noget}){
	$outbuffer{$client}.="You can't get that.\r\n$prompt";
	return 0;
	}
$hold=&findopenhold;
print "$hold\n";
unless ($hold){
	$outbuffer{$client}.="your hands are full\r\n$prompt";
	return 0;
	}
removeitemfromroom($user{$client}{room},$a);
additemtoinventory($a,$hold);	
$outbuffer{$client}.="You pick up $item{$a}{pre} $item{$a}{name} with your $hold\r\n$prompt";
}
sub findopenhold {
foreach $a (@{$user{$client}{hold}}){
#	print "a=$a\n";
	if ($user{$client}{health}{$a}{hold}){
		next;
		}
	else {
		return $a;
		}
	return 0;
	}
}
sub additemtoinventory {
$item=shift;
$location=shift;
$user{$client}{health}{$location}{hold}=$item;
}
sub removeitemfrominventory{
$location=shift;
$user{$client}{health}{$location}{hold}=undef;
}
sub locateitemhands {
$item=shift;
foreach $b (@{$user{$client}{hold}}){
	print "looking for $item in $b\r\n";
	if ($user{$client}{health}{$b}{hold}) {
		if ($item{$user{$client}{health}{$b}{hold}}{name}=~/$item/i){
			if ($skip){
			$skip--;	
				}
			else {
				print "found $item{$user{$client}{health}{$b}{hold}}{name}  $b\n";
				return ($user{$client}{health}{$b}{hold}, $b);
				}
			}
		}
	}
}

sub drop {
my @a;
my $item=$input[1];
@a=locateitemhands($item);
removeitemfrominventory($a[1]);
additemtoroom($user{$client}{room},$a[0]);
$outbuffer{$client}.="You drop $item{$a[0]}{name}.\r\n$prompt";
}
sub wear {
$item=$input[1];
my @a=locateitemhands($item);
unless ($a[0] and $a[1]){
	$outbuffer{$client}.="You aren't holding that.\r\n$prompt";
	return;
	}
print "$a[0]\n";
@location=locatewearlocation($a[0]);	
unless ($location[0] and $location[1]){
	$outbuffer{$client}.="You have no where to wear that available.\r\n$prompt";
	return 0;
	}
#if ($user{$client}{health}{$location[0]}{wear}{$location[1]})
#print "current location is $location[0],$location[1]\n";

removeitemfrominventory($a[1]);
additemtowear(@location,$a[0]);
$outbuffer{$client}.="You wear $item{$a[0]}{pre} $item{$a[0]}{name} on your $location[1].\r\n$prompt";
}
sub locatewearlocation {
my $item=shift;
unless ($item{$item}{wear}){
	return 0;
	}
foreach $a (keys %{$user{$client}{health}}){
	print "$a\n";
	foreach $b (keys %{$user{$client}{health}{$a}{wear}}) {
		print "$b\n";
		if ($b eq $item{$item}{wear}){
			print "\n";
			if ($user{$client}{health}{$a}{wear}{$b}){
				next;
				}
			else {
				return ($a, $b);
				
				}
			}
		}
	print "\n";
	}

}
sub additemtowear {
$location=shift;
$specific=shift;
$item=shift;
$user{$client}{health}{$location}{wear}{$specific}=$item;
}
sub unwear {
	my $item=$input[1];
	print "item=$item\n";
	my @a=locateitembody($item);
	unless ($a[0] and $a[1]){
		$outbuffer{$client}.="Can't find what you were refering to\r\n$prompt";
		return;
		}
	my $a=&findopenhold;
	unless ($a){
		$outbuffer{$client}.="Your hands are full\r\n$prompt";
		return;
		}
#	print "a=@a\n";
	removefrombody(@a);
	
	additemtoinventory($a[2],$a);
	$outbuffer{$client}.="You remove $item{$a[2]}{pre} $item{$a[2]}{name} from your $a[0]\r\n$prompt";
	return 1;
	}
sub locateitembody {
$item=shift;
#print "a=$item";
unless ($item){
#print "AAAA\n";
return 0;
}
foreach $a (keys %{$user{$client}{health}}){
	foreach $b (keys %{$user{$client}{health}{$a}{wear}}) {
		if ($user{$client}{health}{$a}{wear}{$b}){
			if ($item{$user{$client}{health}{$a}{wear}{$b}}{name}=~/$item/i){
				#print "$a,$b,$user{$client}{health}{$a}{wear}{$b})";
				return ($a,$b,$user{$client}{health}{$a}{wear}{$b});
				}
			}
		}
	}
}
sub removefrombody {
my $hold=shift;
my $hold2=shift;
print "deleting $user{$client}{health}{$hold}{wear}{$hold2}\n";
$user{$client}{health}{$hold}{wear}{$hold2}=undef;
return 1;
}
sub reloadcommand {
unless (defined($user{$client}{god})){
	$outbuffer{$client}.="Huh?\r\n$prompt";
	return;
	}
loadcommands();	
$outbuffer{$client}.="Commands reloaded\r\n$prompt";
}
sub reloadroom{
unless (defined($user{$client}{god})){
	$outbuffer{$client}.="Huh?\r\n$prompt";
	return;
	}
loadroom();	
$outbuffer{$client}.="room reloaded\r\n$prompt";
}
sub reloadmonster {
unless (defined($user{$client}{god})){
	$outbuffer{$client}.="Huh?\r\n$prompt";
	return;
	}
loadmonster();	
$outbuffer{$client}.="monsters reloaded\r\n$prompt";
}
sub reloaditem {
unless (defined($user{$client}{god})){
	$outbuffer{$client}.="Huh?\r\n$prompt";
	return;
	}
loaditems();	
$outbuffer{$client}.="items reloaded\r\n$prompt";
}
sub reload {
#this is really dangerous. really really dangerous, one misspelling and poof.
unless (defined($user{$client}{god})){
	$outbuffer{$client}.="Huh?\r\n$prompt";
	return;
	}
&{"reload$input[1]"};
}
sub donew {
unless (defined($user{$client}{god})){
	$outbuffer{$client}.="Huh?\r\n$prompt";
	return;
	}
if (newload($input[1])){
	$outbuffer{$client}.="Loaded $input[1]\r\n$prompt";
}else {
	$outbuffer{$client}.="failed\r\n$prompt";
	}
}
sub newload {
my $a=shift;
require("$a");
return 1;
}
sub engage {
if (defined($user{$client}{eng}{to})){
	$outbuffer{$client}.="Your already engaging something.\r\n$prompt";
	return;
	}
shift @input;
my $b=join(" ",@input);
my $a=locateroomplayer("$b");
unless ($a){
	$outbuffer{$client}.="I can't find that person\r\n$prompt";
	return;
	}
$user{$client}{eng}{to}="$a";
$user{$client}{eng}{pos}=0;
if ($user{$a}{eng}{to} eq $client){
	$user{$client}{eng}{distance}="$user{$a}{eng}{distance}";
	}
else {
	$user{$client}{eng}{distance}="missile";
	}
unless ($user{$client}{eng}{distance} eq "melee"){
	$outbuffer{$client}.="You start to engage $user{$a}{pre}$user{$a}{name} from $user{$client}{eng}{distance} range\r\n$prompt";
	my $time=time;
	push (@{$do{$time+12+int(rand(10))}},{sub=>"advance",args=>[$client]});
	}
else {
	$outbuffer{$client}.="You turn to face $user{$a}{pre}$user{$a}{name}\r\n";
	}
}
sub advance {
my $client=shift;
my $time=time;
if ($user{$client}{eng}{distance} eq "melee"){
	return;
	}
if ($user{$client}{eng}{distance} eq "missile") {
	$user{$client}{eng}{distance}="pole";
	if ($user{$user{$client}{eng}{to}}{eng}{to} eq $client) {
		$user{$user{$client}{eng}{to}}{eng}{distance}="pole";
		}
	push (@{$do{$time+8+int(rand(10))}},{sub=>"advance",args=>[$client]});
	}
elsif ($user{$client}{eng}{distance} eq "pole"){
	if ($user{$user{$client}{eng}{to}}{eng}{to} eq $client) {
		$user{$user{$client}{eng}{to}}{eng}{distance}="melee";
		}
	
	$user{$client}{eng}{distance}="melee";
	}
unless (defined($user{$client}{pre})){
	$user{$client}{pre}="";
	}
my $string1="$user{$client}{pre}$user{$client}{name} closes to $user{$client}{eng}{distance} range on $user{$user{$client}{eng}{to}}{pre}$user{$user{$client}{eng}{to}}{name}";
my $string2="You close to $user{$client}{eng}{distance} range on $user{$user{$client}{eng}{to}}{pre}$user{$user{$client}{eng}{to}}{name}";
say2($string1,$user{$client}{room},$string2,$client);
}

return 1;