//======================================================================================= // Zoom - by Mental Trousers as part of the tutorial at http://www.planetstarsige.com/mt/ //======================================================================================= // // One day I decided that I should get to know how to use the sniper rifle. When I did // start to fool around with it I found that I was forgetting which level of // magnification I had left it at and often zoomed in way too much and couldn't see the // target anymore. Trying to remember to back it off manually was just a pain, as I'd // also forget to do that. Also, alot of guys don't like snipers (funny that :) so they // would often sneak up and slaughter me. Even when I spotted them coming I'd get done // because I had the wrong weapon ie the laser rifle. It really wasn't made for dueling // So this little lot came about. Now I'm still crap with the laser rifle but at least I // go down with a fight. // // We have to keep count of how many times the magnification level is incremented, as // there is no way to reset to a specific magnificatin level. There are only 4 levels // ie 2x, 5x, 10x, 20x. // //======================================================================================= //bind the keys. These ones replace your current zoom and magnification keys. //lshift = zoom //numpad9 = magnification (actually the button on my mouse wheel) EditActionMap("playMap.sae"); bindCommand(keyboard0, make, "lshift", TO, "zoom::zoomInAndSwap ();"); bindCommand(keyboard0, break, "lshift", TO, "zoom::zoomOutAndSwap ();"); bindCommand(keyboard0, make, control, "lshift", TO, "zoom::reset();"); bindCommand(keyboard0, make, "numpad9", TO, "zoom::zoomIn ();"); //tribes defaults to 5x at startup $zoomAmount=1; //======================================================================================= // Swaps to the Laser Rifle when you zoom in. //======================================================================================= function zoom::zoomInAndSwap () { // echo ("function zoom::zoomInAndSwap ()"); //activate sniper view postAction (2048, IDACTION_SNIPER_FOV, 1.000000); //check to see if you've got the laser and mount it if you have if (getItemCount ("Laser Rifle")==1) { if (getMountedItem(0)!=getItemType("Laser Rifle")) { //remember which weapon was used last $previousWeapon=getMountedItem(0); use ("Laser Rifle"); } } return; } //======================================================================================= // Swaps back to the weapon you had before the above function was called //======================================================================================= function zoom::zoomOutAndSwap () { // echo ("function zoom::zoomOutAndSwap ()"); //switch off sniper view postAction (2048, IDACTION_SNIPER_FOV, 0.000000); //only swap if we've got the sniper rifle if (getItemCount ("Laser Rifle")==1) { //and make sure it's mounted, if so, remount the previous weapon if (getMountedItem(0)==getItemType("Laser Rifle")) useItem ($previousWeapon); } //back off the magnification level to 2x zoom::backTo2x (); return; } //======================================================================================= // Backs the zoom level out to 2x //======================================================================================= function zoom::backTo2x () { //zoom out for (%i=0;%i<$zoomAmount;%i++) postAction (2048, IDACTION_INC_SNIPER_FOV, -1.0000); //zero the counter zoom::reset (); } //======================================================================================= // Zooms and and keeps track of the zoom multiplier //======================================================================================= function zoom::zoomIn () { //increase the magnification level and the counter postAction (2048, IDACTION_INC_SNIPER_FOV, 1.0000); $zoomAmount++; //magnification goes back to 2x after 20x which is a count of 3 if ($zoomAmount>=4) $zoomAmount=0; } //======================================================================================= // Reset the zoom multiplier //======================================================================================= function zoom::reset () { $zoomAmount=0; }