Quake 3
I've started hacking on the ioquake3 sources, adding a Perl interface to a small number of C functions and a few callbacks from C/QVM to Perl functions. This allowed me to add an IRC logging backend and a client hack for weapon selection.
IRC Logging
The IRC logging captures game events and produces a message to be sent to IRC. The current implementation uses Net::IRC3 but this is soon going to change to AnyEvent::IRC.
The PerlQuake3 server is running on
q3a.xinutec.org
and events are written
to the channel
#q3a
on
irc.xinutec.org
.
The following events are transferred to IRC:
- Player connected
12:49 < q3a> Jules_Vernes connected
- Player disconnected
13:20 < q3a> Jules_Vernes disconnected
- Player was killed
12:54 < q3a> Jules_Vernes was squished 13:00 < q3a> LucY was railed by Jules_Vernes 13:18 < q3a> Jules_Vernes was in the wrong place
- Round finished
22:16 < q3a> Round finished: 22:16 < q3a> 1. LucY score: 20 ping 33 22:16 < q3a> 2. peter lustich score: 3 ping 61 22:16 < q3a> 3. Jules_Vernes score: -2 ping 91
- Player said something
22:17 < q3a> <peter lustich> lol
IRC users can chat back into the game and it will look like it origined from
irc/user
where
user
is the nickname of the person on IRC. Quake colours
are converted to IRC colours and vice versa.
Furthermore, the IRC bot has the following commands:
- !clients
Show all players currently in the game.
- !verbosity [level]
If no
level
is given, this shows the current IRC verbosity. Currently, there are four verbosity bits that can be set:CHAT
,KILL
,JOIN
andSTAT
. Iflevel
is given in the form!verbosity +chat -kill +join
, the respective bits are set or unset. - !help [command]
Shows help on
command
or a list of commands ifcommand
is omitted. - !reload
Reloads all
Quake3::
modules except for theQuake3
module itself.
Client-Perl
The Quake 3 client has been enhanced to allow for prioritising weapon
selection on pickup. That means, if
cg_autoswitch
is on, weapons are only
selected if their priority is higher or equal to the priority of the current
weapon.
Currently, these priorities are not user-definable, but that will soon be implemented. The code for this is absolutely trivial and can be found in Quake3.pm:
my %prefs = ( Quake3::WP_GRAPPLING_HOOK => 0, Quake3::WP_NONE => 0, Quake3::WP_GAUNTLET => 0, Quake3::WP_GRENADE_LAUNCHER => 0, Quake3::WP_MACHINEGUN => 1, Quake3::WP_RAILGUN => 1, Quake3::WP_SHOTGUN => 2, Quake3::WP_LIGHTNING => 2, Quake3::WP_PLASMAGUN => 2, Quake3::WP_ROCKET_LAUNCHER => 3, Quake3::WP_BFG => 4, ); sub item_pickup { my ($curweap, $newweap) = @_; $prefs{$newweap} >= $prefs{$curweap} ? 1 : 0 }
Future
The current implementation and API design is below all standards (except for maybe the irssiperl one) and requires some real thinking. This interface was written in a few minutes (after needing an hour to figure out how the QVM and callbacks to C work). In the future, the API will undergo some serious changes and probably be rewritten entirely from scratch.