// /=---------------------------------------------------------------------=[ R a d i o . c f g ]
// | Info: this file contains all the real code. It's broken up into sections, which have
// | further notes so you can understand what's going on... =)  
// |=---------------------------------------------------------=( B i n d i n g   A l i a s e s )
// | These commands just unbind the keys which change function, and then bind them back to the
// | variable action#, which changes depending on the state of the radio power and bank.

alias unbind-keypad "unbind kp_end;unbind kp_downarrow;unbind kp_pgdn;unbind-keypad2"
alias unbind-keypad2 "unbind kp_leftarrow;unbind kp_5;unbind kp_rightarrow;unbind-keypad3"
alias unbind-keypad3 "unbind kp_home;unbind kp_uparrow;unbind kp_pgup;unbind kp_del"

alias bind-keypad "bind kp_end $action1;bind kp_downarrow $action2;bind kp_pgdn $action3;bind-keypad2"
alias bind-keypad2 "bind kp_leftarrow $action4;bind kp_5 $action5;bind kp_rightarrow $action6;bind-keypad3"
alias bind-keypad3 "bind kp_home $action7;bind kp_uparrow $action8;bind kp_pgup $action9;bind kp_del $action0"

// |=-------------------------------------------=( S e t   b a n k   a c t i o n   v a l u e s )
// | These are just aliases to group together the set of command needed to change the variable
// | action#, which changes the function of the key bound. Also, each sets the value of an 
// | alias for switching either the radio power or bank, and state - the third preserves the
// | state of the keypad in case one of the modifier aliases are called. This makes sure they 
// | return to the exact original use. A handy little message telling you the state of the 
// | radio is also echoed back to the screen.

alias radio-bankA "set action1 radio-bankA-message1;set action2 radio-bankA-message2;radio-bankA2"
alias radio-bankA2 "set action3 radio-bankA-message3;set action4 radio-bankA-message4;radio-bankA3"
alias radio-bankA3 "set action5 radio-bankA-message5;set action6 radio-bankA-message6;radio-bankA4"
alias radio-bankA4 "set action7 radio-bankA-message7;set action8 radio-bankA-message8;radio-bankA5"
alias radio-bankA5 "set action9 radio-bankA-message9;set action0 radio-bankA-message0;radio-bankA6"
alias radio-bankA6 "echo Radio set to Defence;alias power message-bankA;alias state radio-bankA;alias toggle radio-bankB"

alias radio-bankB "set action1 radio-bankB-message1;set action2 radio-bankB-message2;radio-bankB2"
alias radio-bankB2 "set action3 radio-bankB-message3;set action4 radio-bankB-message4;radio-bankB3"
alias radio-bankB3 "set action5 radio-bankB-message5;set action6 radio-bankB-message6;radio-bankB4"
alias radio-bankB4 "set action7 radio-bankB-message7;set action8 radio-bankB-message8;radio-bankB5"
alias radio-bankB5 "set action9 radio-bankB-message9;set action0 radio-bankB-message0;radio-bankB6"
alias radio-bankB6 "echo Radio set to Offence;alias power message-bankB;alias state radio-bankB;alias toggle radio-bankA"

alias message-bankA "set action1 message-bankA-message1;set action2 message-bankA-message2;message-bankA2"
alias message-bankA2 "set action3 message-bankA-message3;set action4 message-bankA-message4;message-bankA3"
alias message-bankA3 "set action5 message-bankA-message5;set action6 message-bankA-message6;message-bankA4"
alias message-bankA4 "set action7 message-bankA-message7;set action8 message-bankA-message8;message-bankA5"
alias message-bankA5 "set action9 message-bankA-message9;set action0 message-bankA-message0;message-bankA6"
alias message-bankA6 "echo Message set to Defence;alias power radio-bankA;alias state message-bankA;alias toggle message-bankB"

alias message-bankB "set action1 message-bankB-message1;set action2 message-bankB-message2;message-bankB2"
alias message-bankB2 "set action3 message-bankB-message3;set action4 message-bankB-message4;message-bankB3"
alias message-bankB3 "set action5 message-bankB-message5;set action6 message-bankB-message6;message-bankB4"
alias message-bankB4 "set action7 message-bankB-message7;set action8 message-bankB-message8;message-bankB5"
alias message-bankB5 "set action9 message-bankB-message9;set action0 message-bankB-message0;message-bankB6"
alias message-bankB6 "echo Message set to Offence;alias power radio-bankB;alias state message-bankB;alias toggle message-bankA"

// |=---------------------------------------------------=( S e t   m e s s a g e   v a l u e s )
// | This sets up aliases for the Affirmative/Negative messages: the variables are set by the 
// | class config, so they play the class-specific radio sound. It also executes the 
// | messages.cfg file, which sets the values for all the other messages - it had to be 
// | separated in order to get past the size problem... for some reason anything bigger than 
// | 8kb and Quake II gets uppity... =)

alias radio-affirmative "wfteamplay $affirmative;say_team Affirmative!"
alias radio-negative "wfteamplay $negative;say_team Negative!"

exec messages.cfg

// |=---------------------------------------------------=( C l a s s   C h a n g e   A l i a s )
// | Sets up the keypad to change class instead of executing a radio function - uses the same
// | action# variable.

alias class-values "set action1 recon;set action2 nurse;set action3 engineer;class-values2"
alias class-values2 "set action4 marine;set action5 cyborg;set action6 arsonist;class-values3"
alias class-values3 "set action7 gunner;set action8 sniper;set action9 spy;class-values4"
alias class-values4 "set action0 mercenary"

// |=---------------------------------------------------------=( C o m m a n d   A l i a s e s )
// | Set up the commands used to control the script - radio power (an on/off toggle), bank 
// | switching, and class change (this originally backed up the previous values used and then
// | restored them - a better way, I found, was to set a state alias which was then set in the
// | bank action values to be identical to the name of the bank). Have a look at the code and
// | you'll see it's more streamlined...

alias radio-power-on "unbind-keypad;power;bind-keypad;echo Radio On;alias radio-power radio-power-off;play noise.wav"
alias radio-power-off "unbind-keypad;power;bind-keypad;echo Radio Off;alias radio-power radio-power-on;play noise.wav"
alias radio-power "radio-power-on"

alias radio-switch "unbind-keypad;toggle;bind-keypad;play bleep.wav"

alias +class-change "unbind-keypad;class-values;bind-keypad;echo Class select on"
alias -class-change "unbind-keypad;state;bind-keypad;echo Class select off"

// |=-------------------------------------------=( I n i t i a l   R a d i o   S e t t i n g s )
// | The state of the radio when the script is first run. By default, this is set to offence,
// | with the radio off.


// |=---------------------------------------------------------------=( K e y p a d   B i n d s )
// | Binds the keys to the commands on the keypad.

bind kp_ins "radio-power"
bind kp_enter "radio-switch"
bind kp_slash "radio-affirmative"
bind * "radio-negative"
bind kp_plus "+class-change"

// \=-----------------------------------------------------------------=[ E n d   O f   F i l e ]