midi2cfg: support for VOCALS!

This commit is contained in:
Rudolf Polzer 2011-09-18 19:52:28 +02:00
parent 6bf10fe484
commit 5df11ddcb6
2 changed files with 102 additions and 36 deletions

View File

@ -406,6 +406,8 @@ bot uzi
percussion 27
percussion 54 # 054_Tombourine-0.wav
percussion 27
percussion 36 # 036_Kick_2-0.wav
percussion 27
# grenadelauncher = RELOADSOUND RELOADSOUND
@ -552,7 +554,7 @@ bot hook
percussion 63 # 063_Conga_High_2_Open-0.wav
percussion 62
# seeker is rocket tag
# seeker is BADFLYSOUND tag
bot seeker
channels 10
init
@ -561,13 +563,6 @@ bot seeker
cmd barrier
cmd selectweapon 18
cmd wait 0.5
percussion 51 # 051_Cymbal_Ride_1-0.wav
time 0
buttons attack1
time 0.05
buttons
time 0.1
busy 0.25
percussion 41 # 041_Tom_Low_2-0.wav
time 0
buttons attack2
@ -575,10 +570,14 @@ bot seeker
buttons
time 0.1
busy 0.75
percussion 51 # 051_Cymbal_Ride_1-0.wav
percussion 41
percussion 43 # 043_Tom_Low_1-0.wav
percussion 41
percussion 59 # 059_Cymbal_Ride_2-0.wav
percussion 51
percussion 41
percussion 46 # 046_Hi-Hat_Open-0.wav
percussion 41
# rifle is hard soft
bot rifle
@ -606,9 +605,11 @@ bot rifle
bot jetpack
init
cmd resetaim
time -2
cmd aimtarget "tPercussion 1"
cmd barrier
cmd console "g_jetpack_attenuation 0.5"
cmd wait 0.5
percussion 42 # 042_Hi-Hat_Closed-0.wav
time 0
buttons hook
@ -617,19 +618,26 @@ bot jetpack
time 0.1
percussion 32 # 032_Square_Click-0.wav
percussion 42
percussion 36 # 036_Kick_2-0.wav
percussion 42
percussion 44 # 044_Hi-Hat_Pedal-0.wav
percussion 42
percussion 46 # 046_Hi-Hat_Open-0.wav
time 0
buttons hook
time 0.134
buttons
time 0.2
percussion 64 # 064_Conga_Low-0.wav
percussion 42
bot vocals
init
time -2
cmd aimtarget "tPercussion 1"
cmd barrier
cmd wait 0.5
vocals
time 0
cmd sound %s
buttons left
time 0.06666
buttons right
time 0.13333
buttons
bot common
done
cmd resetaim
@ -669,7 +677,7 @@ bot instance_tuba_blue
bot instance_laser
include laser
include common
count 12
count 16
init
cmd movetotarget @places_percussion
cmd barrier
@ -678,7 +686,7 @@ bot instance_laser
bot instance_shotgun
include shotgun
include common
count 2
count 16
init
cmd movetotarget @places_percussion
cmd barrier
@ -687,7 +695,7 @@ bot instance_shotgun
bot instance_uzi
include uzi
include common
count 4
count 16
init
cmd movetotarget @places_percussion
cmd barrier
@ -695,7 +703,8 @@ bot instance_uzi
bot instance_electro
include electro
count 2
include common
count 16
init
cmd movetotarget @places_percussion
cmd barrier
@ -704,7 +713,7 @@ bot instance_electro
bot instance_crylink
include crylink
include common
count 4
count 16
init
cmd movetotarget @places_percussion
cmd barrier
@ -713,7 +722,7 @@ bot instance_crylink
bot instance_nex
include rocket
include common
count 2
count 16
init
cmd movetotarget @places_percussion
cmd barrier
@ -722,7 +731,7 @@ bot instance_nex
bot instance_minstanex
include rocket
include common
count 2
count 16
init
cmd movetotarget @places_percussion
cmd barrier
@ -731,7 +740,7 @@ bot instance_minstanex
bot instance_hagar
include hagar
include common
count 8
count 16
init
cmd movetotarget @places_percussion
cmd barrier
@ -740,7 +749,7 @@ bot instance_hagar
bot instance_rocket
include rocket
include common
count 4
count 16
init
cmd movetotarget @places_percussion
cmd barrier
@ -748,7 +757,8 @@ bot instance_rocket
bot instance_hook
include hook
count 4
include common
count 16
init
cmd movetotarget @places_percussion
cmd barrier
@ -756,7 +766,8 @@ bot instance_hook
bot instance_seeker
include seeker
count 4
include common
count 16
init
cmd movetotarget @places_percussion
cmd barrier
@ -765,7 +776,7 @@ bot instance_seeker
bot instance_rifle
include rifle
include common
count 2
count 16
init
cmd movetotarget @places_percussion
cmd barrier
@ -774,10 +785,20 @@ bot instance_rifle
bot instance_jetpack
include jetpack
include common
count 2
count 16
init
cmd movetotarget @places_percussion
cmd barrier
super
bot instance_vocals
include vocals
include common
count 1
init
cmd cc "playermodel models/player/suiseiseki.zym"
cmd movetotarget @places_percussion
cmd barrier
super
# TODO jumping?

View File

@ -8,6 +8,7 @@ use MIDI;
use MIDI::Opus;
use Storable;
use constant SYS_TICRATE => 0.033333;
use constant MIDI_FIRST_NONCHANNEL => 17;
use constant MIDI_DRUMS_CHANNEL => 10;
@ -144,6 +145,11 @@ sub botconfig_read($)
$super = $currentbot->{percussion}->{$1};
$currentbot->{percussion}->{$1} = $appendref = [];
}
elsif(/^vocals$/)
{
$super = $currentbot->{vocals};
$currentbot->{vocals} = $appendref = [];
}
else
{
print "unknown command: $_\n";
@ -185,12 +191,12 @@ sub busybot_cmd_bot_test($$@)
my $botbusytime = defined $bot->{busytimer} ? $bot->{busytimer} : -1;
return 0
if $time < $botbusytime;
if $time < $botbusytime + SYS_TICRATE;
my $mintime = (@commands && ($commands[0]->[0] eq 'time')) ? $commands[0]->[1] : 0;
return 0
if $time + $mintime < $bottime;
if $time + $mintime < $bottime + SYS_TICRATE;
return 1;
}
@ -288,13 +294,25 @@ sub busybot_note_on_bot($$$$$)
if defined $bot->{channels} and not $bot->{channels}->{$channel};
my $cmds;
my $cmds_off;
if($channel == 10)
if($channel <= 0)
{
# vocals
$cmds = $bot->{vocals};
$cmds_off = undef;
if(defined $cmds)
{
$cmds = [ map { [ map { $_ eq '%s' ? $note : $_ } @$_ ] } @$cmds ];
}
}
elsif($channel == 10)
{
# percussion
$cmds = $bot->{percussion}->{$note};
$cmds_off = undef;
}
else
{
# music
$cmds = $bot->{notes_on}->{$note - ($bot->{transpose} || 0) - $transpose};
$cmds_off = $bot->{notes_off}->{$note - ($bot->{transpose} || 0) - $transpose};
}
@ -348,6 +366,8 @@ sub busybot_note_off($$$)
#print STDERR "note off $time:$channel:$note\n";
return 0
if $channel <= 0;
return 0
if $channel == 10;
@ -498,6 +518,31 @@ sub ConvertMIDI($$)
push @allmidievents, [$command, $tick, $sequence++, $track, @data];
}
}
if(open my $fh, "$filename.vocals")
{
my $scale = 1;
my $shift = 0;
for(<$fh>)
{
chomp;
my ($tick, $file) = split /\s+/, $_;
if($tick eq 'scale')
{
$scale = $file;
}
elsif($tick eq 'shift')
{
$shift = $file;
}
else
{
push @allmidievents, ['note_on', $tick * $scale + $shift, $sequence++, -1, -1, $file];
push @allmidievents, ['note_off', $tick * $scale + $shift, $sequence++, -1, -1, $file];
}
}
}
@allmidievents = sort { $a->[1] <=> $b->[1] or $a->[2] <=> $b->[2] } @allmidievents;
my %midinotes = ();
@ -513,9 +558,9 @@ sub ConvertMIDI($$)
{
my $chan = $_->[4] + 1;
$note_min = $_->[5]
if not defined $note_min or $_->[5] < $note_min and $chan != 10;
if $chan != 10 and $chan > 0 and (not defined $note_min or $_->[5] < $note_min);
$note_max = $_->[5]
if not defined $note_max or $_->[5] > $note_max and $chan != 10;
if $chan != 10 and $chan > 0 and (not defined $note_max or $_->[5] > $note_max);
if($midinotes{$chan}{$_->[5]})
{
--$notes_stuck;