// #autoload // #name = Tink Shock + Disc // #version = 1.0a // #date = 1/7/02 // #author = [GC]-Tinker Bear | -M2-Tink // #warrior = Tinker Bear // #email = Tinker@tribes-universe.net // #web = http://hosted.tribes-universe.com // #description = When you use the shocklance, it will switch to the spinfusor for easy kill =] // #status = Beta // #category = Tinks-Scripts // #include = support/callback.cs // #include = support/key_callbacks.cs // #include = support/loadout.cs if(!isObject(SSwitch)) { new scriptobject (SSwitch) { class = SSwitch; version = "1.0a"; }; // set enabled pref if the var is empty if($pref::SSwitch::Enabled $= "") $pref::SSwitch::Enabled = true; } // called when the toggle key is pressed and when it is released // %val : true/false (pressed/released) function SSwitchToggle(%val) { // only exec this code on key press, not release if(!%val) return; // toggle the enabled pref $pref::SSwitch::Enabled = !$pref::SSwitch::Enabled; // add or delete callbacks as needed SSwitch.setup($pref::SSwitch::Enabled); // play a soft beep alxPlay(sButtonOver,0,0,0); // print some info into the chat hud if($pref::SSwitch::Enabled) addMessageHudLine("\c2Shock + Disc enabled."); //$elfswitchtoggle = true; else addMessageHudLine("\c2Shock + Disc disabled."); // $elfswitchtoggle = false; } // START package ElfSwitch package SSwitch { // override - allows us to add the toggle key to the controls list function OptionsDlg::onWake(%this) { // check if the bind has already been added if (!SSwitch.bind) { $RemapName[$RemapCount]="Tink-Shock Toggle"; $RemapCmd[$RemapCount]="SSwitchToggle"; $RemapCount++; // signify we have added the bind to the list, to avoid adding it multiple times SSwitch.bind = true; } parent::onWake( %this ); } function SSwitch::setup(%this, %val) { if(%val) { callback.add(MouseFirePressed, "SSwitch.mouseFire"); callback.add(MouseFireReleased, "SSwitch.mouseFire"); } else { callback.delete(MouseFirePressed, "SSwitch.mouseFire"); callback.delete(MouseFireReleased, "SSwitch.mouseFire"); } } function SSwitch::mouseFire(%this, %state) { if(%state) %this.active = loadout.getCurrentWeapon() $= "Shocklance"; else { if(%this.active) use(disc); } } }; activatePackage(SSwitch); // add mouse fire callbacks if script is enabled SSwitch.setup($pref::SSwitch::Enabled);