[nexuiz-commits] r6982 - trunk/misc/tools

DONOTREPLY at icculus.org DONOTREPLY at icculus.org
Thu Jun 11 12:37:20 EDT 2009


Author: div0
Date: 2009-06-11 12:37:20 -0400 (Thu, 11 Jun 2009)
New Revision: 6982

Modified:
   trunk/misc/tools/midi2cfg-ng.conf
   trunk/misc/tools/midi2cfg-ng.pl
Log:
more midi2cfg stuff :P


Modified: trunk/misc/tools/midi2cfg-ng.conf
===================================================================
--- trunk/misc/tools/midi2cfg-ng.conf	2009-06-11 11:48:25 UTC (rev 6981)
+++ trunk/misc/tools/midi2cfg-ng.conf	2009-06-11 16:37:20 UTC (rev 6982)
@@ -1,8 +1,10 @@
 bot tuba
-	count 0
+	channels 1 2 3 4 5 6 7 8 9 11 12 13 14 15 16
 	init
 		time -2
 		cmd selectweapon 16
+		raw g_balance_tuba_attenuation 0.1
+		raw g_balance_tuba_damage 0
 		time 0
 	note on -18
 		time -0.05
@@ -381,10 +383,345 @@
 		cmd cc "color 221"
 		super 
 
-bot red
+bot rocket
+	channels 10
+	init
+		time -2
+		cmd aimtarget "tPercussion 1"
+		cmd selectweapon 9
+		time 0
+	percussion 25
+		time 0
+		buttons attack2
+		time 0.05
+		buttons
+		time 0.1
+		busy 1.0
+
+bot uzi
+	channels 10
+	init
+		time -2
+		cmd aimtarget "tPercussion 1"
+		cmd selectweapon 3
+		time 0
+	percussion 27
+		time 0
+		buttons attack2
+		time 0.05
+		buttons
+		time 0.1
+		busy 0.2
+	percussion 33
+		percussion 27
+	percussion 37
+		percussion 27
+
+bot crylink
+	channels 10
+	init
+		time -2
+		cmd aimtarget "tPercussion 1"
+		cmd selectweapon 6
+		time 0
+	percussion 31
+		time 0
+		buttons attack2
+		time 0.05
+		buttons
+		time 0.1
+		busy 0.5
+	percussion 34
+		percussion 31
+	percussion 42
+		time 0
+		buttons attack2
+		time 0.05
+		buttons
+		time 0.1
+		busy 0.4
+	percussion 44
+		percussion 42
+	percussion 46
+		percussion 42
+
+bot jetpack
+	percussion 42
+		time 0
+		buttons hook
+		time 0.05
+		buttons
+		time 0.1
+	percussion 44
+		percussion 42
+	percussion 46
+		percussion 42
+
+bot jump
+	percussion 42
+		time -0.5
+		buttons jump
+		time -0.45
+		buttons
+		time 0
+	percussion 44
+		percussion 42
+	percussion 46
+		percussion 42
+
+bot hagar
+	channels 10
+	init
+		time -2
+		cmd aimtarget "tPercussion 1"
+		cmd selectweapon 8
+		raw g_balance_hagar_primary_lifetime 0.1
+		time 0
+	percussion 35
+		time 0
+		buttons attack1
+		time 0.05
+		buttons
+		time 0.1
+		busy 0.15
+	percussion 38
+		percussion 35
+	percussion 40
+		percussion 35
+	percussion 60
+		percussion 35
+	percussion 65
+		percussion 35
+
+bot tag
+	channels 10
+	init
+		time -2
+		cmd aimtarget "tPercussion 1"
+		cmd selectweapon 14
+		raw g_balance_seeker_tag_lifetime 0.1
+		time 0
+	percussion 36
+		time 0
+		buttons attack1
+		time 0.05
+		buttons
+		time 0.1
+		busy 0.7
+	percussion 61
+		percussion 36
+	percussion 66
+		percussion 36
+
+bot laser
+	channels 10
+	init
+		time -2
+		cmd aimtarget "tPercussion 1"
+		cmd selectweapon 1
+		raw g_balance_laser_primary_lifetime 0.2
+		time 0
+	percussion 39
+		time 0
+		buttons attack1
+		time 0.05
+		buttons
+		time 0.1
+		busy 0.7
+
+bot electro
+	channels 10
+	init
+		time -2
+		cmd aimtarget "tPercussion 1"
+		cmd selectweapon 5
+		time 0
+
+bot hook
+	channels 10
+	init
+		time -2
+		cmd aimtarget "tPercussion 1"
+		cmd selectweapon 12
+		time 0
+	percussion 58
+		time 0
+		buttons attack1
+		time 0.05
+		buttons
+		time 0.1
+		busy 0
+
+# instantiate our bots!
+
+bot tuba1
 	include tuba_red
-	count 256
+	count 1
+	init
+		time -15
+		cmd movetotarget tUba1
+		super
+	done
+		cmd movetotarget goaway1
 
-bot blue
+bot tuba2
 	include tuba_blue
-	count 256
+	count 1
+	init
+		time -15
+		cmd movetotarget tUba2
+		super
+	done
+		cmd movetotarget goaway1
+
+bot tuba3
+	include tuba_red
+	count 1
+	init
+		time -15
+		cmd movetotarget tUba3
+		super
+	done
+		cmd movetotarget goaway1
+
+bot tuba4
+	include tuba_red
+	count 1
+	init
+		time -15
+		cmd movetotarget tUba4
+		super
+	done
+		cmd movetotarget goaway1
+
+# percussion bots:
+
+bot chair11
+	include rocket
+	count 1
+	init
+		time -15
+		cmd movetotarget tChr11
+		super
+	done
+		cmd movetotarget goaway2
+
+bot chair12
+	include electro
+	count 1
+	init
+		time -15
+		cmd movetotarget tChr12
+		super
+	done
+		cmd movetotarget goaway2
+
+bot chair21
+	include uzi
+	count 1
+	init
+		time -15
+		cmd movetotarget tChr21
+		super
+	done
+		cmd movetotarget goaway2
+
+bot chair22
+	include crylink
+	count 0
+	init
+		time -15
+		cmd movetotarget tChr22
+		super
+	done
+		cmd movetotarget goaway2
+
+bot chair23
+	include crylink
+	count 0
+	init
+		time -15
+		cmd movetotarget tChr22
+		super
+	done
+		cmd movetotarget goaway2
+
+bot chair23
+	include hagar
+	count 1
+	init
+		time -15
+		cmd movetotarget tChr23
+		super
+	done
+		cmd movetotarget goaway2
+
+bot chair31
+	include tag
+	count 1
+	init
+		time -15
+		cmd movetotarget tChr31
+		super
+	done
+		cmd movetotarget goaway2
+
+bot chair32
+	include tag
+	count 1
+	init
+		time -15
+		cmd movetotarget tChr32
+		super
+	done
+		cmd movetotarget goaway2
+
+bot chair33
+	include laser
+	count 1
+	init
+		time -15
+		cmd movetotarget tChr33
+		super
+	done
+		cmd movetotarget goaway2
+
+bot chair41
+	include hook
+	count 1
+	init
+		time -15
+		cmd movetotarget tChr41
+		super
+	done
+		cmd movetotarget goaway2
+
+bot chair42
+	include jetpack
+	count 1
+	init
+		time -15
+		cmd movetotarget tChr42
+		super
+	done
+		cmd movetotarget goaway2
+
+bot chair43
+	include jetpack
+	count 1
+	init
+		time -15
+		cmd movetotarget tChr43
+		super
+	done
+		cmd movetotarget goaway2
+
+bot chair44
+	include jetpack
+	count 1
+	init
+		time -15
+		cmd movetotarget tChr44
+		super
+	done
+		cmd movetotarget goaway2

Modified: trunk/misc/tools/midi2cfg-ng.pl
===================================================================
--- trunk/misc/tools/midi2cfg-ng.pl	2009-06-11 11:48:25 UTC (rev 6981)
+++ trunk/misc/tools/midi2cfg-ng.pl	2009-06-11 16:37:20 UTC (rev 6982)
@@ -13,7 +13,9 @@
 use constant MIDI_FIRST_NONCHANNEL => 17;
 use constant MIDI_DRUMS_CHANNEL => 10;
 
-my ($filename, $transpose, $timeoffset, $timeoffset2, @preallocate) = @ARGV;
+die "Usage: $0 filename.mid transpose timeoffset timeoffset2 timeoffset3 preallocatedbots..."
+	unless @ARGV >= 5;
+my ($filename, $transpose, $timeoffset, $timeoffset2, $timeoffset3, @preallocate) = @ARGV;
 
 my $opus = MIDI::Opus->new({from_file => $filename});
 #$opus->write_to_file("/tmp/y.mid");
@@ -102,8 +104,13 @@
 			my @cmd = split /\s+/, $_;
 			if($cmd[0] eq 'super')
 			{
-				push @$appendref, @$super;
+				push @$appendref, @$super
+					if $super;
 			}
+			elsif($cmd[0] eq 'percussion') # simple import
+			{
+				push @$appendref, @{$currentbot->{percussion}->{$cmd[1]}};
+			}
 			else
 			{
 				push @$appendref, \@cmd;
@@ -144,6 +151,11 @@
 				$super = $currentbot->{init};
 				$currentbot->{init} = $appendref = [];
 			}
+			elsif(/^done$/)
+			{
+				$super = $currentbot->{done};
+				$currentbot->{done} = $appendref = [];
+			}
 			elsif(/^note on (-?\d+)/)
 			{
 				$super = $currentbot->{notes_on}->{$1};
@@ -166,7 +178,7 @@
 		}
 		elsif(/^bot (.*)/)
 		{
-			$currentbot = ($bots{$1} ||= {});
+			$currentbot = ($bots{$1} ||= {count => 0, transpose => 0});
 		}
 		else
 		{
@@ -280,6 +292,10 @@
 		{
 			printf "sv_cmd bot_cmd %d %s\n", $bot->{id}, join " ", @{$_}[1..@$_-1];
 		}
+		elsif($_->[0] eq 'raw')
+		{
+			printf join " ", @{$_}[1..@$_-1];
+		}
 	}
 
 	return 1;
@@ -300,21 +316,25 @@
 {
 	my ($bot, $time, $channel, $note, $init) = @_;
 	return -1 # I won't play on this channel
-		if defined $bot->{channels} and not grep { $_ == $channel } $bot->{channels};
+		if defined $bot->{channels} and not $bot->{channels}->{$channel};
 	return 0
 		if $bot->{busy};
-	my $cmds = $bot->{notes_on}->{$note - $bot->{transpose} - $transpose};
-	my $cmds_off = $bot->{notes_off}->{$note - $bot->{transpose} - $transpose};
-	if(defined $cmds_off)
+	my $cmds;
+	if($channel == 10)
 	{
-		$bot->{busy} = 1;
+		$cmds = $bot->{percussion}->{$note};
 	}
-	if(not defined $cmds)
+	else
 	{
-		$cmds = $bot->{percussion}->{$note};
-		return -1 # I won't play this note
-			if not defined $cmds;
+		$cmds = $bot->{notes_on}->{$note - $bot->{transpose} - $transpose};
+		my $cmds_off = $bot->{notes_off}->{$note - $bot->{transpose} - $transpose};
+		if(defined $cmds and defined $cmds_off)
+		{
+			$bot->{busy} = 1;
+		}
 	}
+	return -1 # I won't play this note
+		if not defined $cmds;
 	if($init && $bot->{init})
 	{
 		return 0
@@ -341,6 +361,9 @@
 {
 	my ($time, $channel, $note) = @_;
 
+	return 0
+		if $channel == 10;
+
 	if(my $bot = $notechannelbots{$channel}{$note})
 	{
 		busybot_note_off_bot $bot, $time, $channel, $note;
@@ -395,9 +418,7 @@
 
 	if($overflow)
 	{
-		warn "Not enough bots to play this";
-		use Data::Dumper;
-		print STDERR Dumper \@busybots_allocated;
+		warn "Not enough bots to play this (when playing $channel:$note)";
 	}
 	else
 	{
@@ -428,17 +449,18 @@
 my $note_min = undef;
 my $note_max = undef;
 my $notes_stuck = 0;
+my $t = 0;
 for(@allmidievents)
 {
-	my $t = tick2sec $_->[1];
+	$t = tick2sec $_->[1];
 	my $track = $_->[3];
 	if($_->[0] eq 'note_on')
 	{
 		my $chan = $_->[4] + 1;
 		$note_min = $_->[5]
-			if not defined $note_min or $_->[5] < $note_min;
+			if not defined $note_min or $_->[5] < $note_min and $chan != 10;
 		$note_max = $_->[5]
-			if not defined $note_max or $_->[5] > $note_max;
+			if not defined $note_max or $_->[5] > $note_max and $chan != 10;
 		if($midinotes{$chan}{$_->[5]})
 		{
 			--$notes_stuck;
@@ -460,6 +482,14 @@
 	}
 }
 
+for(@busybots_allocated)
+{
+	if($_->{done})
+	{
+		busybot_cmd_bot_execute $_, $notetime + $t + $timeoffset3, @{$_->{done}};
+	}
+}
+
 print STDERR "Range of notes: $note_min .. $note_max\n";
 print STDERR "Safe transpose range: @{[$note_max - 19]} .. @{[$note_min + 13]}\n";
 print STDERR "Unsafe transpose range: @{[$note_max - 27]} .. @{[$note_min + 18]}\n";



More information about the nexuiz-commits mailing list