So I guess everyone played an mmorpg at least one time.
What about those times when you want things to go a little faster or win more faster in an mmorpg.
Let's take a particular case :hobowars.
It's a game in wich you battle other hobos for money,
respect etc...
probably a nice way to kill some time
A part of the game offers a hobo the possibility to explore
the city ,giving him an imaginary square grid of the city and some directions(have a look
at a picture of how the http://www.hobowars.com/images/hbw-06.jpg),
and he can go in the directions he wants and along the way
find different items,food,money or cans wich he can sell at
the can depo for money
There are 200 turns so it's allot of clicking to do
and maybe it gets boring to need to click that much

So maybe we could fix that.
The following code is commented and shows how one can achieve that by automatically "exploring" the city:
use strict; use warnings; use WWW::Mechanize; my $m = WWW::Mechanize->new(); $m->get('http://www.hobowars.com'); $m->submit_form( form_name =>'loginForm', fields => { username => '', password => '', }, button =>'submit', ); $m->follow_link(url_regex=> qr/cmd\=explore/i); $m->follow_link(url_regex=> qr/cmd\=explore\&do\=/i); my $turns_left = 1; my $turns_used = 0; my @turn_cmds = ( { direction=>'left' ,times=>50, }, { direction=>'down' ,times=>50, }, { direction=>'right' ,times=>50, }, { direction=>'up' ,times=>50, }, );#this array records all the commands and they will made in the o +rder the array stores #this is just an example about how you can consume your 200 turn +s/day my $turn_cmd=0; #this is the indev of the current command wich is run right now while($turns_left) {#while we still have turns to use $turns_used++; ($turns_left) = $m->content =~ /left: (\d+)/; my ($X,$Y) = $m->content =~ /(\d+) , (\d+)<\/font><\/strong><\/div +><\/td>/; #get the current position in the game grid my $directions = {}; for ( grep { $_->url =~ /do\=move.*dir=/ } $m->links ) { #for each + direction link on the page my ($x,$y) = $_->url_abs =~ /x=(\d+)\&y=(\d+)/; #current posit +ion in the grid my $key = ""; #<-- here we will construct the name of the dire +ction depending on xdiff and ydiff # wich show us wich way each direction goes my $xdiff=$X-$x; my $ydiff=$Y-$y; $key.="left" if $xdiff == 1; $key.="right" if $xdiff == -1; $key.="up" if $ydiff == 1; $key.="down" if $ydiff == -1; #warn "Xdiff:$xdiff , Ydiff:$ydiff ,key:$key"; $directions->{$key} = $_->url_abs; #put the absolute url in th +at direction }; warn "[TURNS LEFT]:$turns_left"; warn "[TURNS USED]:$turns_used"; warn "[X]=$X [Y]=$Y"; $m->get($directions->{$turn_cmds[$turn_cmd]->{direction} }); warn "[TURN MADE] , DIRECTION: ".$turn_cmds[$turn_cmd]->{direction +}." TIMES: ".$turn_cmds[$turn_cmd]->{times} ; if($turn_cmds[$turn_cmd]->{times}--==0) { $turn_cmd++;#if we finished the current command then go to the + next command }; }
EDIT: Fixed the links,thanks zentara and Gavin.

Replies are listed 'Best First'.
Re: elegantly cheating mmorpgs using perl
by Anonymous Monk on Jul 22, 2008 at 19:14 UTC
    I've done something like this in the past. Mainly to see if I could. For me it was "cheating" a web game called "Travian". I used the same technique, but used ruby + Watir. Worked a charm. I had 24x7 buildings being constructed, resources being shipped around from high producers to small ones, armies going out to pillage, etc. For months. Never got caught, and the techniques for finding a bot would have been so, so simple. Nice article.
Re: elegantly cheating mmorpgs using perl
by spx2 (Deacon) on Dec 24, 2007 at 10:05 UTC
    hobowars has some captcha sometimes when exploring the city but that can be overcomed by manualy logging in and solving the captcha,then the script will work with no problems(I've tested this)
      Simply amazing! Works like a charm.
        I'm glad you like it rosey :)