1 |
root |
1.1 |
#!/usr/bin/perl |
2 |
|
|
|
3 |
|
|
for ($i=0; $i<=$#ARGV; $i++) { |
4 |
|
|
if (!rename("$ARGV[$i]", "$ARGV[$i].bak")) { |
5 |
|
|
print STDERR "Unable to rename file $ARGV[$i]\n"; |
6 |
|
|
next; |
7 |
|
|
} |
8 |
|
|
print "Processing $ARGV[$i]\n"; |
9 |
|
|
open(IN,"<$ARGV[$i].bak"); |
10 |
|
|
open(OUT,">$ARGV[$i]"); |
11 |
|
|
while (<IN>) { |
12 |
|
|
$in = $_; |
13 |
|
|
if (/^end\s*$/) { |
14 |
|
|
print OUT "$body_info" if ($body_info ne ""); |
15 |
|
|
print OUT "$weapon_info" if ($weapon_info ne ""); |
16 |
|
|
print OUT "$wand" if ($wand ne ""); |
17 |
|
|
$body_info=""; |
18 |
|
|
$weapon_info=""; |
19 |
|
|
$wand=""; |
20 |
|
|
} |
21 |
|
|
if (/^Object (.*)$/) { |
22 |
|
|
$body_info=""; |
23 |
|
|
$weapon_info=""; |
24 |
|
|
$wand=""; |
25 |
|
|
} |
26 |
|
|
elsif (/^can_use_shield\s+1/) { |
27 |
|
|
$weapon_info="body_arm 2\n"; |
28 |
|
|
} |
29 |
|
|
elsif (/^can_use_bow\s+1/) { |
30 |
|
|
$weapon_info="body_arm 2\n"; |
31 |
|
|
} |
32 |
|
|
elsif (/^can_use_weapon\s+1/) { |
33 |
|
|
$weapon_info="body_arm 2\n"; |
34 |
|
|
} |
35 |
|
|
elsif (/^can_use_wand\s+1/) { |
36 |
|
|
$wand="body_range 1\n"; |
37 |
|
|
} |
38 |
|
|
elsif (/^can_use_rod\s+1/) { |
39 |
|
|
$wand="body_range 1\n"; |
40 |
|
|
} |
41 |
|
|
elsif (/^can_use_horn\s+1/) { |
42 |
|
|
$wand="body_range 1\n"; |
43 |
|
|
} |
44 |
|
|
elsif (/^can_use_armour\s+1/) { |
45 |
|
|
$body_info .= "body_torso 1\nbody_head 1\nbody_shoulder 1\nbody_foot 2\nbody_wrist 2\nbody_hand 2\nbody_waist 1\n"; |
46 |
|
|
} |
47 |
|
|
elsif (/^can_use_ring\s+1/) { |
48 |
|
|
$body_info .="body_finger 2\n"; |
49 |
|
|
} |
50 |
|
|
elsif (/^can_use_skill\s+1/) { |
51 |
|
|
$body_info .="body_skill 1\n"; |
52 |
|
|
} |
53 |
|
|
|
54 |
|
|
print OUT $in; |
55 |
|
|
} |
56 |
|
|
close(OUT); |
57 |
|
|
close(IN); |
58 |
|
|
unlink("$ARGV[$i].bak"); |
59 |
|
|
} |