User Tools

Site Tools


user:mhoram:scripts:attacktype

Here's a very simple script that takes a number as an argument and outputs the attacktypes corresponding to that value. Requires Perl.

#!/usr/bin/perl
use warnings;
use strict;
 
die "Usage: attacktype <number>\n" unless $ARGV[0] =~ /^\d+$/;
 
my @attacktypes = qw( physical      # taken from include/attack.h
		      magic	
		      fire		
		      electricity	
		      cold		
		      confusion	
		      acid		
		      drain	
		      weaponmagic	
		      ghosthit	
		      poison	
		      slow		
		      paralyze	
		      turn_undead	
		      fear		
		      cancellation 
		      deplete      
		      death        
		      chaos        
		      counterspell 
		      godpower	
		      holyword	
		      blind	
		      internal	
		      life_stealing
		      disease	
		    );
 
for my $at (0..25){
    if( $ARGV[0] & (2**$at)){
	print "$attacktypes[$at]\n";
    }
}
user/mhoram/scripts/attacktype.txt · Last modified: 2007/03/06 10:24 (external edit)