]> git.xonotic.org Git - xonotic/xonotic.git/blobdiff - misc/tools/WeaponEncounterProfile.pm
fix some weapon names
[xonotic/xonotic.git] / misc / tools / WeaponEncounterProfile.pm
index 68acfb23bcc5e8b1699c5a81a8ccec2e3064825a..4218be62325c11a21c888b41504d95e0b1b33f39 100644 (file)
@@ -27,7 +27,28 @@ sub load($)
                /^$/ and next;
                /^#/ and next;
                /^\/\// and next;
-               my ($addr, $map, $attackerweapon, $targweapon, $value) = split /\t/, $_;
+               my ($addr, $map, $attackerweapon, $targweapon, $value);
+               if(/^([^\t]+)\t(\S+)\t(\d+) (\d+)\t(\d+) (\d+)\t(\d+) (\d+) (\S+)$/)
+               {
+                       # new format (Xonotic)
+                       ($addr, $map, $attackerweapon, $targweapon) = ($1, $2, $3, $5);
+                       next if $4 and not $ENV{WEAPONPROFILER_WITHBOTS};
+                       next if $6 and not $ENV{WEAPONPROFILER_WITHBOTS};
+                       $value =
+                               $ENV{WEAPONPROFILER_DAMAGE} ? $9 :
+                               $ENV{WEAPONPROFILER_HITS} ? $8 :
+                               $7;
+               }
+               elsif(/^([^\t]+)\t(\S+)\t(\d+)\t(\d+)\t(\S+)$/)
+               {
+                       # legacy format (Nexuiz)
+                       ($addr, $map, $attackerweapon, $targweapon, $value) = ($1, $2, $3, $4, $5);
+               }
+               else
+               {
+                       print STDERR "UNRECOGNIZED: $_\n";
+                       next;
+               }
                $targweapon = int $self->weaponid_from_name($targweapon)
                        if $targweapon ne int $targweapon;
                $attackerweapon = int $self->weaponid_from_name($attackerweapon)
@@ -102,19 +123,20 @@ our %WeaponMap = (
          2 => ["Shotgun", "shotgun"],
          3 => ["Uzi", "uzi"],
          4 => ["Mortar", "gl"],
-         5 => ["Electro", "electro"],
-         6 => ["Crylink", "crylink"],
-         7 => ["Nex", "nex"],
-         8 => ["Hagar", "hagar"],
-         9 => ["Rocket Launcher", "rl"],
-        10 => ["Port-O-Launch", "porto"],
-        11 => ["MinstaNex", "minstanex"],
-        12 => ["Grappling Hook", "hookgun"],
-        13 => ["Heavy Laser Assault Cannon", "hlac"],
-        14 => ["Tuba", "tuba"],
-        15 => ["Camping Rifle", "campingrifle"],
-        16 => ["Fireball", "fireball"],
-        17 => ["Seeker", "seeker"],
+         5 => ["Mine Layer", "minelayer"],
+         6 => ["Electro", "electro"],
+         7 => ["Crylink", "crylink"],
+         8 => ["Nex", "nex"],
+         9 => ["Hagar", "hagar"],
+        10 => ["Rocket Launcher", "rl"],
+        11 => ["Port-O-Launch", "porto"],
+        12 => ["MinstaNex", "minstanex"],
+        13 => ["Grappling Hook", "hookgun"],
+        14 => ["Heavy Laser Assault Cannon", "hlac"],
+        15 => ["@!#%'n Tuba", "tuba"],
+        16 => ["Sniper Rifle", "sniperrifle"],
+        17 => ["Fireball", "fireball"],
+        18 => ["Seeker", "seeker"],
 );
 
 sub weaponid_valid($$)