]> git.rm.cloudns.org Git - xonotic/xonotic.git/commitdiff
move list handling from qc to bot scripting. Allows us to use teleports instead soon.
authorRudolf Polzer <divverent@xonotic.org>
Fri, 14 Sep 2012 08:46:18 +0000 (10:46 +0200)
committerRudolf Polzer <divverent@xonotic.org>
Fri, 14 Sep 2012 08:46:18 +0000 (10:46 +0200)
misc/tools/midi2cfg-ng.conf
misc/tools/midi2cfg-ng.pl

index 78248857f3e4b96907d1096c38166398ca6d09e4..aa7c3fb40e52d9d5a8c590e3f38ef267db6ffc4e 100644 (file)
@@ -6,11 +6,11 @@ timeoffset_preintermission 2
 timeoffset_postintermission 2
 time_forgetfulness 3
 
-raw set places_tuba "tUba1 tUba2 tUba3 tUba4 tUba5 tUba6 tUba7 tUba8 tUba9 tUba10 tUba11 tUba12 tUba13 tUba14 tUba15 tUba16 tUba17 tUba18 tUba19 tUba20 tUba21 tUba22 tUba23 tUba24 tUba25 tUba26 tUba27 tUba28 tUba29 tUba30 tUba31 tUba32"
-raw set places_percussion "tChr1 tChr2 tChr3 tChr4 tChr5 tChr6 tChr7 tChr8 tChr9 tChr10 tChr11 tChr12 tChr13 tChr14 tChr15 tChr16 tChr17 tChr18 tChr19 tChr20 tChr21 tChr22 tChr23 tChr24 tChr25 tChr26 tChr27 tChr38 tChr39 tChr30 tChr31 tChr32"
-raw set places_vocals "tVocals"
-raw set places_metalsteps "tMetalSteps1 tMetalSteps2 tMetalSteps3"
-raw set places_nosteps "tNoSteps1 tNoSteps2 tNoSteps3 tNoSteps4"
+list places_tuba tUba1 tUba2 tUba3 tUba4 tUba5 tUba6 tUba7 tUba8 tUba9 tUba10 tUba11 tUba12 tUba13 tUba14 tUba15 tUba16 tUba17 tUba18 tUba19 tUba20 tUba21 tUba22 tUba23 tUba24 tUba25 tUba26 tUba27 tUba28 tUba29 tUba30 tUba31 tUba32
+list places_percussion tChr1 tChr2 tChr3 tChr4 tChr5 tChr6 tChr7 tChr8 tChr9 tChr10 tChr11 tChr12 tChr13 tChr14 tChr15 tChr16 tChr17 tChr18 tChr19 tChr20 tChr21 tChr22 tChr23 tChr24 tChr25 tChr26 tChr27 tChr38 tChr39 tChr30 tChr31 tChr32
+list places_vocals tVocals
+list places_metalsteps tMetalSteps1 tMetalSteps2 tMetalSteps3
+list places_nosteps tNoSteps1 tNoSteps2 tNoSteps3 tNoSteps4
 
 raw settemp bot_ai_thinkinterval 0
 raw settemp bot_sound_monopoly 1
index 58b4097065280f6bdd0648be09e93502ac3eb494..35ade35920db7a1e0a19363726ff73f484d6c678 100755 (executable)
@@ -25,6 +25,8 @@ my $timeoffset_postdone = 2;
 my $timeoffset_preintermission = 2;
 my $timeoffset_postintermission = 2;
 my $time_forgetfulness = 1.5;
+my %lists = ();
+my %listindexes = ();
 
 my ($config, @midilist) = @ARGV;
 
@@ -207,6 +209,11 @@ sub botconfig_read($)
                {
                        $time_forgetfulness = $1;
                }
+               elsif(/^list (.*?) (.*)/)
+               {
+                       $lists{$1} = [split / /, $2];
+                       $listindexes{$1} = 0;
+               }
                else
                {
                        print "unknown command: $_\n";
@@ -298,6 +305,19 @@ sub busybot_cmd_bot_test($$$@)
        return 1;
 }
 
+sub buildstring(@)
+{
+       return
+               join " ",
+               map
+               {
+                       $_ =~ /^\@(.*)$/
+                               ? do { $lists{$1}[$listindexes{$1}++ % @{$lists{$1}}]; }
+                               : $_
+               }
+               @_;
+}
+
 sub busybot_cmd_bot_execute($$@)
 {
        my ($bot, $time, @commands) = @_;
@@ -340,7 +360,7 @@ sub busybot_cmd_bot_execute($$@)
                }
                elsif($_->[0] eq 'cmd')
                {
-                       $commands .= sprintf "sv_cmd bot_cmd %d %s\n", $bot->{id}, join " ", @{$_}[1..@$_-1];
+                       $commands .= sprintf "sv_cmd bot_cmd %d %s\n", $bot->{id}, buildstring @{$_}[1..@$_-1];
                }
                elsif($_->[0] eq 'aim_random')
                {
@@ -354,7 +374,7 @@ sub busybot_cmd_bot_execute($$@)
                }
                elsif($_->[0] eq 'raw')
                {
-                       $commands .= sprintf "%s\n", join " ", @{$_}[1..@$_-1];
+                       $commands .= sprintf "%s\n", buildstring @{$_}[1..@$_-1];
                }
        }
 
@@ -1050,6 +1070,7 @@ my @preallocate = ();
 $noalloc = 0;
 for(;;)
 {
+       %listindexes = ();
        $commands = "";
        eval
        {