snipehud + opts code

Evita
03-05-2004, 03:28 AM
reformatting, installing linux, bbl.

here is some code for whoever cares:

snipehud: (you will need to add/modify the events at the bottom to work with whatever you have)

$zoompower[1] = 2;
$zoompower[2] = 5;
$zoompower[3] = 10;
$zoompower[4] = 20;
$zoompower[5] = 50;
$zoompower[6] = 100;
$zoompower[7] = 250;

$snipehud::index = 2;
$zoompower = 5;

function snipehud::add()
{
if($snipehud::exist)
return;

%extentx = $screenx / 3;
%extenty = $screeny / 3;

%zoomx = -($screenx * $zoompower) / 2 + (%extentx / 2);
%zoomy = -($screeny * $zoompower) / 2 + (%extenty / 2);

$SnipeHud::Container = newObject(SnipeHud::frame , SimGui::Control, 2, 2, %extentx, %extenty);
$SnipeHud::BG = newObject("SnipeHud::bg", FearGui::FearGuiMenu, -2, -2, %extentx+5, %extenty+5);
$SnipeHud::view = newObject(SnipeHud::view, SimGui::TSControl, %zoomx, %zoomy, $screenx * $zoompower, $screeny * $zoompower);
$SnipeHud::xhair = newObject(SnipeHud::xhair , FearGui::Crosshair, 0, 0, 1, 1);

addToSet($SnipeHud::Conta iner, $SnipeHud::bg);
addToSet($SnipeHud::Conta iner, $SnipeHud::view);
addToSet($SnipeHud::Conta iner, $SnipeHud::xhair);
addToSet(playgui, $SnipeHud::Container);

control::setvisible(Snipe Hud::frame, false);

$snipehud::exist = true;
}

function snipehud::remove()
{
removeFromSet(playgui, $SnipeHud::Container);
deleteObject($SnipeHud::C ontainer);

$snipehud::exist = false;
}

function snipehud::show()
{
if(getMountedItem(0) == 22)
{
sense(2);
control::setvisible(Snipe Hud::frame, true);
}
else
{
sense(15);
control::setvisible(Snipe Hud::frame, false);
}
}

function snipehud::delay()
{
schedule("snipehud::show();", 0.5);
}

function snipehud::cycle()
{
$snipehud::index++;

if($zoompower[$snipehud::index] == "")
$snipehud::index = 1;

$zoompower = $zoompower[$snipehud::index];

removeFromSet($SnipeHud:: Container, $SnipeHud::view);
removeFromSet($SnipeHud:: Container, $SnipeHud::xhair);

%extentx = $screenx / 3;
%extenty = $screeny / 3;

%zoomx = -($screenx * $zoompower) / 2 + (%extentx / 2);
%zoomy = -($screeny * $zoompower) / 2 + (%extenty / 2);

$SnipeHud::view = newObject(SnipeHud::view, SimGui::TSControl, %zoomx, %zoomy, $screenx * $zoompower, $screeny * $zoompower);
$SnipeHud::xhair = newObject(SnipeHud::xhair , FearGui::Crosshair, 0, 0, 1, 1);
addToSet($SnipeHud::Conta iner, $SnipeHud::view);
addToSet($SnipeHud::Conta iner, $SnipeHud::xhair);
}

editActionMap("playMap.sae");
bindCommand(keyboard0, make, "j", TO, "snipehud::cycle();");

Event::Attach(eventPlayGu iOpen, snipehud::add);
Event::Attach(eventPlayGu iClose, snipehud::remove);
Event::Attach(eventExit, snipehud::remove);
Event::Attach(eventNextWe apon, snipehud::delay);
Event::Attach(eventPrevWe apon, snipehud::delay);


here is $screen function(me) and sense function (random) needed for snipehud:

function ScreenRes::GuiOpen()
{
%scr = $pref::VideoFullScreenRes ;
%idx = String::FindSubStr(%scr,"x");
$ScreenX = String::GetSubStr(%scr,0, %idx);
$ScreenY = String::GetSubStr(%scr,%i dx+1,5);
}

function ScreenRes::Init()
{
%scr = $pref::VideoFullScreenRes ;
%idx = String::FindSubStr(%scr,"x");
$ScreenX = String::GetSubStr(%scr,0, %idx);
$ScreenY = String::GetSubStr(%scr,%i dx+1,5);
}

Event::Attach(eventPlayGu iOpen, ScreenRes::GuiOpen);

ScreenRes::Init();

function sense(%amount)
{
if(%amount != "")
{
%sense = %amount / 5000;
editActionMap("playMap.sae");
bindAction(mouse, xaxis, TO, IDACTION_YAW, scale, %sense, flip);

if(Client::getMouseYAxisF lip("playMap.sae") == "TRUE")
bindAction(mouse, yaxis, TO, IDACTION_PITCH, scale, %sense);
else
bindAction(mouse, yaxis, TO, IDACTION_PITCH, scale, %sense, flip);
}

echo("Current sensitivity is " @ floor(Client::getMouseSen sitivity("playMap.sae") * 5000 + 1) @ ".");
}


here is opts code, you still need to create opts manually:

function ScriptsGui::ScriptSelect( )
{
%objects = $ScriptsGuiObjects[$ScriptPage];
ScriptsGui::ClosePage($Sc riptPage, %objects);

$ScriptPage = FGCombo::getSelectedText( ScriptsList);

%objects = $ScriptsGuiObjects[$ScriptPage];
ScriptsGui::OpenPage($Scr iptPage, %objects);

echo("Loaded Script Page: " @ $ScriptPage);
}

function ScriptsGui::OpenPage(%pag e, %objects)
{
if(%page == "")
return;

for(%i=0; %i<=%objects; %i++)
{
%objname = %page @ %i;
control::setvisible(%objn ame, true);
}
}

function ScriptsGui::ClosePage(%pa ge, %objects)
{
if(%page == "")
return;

for(%i=0; %i<=%objects; %i++)
{
%objname = %page @ %i;
control::setvisible(%objn ame, false);
}
}

function ScriptsGui::HideAll()
{
for(%i=1; $ScriptsGuiPage[%i] != ""; %i++)
{
%page = $ScriptsGuiPage[%i];
%objects = $ScriptsGuiObjects[%page];
ScriptsGui::ClosePage(%pa ge, %objects);
}
}

function ScriptsGui::Register(%pag e, %objects)
{
$pageCount++;

$ScriptsGuiPage[$pageCount] = %page;
$ScriptsGuiObjects[%page] = %objects;
}

function OptionsGui::onOpen()
{
IRCOptions::init();
OptionsMovement::init();
OptionsVideo::init();
OptionsGraphics::init();
OptionsNetwork::init();
OptionsSound::init();

// Scripts Gui gets initialized when Options Gui opens for the first time.
if(!$ScriptListLoaded)
{
for(%i=0; $ScriptsFrameID == ""; %i++)
{
if(Object::GetName(%i) == "ScriptsFrame")
$ScriptsFrameID = %i;
}

//Here is where you add scripts to the combo box in the
//script opts gui. The first parameter (ScriptsList) never
//changes. The second parameter (ie, "ski") is the name that
//will appear in the combo list. The third parameter is the
//order in which the second parameter(s) appear in the list (in reverse).
fgcombo::addentry(Scripts List, "ski", 1);
fgcombo::addentry(Scripts List, "invy spew", 2);
fgcombo::addentry(Scripts List, "max throw", 3);
fgcombo::addentry(Scripts List, "demo drop", 4);
fgcombo::addentry(Scripts List, "pref page 1", 5);

//This section registers each 'page' with the Scripts Gui.
//This lets Scripts Gui know how many pages there are, the
//name of each page, and how many objects are associated
//with each page. The first parameter is the name of the
//script page, while the second parameter is how many objects
//are associated with that script page. (ie, the invy spew
//page has five config buttons).
ScriptsGui::Register("ski", 1);
ScriptsGui::Register("invy spew", 5);
ScriptsGui::Register("max throw", 2);
ScriptsGui::Register("demo drop", 2);
ScriptsGui::Register("pref page 1", 10);
ScriptsGui::HideAll();
}

$ScriptListLoaded = "true";
}

function OptionsGui::onClose()
{
IRCOptions::Shutdown();
OptionsNetwork::shutdown( );
}

Mr. Hated
03-06-2004, 03:16 AM
reminds me of the good ol days

UniX
03-06-2004, 10:38 AM
How is it on the fps?

eskimofo
03-06-2004, 11:43 AM
shes a doosey. :bananasex