sub animalbirth { $time=time; #set two events, both calling say. push (@{$do{$time+2}},{sub=>"say",args=>["The gods smile down from above and the words \"Hello child\" are heard. Welcoming the new $user{$client}{name} into the world","$user{$client}{room}"]}); push (@{$do{int($time+rand(15)+2)}}, { sub=>"say", args=>["A small puff of smoke rises from below the bench.","$user{$client}{room}"] }); } sub animalmain { my $incoming=shift; #example of AI, respond with a friendly gretting. if (defined($user{$client}{dead})){ return; } if ($incoming=~/hello/i or $incoming=~/hey/i){ docommand("say hi, I'm $user{$client}{pre}$user{$client}{name}. Don't mind me I'm just wandering around."); } if ($incoming=~/\s*(\w*) begins to advance on you from/is){ #being attacked, counterattacking $1; docommand("say help I'm being attacked!"); docommand("eng $1"); return; } if ($user{$client}{eng}{to} and !$user{$client}{round}){ my @commands=("swing","feint"); my $a=int (rand(@commands)); docommand("$commands[$a]"); return; } #not in combat so lets wander around. if (rand(100)>95){ foreach $a (keys %{$room[$user{$client}{room}]{exits}}){ if ($room[$user{$client}{room}]{exits}{$a}{dest}){ push (@a, $a); } } my $direction=$a[int rand(@a)]; docommand("$direction"); return; } } sub animalcounter{ local $client=shift; docommand("swing"); } sub docommand{ push (@{$ready{$client}}, shift); } 1;