[Crossfire-wiki] [Crossfire DokuWiki] page changed: user:mhoram:scripts:watch_food

no-reply_wiki at metalforge.org no-reply_wiki at metalforge.org
Mon Feb 19 15:11:11 CST 2007


A page in your DokuWiki was added or changed. Here are the details:

Date        : 2007/02/19 15:11
User        : mhoram
Edit Summary: new script version

@@ -7,48 +7,68 @@
  
  ====== Requirements ======
  
    * Perl
+ 
  
  ====== Code ======
  <code perl>
  #!/usr/bin/perl
  use warnings;
  use strict;
+ require "./subs.pl"; # get some subs to use
  $| = 1;
  
  my $last_meal = time;
- my $hungry = 250;     # Set this to your "hunger" preference
+ my $hungry = 500;
+ my $praycount = 1;
+ 
+ print "draw 4 Watching food...\n";
  
  print "watch stats\n";
  
- while(<STDIN>){
-   if( ( time - $last_meal ) > 60  and /food (\d+)/ ){
-     my $food = $1;
-     next unless $food < $hungry;
-     print "request items inv\n";
-     my $foods; my $waybreads;
-     while(<STDIN>){
-       last if /request items inv end/;
-       if( /request items inv .* foods?$/ ){
- 	$foods = 1;
- 	last;
-       } elsif( /request items inv .* waybreads?$/ ){
- 	$waybreads = 1;
-       }
+ while (<STDIN>) {
+     if ( ( time - $last_meal ) > 60  and /food (\d+)/ ) {
+ 	my $food = $1;
+ 	next unless $food < $hungry;
+ 	print "request items inv\n";
+ 	my $foods; my $waybreads; my $orcchops;
+ 	while (<STDIN>) {
+ 	    last if /request items inv end/;
+ 	    if ( /request items inv .* foods?$/ ) {
+ 		$foods = 1;
+ 		last;
+ 	    } elsif ( /request items inv .* waybreads?$/ ) {
+ 		$waybreads = 1;
+ 	    } elsif ( /request items inv .* orc chops?$/ ) {
+ 		$orcchops = 1;
+ 	    }
+ 	}
+ 	if ( $orcchops ) {
+ 	    issue('apply orc chop');
+ 	    draw(3, 'Hungry, eating an orc chop.');
+ 	} elsif ( $foods ) {
+ 	    issue('apply food');
+ 	    draw(3, 'Hungry, eating a food.');
+ 	} elsif ( $waybreads ) {
+ 	    issue('apply waybread');
+ 	    draw(3, 'Hungry, eating a waybread.');
+ 	} else {
+ 	    draw( 3, 'Hungry, out of food and waybread!!!');
+ 	}
+ 	$last_meal = time;
      }
-     if( $foods ){
-       print "issue 1 1 apply food\n";
-       print "draw 3 Hungry, eating a food.\n";
-     } elsif( $waybreads ){
-       print "issue 1 1 apply waybread\n";
-       print "draw 3 Hungry, eating a waybread.\n";
-     } else {
-       print "draw 3 Hungry, out of food and waybread!!!\n";
+     unless($praycount++ % 100){
+ 	$praycount = 1;
+ 	my @hp = request_line('stat hp');
+ 	my( $grace, $maxgrace ) = @hp[4,5];
+ 	if ( $grace < $maxgrace ) {
+ 	    draw(3, "Extra Prayer $praycount");
+ 	    issue('use_skill praying');
+ 	}
      }
-     $last_meal = time;
-   }
  }
+ 
  </code>
  
  ====== Notes & Comments ======
  


IP-Address  : 206.71.197.56
Old Revision: http://wiki.metalforge.net/doku.php/user:mhoram:scripts:watch_food?rev=1167323125
New Revision: http://wiki.metalforge.net/doku.php/user:mhoram:scripts:watch_food

-- 
This mail was generated by DokuWiki at
http://wiki.metalforge.net/




More information about the crossfire-wiki mailing list