From 673839ee55b6d942f4ad6f2f9af036acd14dbcdf Mon Sep 17 00:00:00 2001 From: Rudolf Polzer Date: Fri, 14 Sep 2012 10:46:18 +0200 Subject: [PATCH] move list handling from qc to bot scripting. Allows us to use teleports instead soon. --- misc/tools/midi2cfg-ng.conf | 10 +++++----- misc/tools/midi2cfg-ng.pl | 25 +++++++++++++++++++++++-- 2 files changed, 28 insertions(+), 7 deletions(-) diff --git a/misc/tools/midi2cfg-ng.conf b/misc/tools/midi2cfg-ng.conf index 78248857..aa7c3fb4 100644 --- a/misc/tools/midi2cfg-ng.conf +++ b/misc/tools/midi2cfg-ng.conf @@ -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 diff --git a/misc/tools/midi2cfg-ng.pl b/misc/tools/midi2cfg-ng.pl index 58b40970..35ade359 100755 --- a/misc/tools/midi2cfg-ng.pl +++ b/misc/tools/midi2cfg-ng.pl @@ -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 { -- 2.39.2