// ***** BEGIN LICENSE BLOCK ***** 
// Version: MPL 1.1/GPL 2.0/LGPL 2.1 
// 
// The contents of this file are subject to the Mozilla Public License Version 
// 1.1 (the "License"); you may not use this file except in compliance with 
// the License. You may obtain a copy of the License at 
// http://www.mozilla.org/MPL/ 
// 
// Software distributed under the License is distributed on an "AS IS" basis, 
// WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 
// for the specific language governing rights and limitations under the 
// License. 
// 
// The Original Code is the toekk.org QuakeWorld timer script. 
// 
// The Initial Developer of the Original Code is 
// Alexander Ahern - toekk at toekk dot org. 
// Portions created by the Initial Developer are Copyright (C) 2005 
// the Initial Developer. All Rights Reserved. 
// 
// Contributor(s): 
// 
// Alternatively, the contents of this file may be used under the terms of 
// either the GNU General Public License Version 2 or later (the "GPL"), or 
// the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 
// in which case the provisions of the GPL or the LGPL are applicable instead 
// of those above. If you wish to allow use of your version of this file only 
// under the terms of either the GPL or the LGPL, and not to allow others to 
// use your version of this file under the terms of the MPL, indicate your 
// decision by deleting the provisions above and replace them with the notice 
// and other provisions required by the GPL or the LGPL. If you do not delete 
// the provisions above, a recipient may use your version of this file under 
// the terms of any one of the MPL, the GPL or the LGPL. 
// 
// ***** END LICENSE BLOCK ***** 

// $Id: teamtime.cfg,v 1.1 2006-04-20 18:49:00 johnnycz Exp $ 

// Bindings: 
// The variables "__kt_X" indicate the keys you should bind. 
// __kt_reset - resets the timer, if you make a mistake entering a time. 
// __kt_spam - tell your teammates the time on the currently selected timer. 
// __kt_nudgeup   - increment current item's time by 1. 
// __kt_nudgedown - you can guess! 
// __kt_zero/one... - typically these are the the numeric keypad. 

// Installation: 
// Put the timer.cfg in your quakeworld/id1 directory, and then place 
// "exec timer.cfg" in your config somewhere. This will bind all the 
// keys and set your timers to zero. The script will not be much use unless 
// you also set "cl_gameclock 1" in your config! 

// Usage: 
// At the moment, the timer only records quad, rl, pent, ra and ya times. 
// To enter a time, first select the item you wish to record: 
// 1: yellow armour 
// 2: red armour 
// 4: quad 
// 6: pent 
// 7: rocket launcher 
// Then type the time you took the item. As an example, suppose we collect rl 
// on 47 seconds. Type "7", "4", "7" and the script will report that the next 
// rl is on 17. 
// 
// (these instructions assume you have the standard numeric keypad bindings) 

// Customisation: 
// To change your message, the alias __kt_spam can be redefined. 

// Contact: 
// The author, toekk, can usually be found on QuakeNet IRC, 
// channel #knockback. 
// JohnNy_cz, 1.13->1.13j updater - #qw.cz

set __kt_reset      "kp_enter" 
set __kt_spam      "kp_star" 
set __kt_nudgeup    "kp_plus" 
set __kt_nudgedown    "kp_minus" 
set __kt_zero       "kp_0" 
set __kt_one       "kp_1" 
set __kt_two       "kp_2" 
set __kt_three       "kp_3" 
set __kt_four       "kp_4" 
set __kt_five       "kp_5" 
set __kt_six       "kp_6" 
set __kt_seven       "kp_7" 
set __kt_eight       "kp_8" 
set __kt_nine       "kp_9" 

set __t_quad       "00" 
set __t_rl       "00" 
set __t_pent       "00" 
set __t_ra      "00" 
set __t_ya      "00" 

set __t_tens      0 
set __t_units      0 
set __t_item      0 
set __t_tmp      0 

// Save the temporary time __t_tmp into the correct item's time 
alias _t_save      "if $qt,$__t_item,$qt isin $qt,quad,rl,pent,ya,ra,$qt then set __t_$__t_item $__t_tmp" 

// Load the selected item's time into the temporary time __t_tmp 
alias _t_load      "if $qt,$__t_item,$qt isin $qt,quad,rl,pent,ya,ra,$qt then _t_load$__t_item" 
alias _t_loadquad   "set __t_tmp $__t_quad" 
alias _t_loadrl      "set __t_tmp $__t_rl" 
alias _t_loadpent   "set __t_tmp $__t_pent" 
alias _t_loadra      "set __t_tmp $__t_ra" 
alias _t_loadya      "set __t_tmp $__t_ya" 

// Show the current time as an echo 
alias _t_echo      "echo $__t_item on $__t_tmp" 

// Spam the current time 
alias _t_spam      "say_team $\$nick $__t_item $__t_tmp; _t_bindselect" 

// Panic button to stop setting a time if you make a mistake 
alias _t_reset      "bf; echo reset - selection mode; _t_bindselect" 

// Select item to set/report it's time 
alias _ts_ya      "echo yellow selected; _t_save; set __t_item ya; _t_load; _t_bindtens;" 
alias _ts_ra      "echo red selected; _t_save; set __t_item ra; _t_load; _t_bindtens;" 
alias _ts_quad      "echo quad selected; _t_save; set __t_item quad; _t_load; _t_bindtens" 
alias _ts_rl      "echo rl selected; _t_save; set __t_item rl; _t_load; _t_bindtens" 
alias _ts_pent      "echo pent selected; _t_save; set __t_item pent; _t_load; _t_bindtens" 

// Bind all the keys to item selection 
alias _t_bindselect   "unbind $__kt_zero; bind $__kt_one _ts_ya; bind $__kt_two _ts_ra; unbind $__kt_three; bind $__kt_four _ts_quad; unbind $__kt_five; bind $__kt_six _ts_pent; bind $__kt_seven _ts_rl; unbind $__kt_eight; unbind $__kt_nine;" 

// Bind all the keys to unit selection 
alias _t_bindunits   "bind $__kt_zero _tu_zero; bind $__kt_one _tu_one; bind $__kt_two _tu_two; bind $__kt_three _tu_three; bind $__kt_four _tu_four; bind $__kt_five _tu_five; bind $__kt_six _tu_six; bind $__kt_seven _tu_seven; bind $__kt_eight _tu_eight; bind $__kt_nine _tu_nine" 

// Bind keys to tens selection 
alias _t_bindtens   "bind $__kt_zero _tt_zero; bind $__kt_one _tt_one; bind $__kt_two _tt_two; bind $__kt_three _tt_three; bind $__kt_four _tt_four; bind $__kt_five _tt_five; unbind $__kt_six; unbind $__kt_seven; unbind $__kt_eight; unbind $__kt_nine" 

// Take a weapon, this adds 30 seconds 
// this works for any gameclock settings the same - JohnNy_cz
alias _t_weapon    "inc __t_tmp 30; if $__t_tmp >= 60 then inc __t_tmp -60; _t_pad" 

// Take an armour, this adds 20 seconds 
// <JohnNy_cz>
alias _t_armour      "if $cl_gameclock == 1 _t_armour_cw else if $cl_gameclock == 3 _t_armour_cw else _t_armour_ccw"
alias _t_armour_cw      "inc __t_tmp 20; if $__t_tmp >= 60 then inc __t_tmp -60; _t_pad" 
alias _t_armour_ccw      "inc __t_tmp -20; if $__t_tmp < 0 then inc __t_tmp 60; _t_pad"
// </JohnNy_cz>

// Pad with leading zeros 
alias _t_pad      "if $__t_tmp < 10 then set __t_tmp 0$__t_tmp" 

// Set the time 
alias _t_settime   "set __t_tmp $qt$__t_tens$__t_units$qt; if $__t_item == rl then _t_weapon else if $qt,$__t_item,$qt isin $qt,ra,ya,$qt then _t_armour" 
alias _t_nudgeup   "inc __t_tmp; if $__t_tmp >= 60 then inc __t_tmp -60; _t_pad; _t_echo" 
alias _t_nudgedown   "inc __t_tmp -1; if $__t_tmp < 0 then inc __t_tmp 60; _t_pad; _t_echo" 

// Units 
alias _tu_zero      "set __t_units 0; _t_settime; _t_spam; _t_bindselect" 
alias _tu_one      "set __t_units 1; _t_settime; _t_spam; _t_bindselect" 
alias _tu_two      "set __t_units 2; _t_settime; _t_spam; _t_bindselect" 
alias _tu_three      "set __t_units 3; _t_settime; _t_spam; _t_bindselect" 
alias _tu_four      "set __t_units 4; _t_settime; _t_spam; _t_bindselect" 
alias _tu_five      "set __t_units 5; _t_settime; _t_spam; _t_bindselect" 
alias _tu_six      "set __t_units 6; _t_settime; _t_spam; _t_bindselect" 
alias _tu_seven      "set __t_units 7; _t_settime; _t_spam; _t_bindselect" 
alias _tu_eight      "set __t_units 8; _t_settime; _t_spam; _t_bindselect" 
alias _tu_nine      "set __t_units 9; _t_settime; _t_spam; _t_bindselect" 

// Tens 
alias _tt_zero      "echo 0...; set __t_tens 0; _t_bindunits" 
alias _tt_one      "echo 1...; set __t_tens 1; _t_bindunits" 
alias _tt_two      "echo 2...; set __t_tens 2; _t_bindunits" 
alias _tt_three      "echo 3...; set __t_tens 3; _t_bindunits" 
alias _tt_four      "echo 4...; set __t_tens 4; _t_bindunits" 
alias _tt_five      "echo 5...; set __t_tens 5; _t_bindunits" 

// Setup 

_t_bindselect 
bind $__kt_reset    "_t_reset" 
bind $__kt_spam      "_t_spam" 
bind $__kt_nudgeup   "_t_nudgeup" 
bind $__kt_nudgedown   "_t_nudgedown" 

echo "timer.cfg $Revision: 1.1 $"