//======================================================================================= // One key pack - by Mental Trousers as part of the Tribes scripting documents at // http://planetstarsiege.com/mt/ //======================================================================================= // // I used to get sick of having to change to the repair pack and then holding the fire // key down, so I wrote this. Lazy I know, but I prefer this to doing it manually as I // can type or something while I'm repairing stuff. There are disadvantages to using this // however. The main one is that if you miss target you want to repair, it will switch // back to your previous weapon even though you may not want it to. Ocassionally, the // right amount of lag at just the right time will cause the game to miss the fact that // you wanted to swap packs before firing, causing damage to you and anyone near you. // This is very rare though. // // Part of this script is activated by pressing a key, while other parts are activated by // messages that appear on the chat screen. The key causes the current weapon you're // using to be replaced with the repair gun, which is then activated. When the repair is // finished, the weapon you were using before is remounted. If the repair is totally // finished, a message is sent to the rest of your team telling them what you have fixed. // If you stop half way through a repair, theres a 5 second delay before announcing a // partial repair. It doesn't tell people when you've fixed a vehicle or another person // because thats just stupid. // // As well as automatically activating the repair gun etc, this script also finds the // correct place for deployable backpacks. It does this by trying to deploy the backpack, // and then catching the two messages "Deploy position out of range" and "Unable to // deploy - You're in the way", adjusting where you are looking up or down depending on // which message is received. Finding a suitable spot to deploy can be cancelled by // simply pressing the backpack key again. // // The third feature of this script is when you pick up a back pack or have a pack that // can not be deployed or activated, the player view will zoom out to the 3rd person // perspective briefly, before zooming back in to the usual first person. I used to find // that I would pick up a pack without noticing (normally during a fight) and then I // would try to pick up a pack later and wonder why I couldn't (you've probably seen a // number of people doing that, looks real funny :) // //======================================================================================= // Too activate anything using the keyboard/mouse/joystick or whatever, we have to bind // the function to a key. To do that we need to edit the appropriate "action map". There // are 3 of those, playMap.sae, actionMap.sae and pdaMap.sae EditActionMap("playMap.sae"); bindCommand(keyboard0, make, "v", TO, "oneKeyPack::toggleWeapon ();"); $catchDeployMessages=False; // controls whether or not to find the right spot $previousWeapon=21; // set the default weapon as the Disc Launcher //======================================================================================= // There is a 5 second delay before this is announced. If you start repairing anything at // all before that 5 seconds is up, the announcement will not be made ie if you // accidentally stop repairing something and then continue again, we don't want to // announce it repeatedly, that's just annoying //======================================================================================= function oneKeyPack::announcePartialRepair () { // echo ("function oneKeyPack::announcePartialRepair ()"); //check to make sure the message is valid if ($announcePartialRepair&&$repairingItem!="") say (1,"Partial repairs completed on "@$repairingItem); // set to invalid $announcePartialRepair=False; return; } //======================================================================================= // Catches all of the repair messages and does something with them. :) //======================================================================================= function oneKeyPack::catchRepairMessage (%msg) { // echo ("function oneKeyPack::catchRepairMessage (%msg)"); // catch the repair messages if (Match::String(%msg,"*Repairing*")) { // extract the name of what is being repaired if (Match::ParamString (%msg, "Repairing %i")) $repairingItem=Match::Result(i); // check that the item isn't a player or a vehicle if (getClientByName($repairingItem)!=0) $repairingItem=""; else if ($repairingItem=="Scout"||$repairingItem=="LPC"||$repairingItem=="HPC") $repairingItem=""; return; } // catch message for a completed repair if (Match::String (%msg,"*Repair Done*")) { // make sure message will be valid and then send message if ($repairingItem!="") say (1, "Repairs completed on "@$repairingItem); // change back to previous weapon oneKeyPack::toggleWeapon (); } // catch message for a partial repair else if(Match::String (%msg,"*Repair Stopped*")) { // wait 5 seconds to see if we continue repairs schedule ("oneKeyPack::announcePartialRepair ();",5); $announcePartialRepair=True; // change back to previous weapon oneKeyPack::toggleWeapon (); } // catch self repairing message else if (Match::String (%msg,"*AutoRepair Off*")) // change back to previous weapon oneKeyPack::toggleWeapon (); //somelse is repairing us so tank him after a slight delay else if (Match::paramString(%msg, "Being repaired by %p")) { %thanks="say (1, 'Thanks "@Match::Result(p)@"');"; schedule (%Thanks,3); } return; } //======================================================================================= // If you're carrying the repair pack, this one swaps to it, does the repair and then // automatically swaps back to the last weapon. Otherwise it just activates the pack // you're carrying //======================================================================================= function oneKeyPack::toggleWeapon () { // echo ("function oneKeyPack::toggleWeapon ()"); // cancel the automatic deploy spot locating function if ($catchDeployMessages) { $catchDeployMessages=False; use("Backpack"); return; } if (getItemCount ("Repair Pack")==1) { if (getMountedItem(0)!=getItemType("Repair Gun")) { $previousWeapon=getMountedItem(0); use ("Repair Pack"); schedule ("postAction(2048, IDACTION_FIRE1, 1.0000);",0.2); $announcePartialRepair=False; } else if (getMountedItem(0)==getItemType("Repair Gun")) { postAction(2048, IDACTION_BREAK1, -0); useItem ($previousWeapon); } } else if (getItemCount ("Energy Pack")==1 || getItemCount ("Ammo Pack")==1) oneKeyPack::checkBackPack (); else if (getMountedItem(1)==-1) oneKeyPack::checkBackPack (); else { $catchDeployMessages=True; schedule ("$catchDeployMessages=False;", 5); use("Backpack"); } return; } //======================================================================================= // Finds the right spot for deploying a back pack //======================================================================================= function oneKeyPack::findDeploySpot (%instr) { // echo ("function oneKeyPack::findDeploySpot (%instr)"); if (!$catchDeployMessages) return; if (%instr=="LookDown") { postAction (2048, IDACTION_PITCH, -0.03); schedule ("use (\"Backpack\");", 0.1); return mute; } else if (%instr=="LookUp") { postAction (2048, IDACTION_PITCH, 0.02); schedule ("use (\"Backpack\");", 0.1); return mute; } return; } //======================================================================================= // Zooms out to show you whats on your back, then zooms back in again //======================================================================================= function oneKeyPack::checkBackPack () { // echo ("function oneKeyPack::checkBackPack ()"); postAction (2048, IDACTION_VIEW, -0); schedule ("postAction (2048, IDACTION_VIEW, -0);", 0.3); return; } //======================================================================================= // This is where everything is caught :) //======================================================================================= function oneKeyPack::clientMessage (%client, %msg) { // echo ("function oneKeyPack::clientMessage (%client, %msg)"); if (Match::String (%msg, "*You received a * backpack")) oneKeyPack::checkBackPack (); else if (String::findSubStr(%msg,"Nothing in range")!=-1 || String::findSubStr(%msg,"not damaged")!=-1) oneKeyPack::toggleWeapon (); else if (String::findSubStr(%msg,"epair")!=-1) oneKeyPack::catchRepairMessage (%msg); else if (Match::String (%msg, "Deploy position out of range")) oneKeyPack::findDeploySpot ("LookDown"); else if (Match::String (%msg, "Unable to deploy - You're in the way")) oneKeyPack::findDeploySpot ("LookUp"); else if (Match::String (%msg, "*deployed*")) $catchDeployMessages=False; return; } Event::Attach(eventClientMessage, oneKeyPack::clientMessage, %client, %msg);