Xonotic Forums
[SOLVED] Per map setting? - Printable Version

+- Xonotic Forums (https://forums.xonotic.org)
+-- Forum: Support (https://forums.xonotic.org/forumdisplay.php?fid=3)
+--- Forum: Xonotic - Server Administration (https://forums.xonotic.org/forumdisplay.php?fid=16)
+--- Thread: [SOLVED] Per map setting? (/showthread.php?tid=5570)



Per map setting? - BuddyFriendGuy - 06-15-2015

Game admins,

I wonder whether it's possible to have a per-map balance setting. Many maps are ported from other games, and some of them requires a bit of modification to make sense. For example, I would like to turn off fall damages for maps with high surfaces.

Is this possible? For example, perhaps there's a way to get the name of the next map, and use that to trigger some alias to set a bunch of variables.

Thanks a lot.


RE: Per map setting? - Mirio - 06-15-2015

Need to put it into the mapinfo:
Code:
settemp_for_type all <cvar>



RE: Per map setting? - BuddyFriendGuy - 06-16-2015

Thanks, @Mirio. I'll test it out and mark this as solved after I figure it out.


RE: Per map setting? - BuddyFriendGuy - 06-17-2015

Thanks, @Mirio. Worked like a charm.

For anybody who wants to do the same thing, here's a small script to batch add necessary settings to a bunch of pk3 files.

Code:
#!/usr/bin/perl

# this script extracts mapinfo files from the given pk3,
# then add custom settings to the end of the mapinfo file,
# and then repack it back to the pk3 and delete the temp file

my $custom_settings = <<'END';
// prevent any kind of motion damage (bump into a wall, falling, etc.)
settemp_for_type all g_balance_falldamage_maxdamage 0
END

my %filename;
$filename{'pk3'} = $ARGV[0];
if (!$filename{'pk3'}) {
    die "$0 mapfile.pk3\n";
} elsif (!-e $filename{'pk3'}) {
    die("file not found\n");
}
my $cmd = "/usr/bin/7z x -y \"$filename{'pk3'}\" maps/\\*.mapinfo";
my @cmd_output = split("\n", `$cmd`);
foreach my $fname (@cmd_output) {
    if ($fname =~ s|^Extracting\s+||) {
        open(my $fh, ">>$fname");
        print $fh $custom_settings;
        close($fh);
        `/usr/bin/7za a -y \"$filename{'pk3'}\" "$fname"`;
        unlink("$fname");
    }
}

Here's an example of how I used it to add no-fall-damage setting to all World of Padman maps.

Code:
$ mkdir temp
$ cd temp
$ for i in ~/.xonotic/custom_maps/wop/*wop*.pk3; do ~/bin/nofalldamage.pl "$i"; done
$ cd ..
$ rm -rf temp