mirror of
https://github.com/Ragora/T2-BoL.git
synced 2026-03-02 12:03:41 +00:00
Brought up to date with the newest T2BoL I've located
This commit is contained in:
parent
8c96cba3e1
commit
accd31895e
287 changed files with 108557 additions and 107608 deletions
6
scripts/modscripts/AICharacter.cs
Normal file
6
scripts/modscripts/AICharacter.cs
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// AICharacter.cs
|
||||
// Copyright (c) 2011 DarkDragonDX
|
||||
//=============================================================================
|
||||
|
||||
|
||||
334
scripts/modscripts/client/RPGBrowserGui.cs
Normal file
334
scripts/modscripts/client/RPGBrowserGui.cs
Normal file
|
|
@ -0,0 +1,334 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// Scripts/RPGBrowserGUI.cs
|
||||
// One of the highlights of T2Bol.
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function RPGBrowserGui::onWake(%this)
|
||||
{
|
||||
if (RPGBrowserGui.pane $= "")
|
||||
RPG_NewsPane.onActivate();
|
||||
|
||||
LaunchTabView.viewTab( "MOD BROWSER", RPGBrowserGui, 0 );
|
||||
Canvas.pushDialog( LaunchToolbarDlg );
|
||||
|
||||
// This is essentially an "isInitialized" flag...
|
||||
if ( RPG_TabView.tabCount() == 0 )
|
||||
{
|
||||
RPG_TabView.addSet(1, "gui/shll_horztabbuttonB", "5 5 5", "50 50 0", "5 5 5" );
|
||||
RPG_TabView.addTab(1,"NEWS",1);
|
||||
RPG_TabView.setSelected( 1 );
|
||||
RPG_TabView.addTab(2,"ENCYCLOPEDIA");
|
||||
RPG_TabView.addTab(3,"DOWNLOADS");
|
||||
RPG_TabView.setTabActive(3,0);
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function RPGBrowserGui::onSleep(%this)
|
||||
{
|
||||
%ctrl = "RPG_" @ %this.pane @ "Pane";
|
||||
if ( isObject( %ctrl ) )
|
||||
%ctrl.onDeactivate();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function BrowserDoSave() //A good ol' converter for browser files. Should work on ANY browser file. Including ones that you insert yourself.
|
||||
{
|
||||
%file = new fileObject();
|
||||
%item = RPG_ItemList.getValue();
|
||||
%category = RPG_Category.getValue();
|
||||
%file.openForWrite("savedDocs/" @ %item @ ".txt");
|
||||
%read = new fileObject();
|
||||
%read.openForRead("Data/Browser/" @ %category @ "/" @ %item @ ".txt");
|
||||
|
||||
%skip = false;
|
||||
while (!%read.isEOF())
|
||||
{
|
||||
%line = %read.readLine();
|
||||
%lineTest = strLwr(strReplace(%line," ","")); //strip spaces to test for tags to skip
|
||||
%spush = getSubStr(%lineTest,0,7);
|
||||
%just = getSubStr(%lineTest,0,6);
|
||||
|
||||
//Ok.. we need to cipher out some useless information before we're through
|
||||
if (%just !$= "<just:")
|
||||
{
|
||||
if (%spush $= "<spush>")
|
||||
%skip = true;
|
||||
|
||||
if (%skip == true) //Try to find our <spop> tag
|
||||
{
|
||||
%search = strStr(%lineTest,"<spop>");
|
||||
if (%search != -1)
|
||||
%skip = false; //We found our <spop> tag, set %skip to false for the next turn
|
||||
}
|
||||
else //Otherwise the data is safe -- but we still got to look for my special <a:select> tag
|
||||
{
|
||||
%select = strStr(%lineTest,"<a:select");
|
||||
if (%select != -1) //It exists -- we must convert it
|
||||
{
|
||||
%line = strReplace(%line,"-","\t"); //Apparently special tags don't work when read from a file, so the negative sign represents \t
|
||||
%tag = strStr(%line,"<a:select"); //Find the position of my select tag
|
||||
if (%tag != -1) //Ok, it exists. We need to grab our entire tag as a string
|
||||
{
|
||||
%start = strStr(%line,"<");
|
||||
|
||||
for (%i = 0; %i < strLen(%line); %i++)
|
||||
{
|
||||
%testC = getSubStr(%line, %i + %start, 3);
|
||||
if (%testC $= "</a")
|
||||
{
|
||||
%end = %i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (%line !$= "") //If the line is totally blank, don't do shit. Otherwise, attempt to space out the file (for easier read)
|
||||
{
|
||||
for (%i = 0; %i < strLen(%line); %i++) //Was up a little higher in the function; figured it should be moved down here
|
||||
{
|
||||
%test = getSubStr(%line,%i,9);
|
||||
if (%test $= "<a:select") //We found a select tag.
|
||||
{
|
||||
%start = %i;
|
||||
%end = strLen(%line) - strStr(%line,"</a>") - 3;
|
||||
%test = getSubStr(%line,%start,%end);
|
||||
%str = getWord(%test,0);
|
||||
%line = strReplace(%line,%str,getNameFromSelectTag(%str));
|
||||
}
|
||||
}
|
||||
for (%i = 0; %i < strLen(%line); %i++)
|
||||
{
|
||||
%sub = getSubStr(%line, %i, 1);
|
||||
if (%sub $= ".") //Ok, we found a period. %i is where we are in the string. So we grab everything up until this period and move on
|
||||
{
|
||||
%file.writeLine(getSubStr(%line, 0, %i+1));
|
||||
%line = getSubStr(%line, %i+1, strLen(%line));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//Detach our file objects (scripts/fileProcessing.cs)
|
||||
%file.detach();
|
||||
%read.detach();
|
||||
|
||||
messageBoxOk("SUCCESS","The contents of item "@%item@" in category "@%category@" have been saved. Check your mod Directory's sub-dir, /savedDocs for "@%item@".txt."); //YES! After all that the file should be good.
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function getNameFromSelectTag(%string) //Since the tag should be directly inserted, there is no start.
|
||||
{
|
||||
%len = strLen(%string);
|
||||
|
||||
%start = strStr(%string,">");
|
||||
%end = strStr(%string,"</a>");
|
||||
%sub = getSubStr(%string,%start,%end);
|
||||
%sub = stripTrailingSpaces(stripChars(strReplace(%sub,"</a>",""),">"));
|
||||
return %sub;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function RPGBrowserGui::setKey( %this, %key )
|
||||
{
|
||||
// To avoid console error
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function RPGBrowserGui::onClose( %this, %key )
|
||||
{
|
||||
// To avoid console error
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// News pane:
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function RPG_NewsPane::onActivate(%this)
|
||||
{
|
||||
RPGBrowserGui.pane = "News";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function RPG_NewsPane::onDeactivate(%this)
|
||||
{
|
||||
//RPGBrowserGui.pane = "News";
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Browser pane:
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function RPG_BrowserPane::onActivate(%this)
|
||||
{
|
||||
RPGBrowserGui.pane = "Browser";
|
||||
RPG_Category.PopulateList();
|
||||
|
||||
//Make sure our DL button is properly placed (resolution may have changed)
|
||||
RPG_DownloadButton.setPosition("5", getWord(Canvas.getExtent(), 1) - 163);
|
||||
|
||||
RPG_BrowserPane.refresh();
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function RPG_BrowserPane::Refresh(%this,%val)
|
||||
{
|
||||
//Ok, we must make the browser dynamic for convenience.
|
||||
%text = RPG_Category.getText();
|
||||
|
||||
if (%text $= "Select Category" || %text $= "")
|
||||
return RPG_Text.readFromFile("Data/Browser/Introduction.txt");
|
||||
|
||||
RPG_ItemList.clear();
|
||||
|
||||
%path = "Data/Game/" @ %text @ "/*.des";
|
||||
%count = 0;
|
||||
for( %file = findFirstFile( %path ); %file !$= ""; %file = findNextFile( %path ) )
|
||||
{
|
||||
%name = getFileNameFromString(strReplace(%file,".des","")); //Get the fileName from our string (used in the item List)
|
||||
if (%name !$= "Introduction")
|
||||
{
|
||||
RPG_ItemList.addRow(%count, %name);
|
||||
%count++;
|
||||
}
|
||||
}
|
||||
RPG_ItemList.sortNumerical(0,0); //Sort the items from A-Z
|
||||
//RPG_ItemList.setSelectedRow(RPG_ItemList.findTextIndex($Browser::SelectedText));
|
||||
RPG_ItemList.setSelectedRow(RPGBrowserGUI.selectedID[%text]);
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
function RPG_BrowserPane::onDeactivate(%this)
|
||||
{
|
||||
//RPGBrowserGui.pane = "Browser";
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Downloads pane:
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function RPG_DownloadsPane::onActivate(%this)
|
||||
{
|
||||
RPGBrowserGui.pane = "Downloads";
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function RPG_DownloadsPane::onDeactivate(%this)
|
||||
{
|
||||
//RPGBrowserGui.pane = "Downloads";
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function RPG_TabView::onSelect( %this, %id, %text )
|
||||
{
|
||||
RPG_BrowserPane.setVisible( %id == 2 );
|
||||
RPG_NewsPane.setVisible( %id == 1 );
|
||||
|
||||
%ctrl = "RPG_" @ RPGBrowserGui.pane @ "Pane";
|
||||
if ( isObject( %ctrl ) )
|
||||
%ctrl.onDeactivate();
|
||||
|
||||
switch ( %id )
|
||||
{
|
||||
case 1: // News
|
||||
RPG_NewsPane.onActivate();
|
||||
case 2: // Encyclopedia
|
||||
RPG_BrowserPane.onActivate();
|
||||
case 3: // Downloads
|
||||
RPG_DownloadsPane.onActivate();
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function RPG_Category::PopulateList() //Listing is now alphabatized
|
||||
{
|
||||
RPG_Category.clear();
|
||||
|
||||
%file = "Data/Game/encyclopediaData.txt";
|
||||
|
||||
%count = getBlockData(%file,"Encyclopedia",1,"categoryCount");
|
||||
RPG_Category.count = %count;
|
||||
|
||||
for (%i = 0; %i < %count; %i++)
|
||||
{
|
||||
%category = getBlockData(%file,"Encyclopedia",1,"category" @ %i);
|
||||
RPG_Category.add(%category,%i);
|
||||
}
|
||||
|
||||
if (RPG_Category.selected !$= "") //Fixes the category dropdown resetting
|
||||
RPG_Category.setSelected(RPG_Category.selected);
|
||||
else
|
||||
RPG_Category.setValue("Select Category");
|
||||
//Force the browser to have an introduction.
|
||||
RPG_Text.readFromFile("Data/Game/Encyclopedia_Intro.des");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function RPG_Category::onSelect(%this, %id, %text)
|
||||
{
|
||||
RPG_ItemList.clear();
|
||||
RPG_Text.setValue("");
|
||||
RPG_Category.selected = %id;
|
||||
RPG_Text.readFromFile("Data/Game/" @ %text @ "/Introduction.des"); //Display the intro for the category we selected
|
||||
RPG_BrowserPane.refresh();
|
||||
if (RPG_ItemList.getSelectedID() == -1) //Does our button really need to be inactive?
|
||||
RPG_DownloadButton.setActive(false); //YES!
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function RPG_ItemList::onSelect(%this, %id, %text)
|
||||
{
|
||||
$Browser::SelectedText = %text;
|
||||
RPG_DownloadButton.setActive(true);
|
||||
%category = RPG_Category.getvalue();
|
||||
RPGBrowserGUI.selectedID[%category] = %id;
|
||||
RPG_Text.readFromFile("Data/Game/" @ %category @ "/" @ %text @ ".des");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function RPG_Text::readFromFile(%this,%file)
|
||||
{
|
||||
RPG_Text.setValue(""); //Clear the info, for some odd reason .clear() won't work..
|
||||
|
||||
if (!IsFile(%file))
|
||||
return -1;
|
||||
|
||||
%fileobj = new FileObject();
|
||||
%fileobj.openForRead(%file);
|
||||
|
||||
while (!%fileobj.isEOF())
|
||||
{
|
||||
%line = %fileobj.readLine() @ "\n";
|
||||
RPG_Text.addText(%line,1);
|
||||
}
|
||||
%fileobj.detach();
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
RPG_DownloadButton.setActive(false); //Eh.. for some reason setting isActive in the GUI file isn't working
|
||||
97
scripts/modscripts/client/clientFunctions.cs
Normal file
97
scripts/modscripts/client/clientFunctions.cs
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// Scripts/DO_NOT_DELETE/clientFunctions.cs (OPEN SOURCE)
|
||||
// If you see this text, you have obtained the official copy of this file from
|
||||
// one of the developers. Otherwise, your decompiler is so advanced that it can
|
||||
// somehow get commented lines in a script. If this is not the case, someone has
|
||||
// betrayed my trust.
|
||||
// -- Dark Dragon DX (as of 2011).
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//Different from modVersionText, is used to compare our mod to the update server
|
||||
//Since TribesNext will soon allow binary transfers, this is stored here.
|
||||
$ModVersion = 1.0; //Looks better as whole numbuhs
|
||||
|
||||
//All clientCmds are secured here (so certain funcs can't simply just be disabled)
|
||||
//Although, hooks can be attached for custom actions.
|
||||
function clientCmdHandleScriptedCommand(%num,%arg1,%arg2,%arg3,%arg4)
|
||||
{
|
||||
switch(%num)
|
||||
{
|
||||
case 0: //Pop Dialog
|
||||
Canvas.popDialog(%arg1);
|
||||
case 1: //BoxYesNo
|
||||
messageBoxYesNo(%arg1,%arg2,%arg3,%arg4);
|
||||
case 2: //FadeIn
|
||||
ServerConnection.setBlackOut(true, %arg1);
|
||||
case 3: //Fadeout
|
||||
ServerConnection.setBlackOut(false, %arg1);
|
||||
case 4: //Show Cursor
|
||||
$cursorControlled = %arg1;
|
||||
lockMouse(%arg1);
|
||||
|
||||
if (%arg1)
|
||||
{
|
||||
Canvas.cursorOn();
|
||||
GlobalActionMap.bind(mouse, button0, RTS_LeftButton);
|
||||
GlobalActionMap.bind(mouse, button1, RTS_RightButton);
|
||||
RTS_Command.push();
|
||||
$RTS::ButtonPress = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Canvas.cursorOff();
|
||||
GlobalActionMap.unbind(mouse, button0);
|
||||
GlobalActionMap.unbind(mouse, button1);
|
||||
Canvas.setCursor(DefaultCursor);
|
||||
RTS_Command.pop();
|
||||
$RTS::ButtonPress = true;
|
||||
}
|
||||
case 5: //Verify Client
|
||||
if (%arg1)
|
||||
ScoreParent.settext("PDA - PERSONAL DATA ASSISTANT");
|
||||
$Pref::LANAccount::GUID = stripNonNumericCharacters($Pref::LANAccount::GUID); //Make sure the GUID is pure before sending. Monkee, you won't be breaking anything here. The server does the same on its side. :)
|
||||
//Let the server know we're an actual client.. and if we're offline, send my GUID
|
||||
if (!$PlayingOnline)
|
||||
commandToServer('VerifyClient',$Pref::LANAccount::GUID,$ModVersion);
|
||||
else
|
||||
commandToServer('VerifyClient',0,$ModVersion);
|
||||
//Turn off the 'continue' button if it's T2Bol.
|
||||
if (%arg2)
|
||||
DB_ContinueBTN.setActive(0);
|
||||
case 6: //Is RTS Game
|
||||
hudClusterBack.opacity = 0; //Make it invisible
|
||||
clientCmdHandleScriptedCommand(4,true); //Show our cursor
|
||||
case 7: //Music fadeout
|
||||
alxMusicFadeout($Pref::Audio::MusicVolume);
|
||||
case 8: //Music Fadein
|
||||
alxMusicFadein(0);
|
||||
case 9: //Set client Time
|
||||
clockHud.setVisible(0);
|
||||
%pos = ClockHud.getPosition();
|
||||
%x = getWord(%pos,0);
|
||||
%y = getWord(%pos,1);
|
||||
%x = %x - -14;
|
||||
%y = %y - -4;
|
||||
if (!IsObject(timeHud))
|
||||
{
|
||||
new GuiTextCtrl(timeHud)
|
||||
{
|
||||
profile ="ClockProfile";
|
||||
position = %x SPC %y;
|
||||
extent = "41 12";
|
||||
text = %arg1 SPC "Hrs";
|
||||
horizSizing = "left";
|
||||
vertSizing = "bottom";
|
||||
};
|
||||
playGui.add(timeHud);
|
||||
}
|
||||
|
||||
timeHud.setValue(%arg1);
|
||||
timeHud.setVisible(1);
|
||||
default: //If for some reason we got an invalid command ID, report it to console
|
||||
if ($Pref::DeveloperMode) //If dev mode is on (just a value set on the clientside to tell scripts to echo shit to the console)
|
||||
error("Scripted Command Handler: Received unknown command request ("@%num@") from server.");
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
9
scripts/modscripts/client/initialise.cs
Normal file
9
scripts/modscripts/client/initialise.cs
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// initialise.cs
|
||||
// Client Scripts Init
|
||||
// Copright (c) 2012 The DarkDragonDX
|
||||
//==============================================================================
|
||||
|
||||
exec("scripts/modScripts/client/clientFunctions.cs");
|
||||
exec("scripts/modScripts/client/serverRequestHandler.cs");
|
||||
exec("scripts/modScripts/client/RPGBrowserGUI.cs");
|
||||
7
scripts/modscripts/client/initialize.cs
Normal file
7
scripts/modscripts/client/initialize.cs
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// initialise.cs
|
||||
// Client Scripts Init
|
||||
// Copright (c) 2012 The DarkDragonDX
|
||||
//==============================================================================
|
||||
exec("scripts/modScripts/client/clientFunctions.cs");
|
||||
exec("scripts/modScripts/client/serverRequestHandler.cs");
|
||||
218
scripts/modscripts/client/serverRequestHandler.cs
Normal file
218
scripts/modscripts/client/serverRequestHandler.cs
Normal file
|
|
@ -0,0 +1,218 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// serverRequestHandler.cs
|
||||
// Server Request Handler
|
||||
// Copyright (c) 2012 The DarkDragonDX
|
||||
//==============================================================================
|
||||
|
||||
function InteractWithObject(%val)
|
||||
{
|
||||
}
|
||||
|
||||
function IcreaseRadioFrequency(%val)
|
||||
{
|
||||
}
|
||||
|
||||
function DecreaseRadioFrequency(%val)
|
||||
{
|
||||
}
|
||||
|
||||
//These are just here.. just in case.
|
||||
function OnLANPasswordInput()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
function OnLANNameInput()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
function clientCmdSetScoreText(%text)
|
||||
{
|
||||
ScoreParent.settext(%text);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
function alxMusicFadeout(%startvol)
|
||||
{
|
||||
%startvol = %startvol - 0.1;
|
||||
|
||||
if (%startvol <= 0)
|
||||
{
|
||||
alxstopmusic();
|
||||
alxsetmusicvolume($pref::audio::musicvolume);
|
||||
return;
|
||||
}
|
||||
alxsetmusicvolume(%startvol);
|
||||
schedule(500,0,"alxmusicfadeout",%startvol);
|
||||
return 1;
|
||||
}
|
||||
|
||||
function alxMusicFadein(%startvol)
|
||||
{
|
||||
%startvol = %startvol + 0.1;
|
||||
|
||||
if (%startvol > 1)
|
||||
{
|
||||
alxsetmusicvolume($pref::audio::musicvolume);
|
||||
return;
|
||||
}
|
||||
alxsetmusicvolume(%startvol);
|
||||
schedule(500,0,"alxmusicfadein",%startvol);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
function clientCmdAlxMusicFadeout()
|
||||
{
|
||||
alxmusicfadeout($pref::audio::musicvolume);
|
||||
return 1;
|
||||
}
|
||||
|
||||
function alxSetMusicVolume(%vol)
|
||||
{
|
||||
OP_MusicVolumeSlider.setvalue(%vol);
|
||||
return %vol;
|
||||
}
|
||||
|
||||
|
||||
|
||||
function reLightMission() {
|
||||
if ($SceneLighting::lightingProgress == 0 || $SceneLighting::lightingProgress == 1)
|
||||
lightScene("",forceAlways);
|
||||
}
|
||||
|
||||
function clientCmdReLightMission() {
|
||||
if (!$pref::disallowRelight)
|
||||
reLightMission();
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Client Hook
|
||||
// -----------------------------------------------------
|
||||
package clientMod{
|
||||
function DispatchLaunchMode()
|
||||
{
|
||||
parent::DispatchLaunchMode();
|
||||
|
||||
// check T2 command line arguments
|
||||
for(%i = 1; %i < $Game::argc ; %i++)
|
||||
{
|
||||
%arg = $Game::argv[%i];
|
||||
%nextArg = $Game::argv[%i+1];
|
||||
%hasNextArg = $Game::argc - %i > 1;
|
||||
|
||||
if( !stricmp(%arg, "-CleanDSO")) //Remove DSO's on shutdown
|
||||
{
|
||||
$CleanDSO = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Disconnect()
|
||||
{
|
||||
parent::Disconnect();
|
||||
|
||||
//Play the menu audio
|
||||
alxplaymusic("T2BOL/Music/Menu.mp3");
|
||||
alxMusicFadein(0);
|
||||
//Fix the score menu
|
||||
ScoreParent.settext("SCORE");
|
||||
//Enable continue
|
||||
DB_ContinueBTN.setActive(1);
|
||||
//Show other elements
|
||||
clockHud.setVisible(1);
|
||||
timeHud.setVisible(0);
|
||||
return 1;
|
||||
}
|
||||
|
||||
function OptionsDLG::OnSleep(%this)
|
||||
{
|
||||
parent::OnSleep(%this);
|
||||
|
||||
if ($pref::Audio::musicEnabled && !IsObject(ServerConnection))
|
||||
{
|
||||
alxplaymusic("T2BOL/Music/Menu.mp3");
|
||||
alxMusicFadein(0);
|
||||
}
|
||||
}
|
||||
|
||||
function GuiMLTextCtrl::onURL(%this, %url)
|
||||
{
|
||||
%url = strReplace(%url,"-","\t"); //Reading from files causes some funny issues..
|
||||
|
||||
switch$( getField(%url, 0) )
|
||||
{
|
||||
case "select":
|
||||
%cb = getField(%url, 1);
|
||||
|
||||
if(%cb $= "")
|
||||
return;
|
||||
|
||||
%i = 0;
|
||||
while((%p[%i] = getField(%url, %i + 2)) !$= "")
|
||||
%i++;
|
||||
|
||||
RPG_Category.setText(%cb); //Set the dropdown Text
|
||||
RPG_BrowserPane.refresh(); //Force a refresh
|
||||
|
||||
for (%i = 0; %i < RPG_ItemList.rowCount(); %i++)
|
||||
{
|
||||
%text = RPG_ItemList.getRowText(%i);
|
||||
|
||||
if (%text $= %p0)
|
||||
{
|
||||
RPG_ItemList.setSelectedRow(%i);
|
||||
break; //Tell the for loop to stop and continue executing
|
||||
}
|
||||
}
|
||||
//Now make our category select the correct row
|
||||
for (%i = 0; %i < RPG_Category.count; %i++)
|
||||
{
|
||||
%text = RPG_Category.getTextByID(%i);
|
||||
if (%text $= %cb)
|
||||
{
|
||||
RPG_Category.setSelected(%i);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
case "call": //Dunno if anybody will use this..
|
||||
%cb = getField(%url, 1);
|
||||
|
||||
if(%cb $= "")
|
||||
return;
|
||||
|
||||
%i = 0;
|
||||
while((%p[%i] = getField(%url, %i + 2)) !$= "")
|
||||
%i++;
|
||||
|
||||
call(%cb, %p0, %p1, %p2, %p3, %p4);
|
||||
|
||||
case "input": //Should only be used on the PDA.
|
||||
%cb = getField(%url, 1);
|
||||
|
||||
if(%cb $= "")
|
||||
return;
|
||||
|
||||
%i = 0;
|
||||
while((%p[%i] = getField(%url, %i + 2)) !$= "")
|
||||
%i++;
|
||||
|
||||
//%cb is our data type
|
||||
//%p0 is the text that shows up above the input box
|
||||
//%p1 is the text for the box itself
|
||||
InputText.setText(%p0);
|
||||
InputTransFrame.setText(%p1);
|
||||
Input.setValue("");
|
||||
canvas.pushDialog(InputDLG);
|
||||
$InputType = %cb;
|
||||
|
||||
default:
|
||||
Parent::onURL(%this, %url);
|
||||
}
|
||||
return;
|
||||
}
|
||||
};
|
||||
activatePackage(clientMod);
|
||||
1
scripts/modscripts/server/HTTP/ActivePlayers.cs
Normal file
1
scripts/modscripts/server/HTTP/ActivePlayers.cs
Normal file
|
|
@ -0,0 +1 @@
|
|||
//------------------------------------------------------------------------------
// ActivePlayers.cs
// .cs code listing currently active players
// Copyright (c) 2012 Robert MacGregor
//------------------------------------------------------------------------------
// Function that returns raw HTML formatting for the web browser on the client end to read
function ActivePlayers::contents(%this)
{
%data = "<head><title>T2BoL Webserver Testing | Active Players</title></head><body>" @
"<center>" @
"<font size=\x225\x22>Currently Active Players</font>" @
"<hr></br></br>" @
"<table border=\x225\x22 width=\x22500\x22>";
%data = %data @ "<tr><td><center>Name</center></td>";
%data = %data @ "<td><center>Species</center></td>";
%data = %data @ "<td><center>Gender</center></td></tr>";
for (%i = 0; %i < ClientGroup.getCount(); %i++)
{
%client = ClientGroup.getObject(%i);
%data = %data @ "<tr><td><center>" @ %client.namebase @ "</center></td>";
%data = %data @ "<td><center>" @ %client.race @ "</center></td>";
%data = %data @ "<td><center>" @ %client.sex @ "</center></td></tr>";
}
//"<tr>" @
//"<td><center><a href=\x22ActivePlayers.cs\x22>Active Players</a></center></td>" @
//"</tr>" @
%data = %data @ "</table>" @
"</body>";
return %data;
}
|
||||
21
scripts/modscripts/server/HTTP/Index.cs
Normal file
21
scripts/modscripts/server/HTTP/Index.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// Index.cs
|
||||
// Home page for the BoL inbuilt web server
|
||||
// Copyright (c) 2012 Robert MacGregor
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Function that returns raw HTML formatting for the web browser on the client end to read
|
||||
function Index::contents(%this)
|
||||
{
|
||||
%data = "<head><title>T2BoL Webserver Testing</title></head><body>" @
|
||||
"<center>" @
|
||||
"<font size=\x225\x22>Welcome! This is the testing index page!</font>" @
|
||||
"<hr></br></br>" @
|
||||
"<table border=\x225\x22 width=\x22200\x22>" @
|
||||
"<tr>" @
|
||||
"<td><center><a href=\x22ActivePlayers.cs\x22>Active Players</a></center></td>" @
|
||||
"</tr>" @
|
||||
"</table>" @
|
||||
"</body>";
|
||||
return %data;
|
||||
}
|
||||
0
scripts/modscripts/server/HTTP/PlayerDirectory.cs
Normal file
0
scripts/modscripts/server/HTTP/PlayerDirectory.cs
Normal file
336
scripts/modscripts/server/HTTPServer.cs
Normal file
336
scripts/modscripts/server/HTTPServer.cs
Normal file
|
|
@ -0,0 +1,336 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// HTTPServer.cs
|
||||
// An experimental HTTP Server written in Torque!
|
||||
// Copyright (c) 2012 Robert MacGregor
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Replicate Code for Servers
|
||||
$HTTPServer::ServerReplicate = "function *UNIQUESOCKET*::onConnectRequest(%this, %address, %socket)\n" @
|
||||
"{\n" @
|
||||
"%this.Parent.connectionCreated(%address, %socket);\n" @
|
||||
"return true;\n" @
|
||||
"}\n";
|
||||
// Replicate Code for Clients
|
||||
$HTTPServer::ClientReplicate = "function *UNIQUESOCKET*::onLine(%this, %line)\n" @
|
||||
"{\n" @
|
||||
"%this.Parent.onLine(%this, %line);\n" @
|
||||
"return true;\n" @
|
||||
"}\n" @
|
||||
"function *UNIQUESOCKET*::onDisconnect(%this) { %this.Parent.connectionDropped(%this); return true; }\n" @
|
||||
"function *UNIQUESOCKET*::sendPacket(%this,%packet)\n" @
|
||||
"{\n" @
|
||||
"%this.send(%packet.statusCode);\n" @
|
||||
"for (%i = 0; %i < %packet.headerCount; %i++)\n" @
|
||||
"{\n" @
|
||||
"%this.send(%packet.headers[%packet.headerName[%i]]);\n" @
|
||||
"}\n" @
|
||||
"%this.send(\"\\n\");\n" @
|
||||
"%this.send(%packet.payLoad);\n" @
|
||||
"%this.disconnect();\n" @
|
||||
"}\n";
|
||||
|
||||
function HTTPServer::listen(%this, %address, %port, %maxClients)
|
||||
{
|
||||
%uniqueNameLength = 6; // Adjust this if need be, but there should never be a reason to
|
||||
%this.allowMultiConnect = false; // If false, when a client connects twice, its old connection is killed and replaced with a new one.
|
||||
if (%this.isListening)
|
||||
return false;
|
||||
if (%maxClients < 1 || %maxClients == 0)
|
||||
%maxClients = 8;
|
||||
%oldAddr = $Host::BindAddress;
|
||||
%address = strlwr(%address);
|
||||
if (%address $= "local" || %address $="localhost" ) %address = "127.0.0.1";
|
||||
else if (%address $= "any") %address = "0.0.0.0";
|
||||
|
||||
%charList = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
// Generate A name for a TCPObject (and make sure it's unique)
|
||||
%uniqueStringLen = 6; // Adjust this if needed, but there shouldn't be a reason to
|
||||
%uniqueString = "";
|
||||
while (true)
|
||||
{
|
||||
%uniqueString = generateString(%uniqueNameLength, %charList);
|
||||
if (!isObject(%uniqueString)) break;
|
||||
else %uniqueString = "";
|
||||
}
|
||||
%evalCode = $HTTPServer::ServerReplicate;
|
||||
%evalCode = strReplace(%evalCode, "*UNIQUESOCKET*", %uniqueString);
|
||||
eval(%evalCode);
|
||||
|
||||
// Generate a list of unique names that this TCPServer will use (to keep down function def count)
|
||||
for (%i = 0; %i < %maxClients; %i++)
|
||||
while (true)
|
||||
{
|
||||
%uniqueName = generateString(%uniqueNameLength, %charList);
|
||||
if (!isObject(%uniqueName))
|
||||
{
|
||||
%eval = strReplace($HTTPServer::ClientReplicate, "*UNIQUESOCKET*", %uniqueName);
|
||||
eval(%eval);
|
||||
%this.uniqueName[%i] = %uniqueName;
|
||||
%this.uniqueNameInUse[%uniqueName] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Create the Socket and we'll rock n' roll
|
||||
$Host::BindAddress = %address;
|
||||
%this.Server = new TCPObject(%uniqueString);
|
||||
%this.Server.listen(%port);
|
||||
%this.Server.Parent = %this;
|
||||
%this.connectionCount = 0;
|
||||
%this.maximumClients = %maxClients;
|
||||
$Host::BindAddress = %oldAddr;
|
||||
%this.isListening = true;
|
||||
|
||||
%statusCodes = HTTPServerPrefs.get("StatusCodes",0);
|
||||
%this.Page[404] = %statusCodes.element("404");
|
||||
%this.Page[403] = %statusCodes.element("403");
|
||||
|
||||
%generic = HTTPServerPrefs.get("Generic",0);
|
||||
%this.Root = %generic.element("Root");
|
||||
|
||||
%this.Variables = Array.create();
|
||||
%this.MimeTypes = HTTPServerPrefs.get("MIME");
|
||||
|
||||
logEcho("Server " @ %uniqueString SPC "is ready on " @ %address @ ":" @ %port);
|
||||
return true;
|
||||
}
|
||||
|
||||
function HTTPServer::disconnect(%this)
|
||||
{
|
||||
}
|
||||
|
||||
function HTTPServer::connectionDropped(%this, %socket)
|
||||
{
|
||||
if (!IsObject(%socket))
|
||||
return false;
|
||||
%socket.disconnect();
|
||||
if (!%this.allowMultiConnect)
|
||||
%this.connections[%socket.Address] = "";
|
||||
else
|
||||
%this.connections[%socket.Address, %socket.Port] = "";
|
||||
%this.uniqueNameInUse[%socket.getName()] = false;
|
||||
%this.connectionCount--;
|
||||
%this.onClientDisconnect(%socket);
|
||||
}
|
||||
|
||||
function HTTPServer::connectionCreated(%this, %address, %socket)
|
||||
{
|
||||
%isReplicate = false;
|
||||
// Get the Port No. and Address respectively
|
||||
%address = strReplace(%address, "IP:","");
|
||||
%portPos = strStr(%address, ":");
|
||||
%port = getSubStr(%address, %portPos+1, strLen(%address));
|
||||
%address = getSubStr(%address, 0, %portPos);
|
||||
|
||||
// Pick a unique name
|
||||
%uniqueName = "";
|
||||
for (%i = 0; %i < %this.maximumClients; %i++)
|
||||
{
|
||||
%name = %this.uniqueName[%i];
|
||||
if (!%this.uniqueNameInUse[%name])
|
||||
{
|
||||
%uniqueName = %name;
|
||||
%this.uniqueNameInUse[%name] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// If we were unable to find a good unique name
|
||||
%charList = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
%uniqueStringLen = 6; // Adjust this if needed, but there shouldn't be a reason to
|
||||
if (%uniqueName $= "")
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
%uniqueName = generateString(%uniqueStringLen, %charList);
|
||||
if (!isObject(%uniqueName)) break;
|
||||
else %uniqueName = "";
|
||||
}
|
||||
%eval = strReplace($HTTPServer::ClientReplicate, "*UNIQUESOCKET*", %uniqueName);
|
||||
eval(%eval);
|
||||
|
||||
%this.uniqueName[%this.maximumClients] = %uniqueName;
|
||||
%this.uniqueNameInUse[%uniqueName] = true;
|
||||
%this.maximumClients++;
|
||||
}
|
||||
// Create The Client Socket
|
||||
%connection = new TCPObject(%uniqueName,%socket) { class = ConnectionTCP; parent = %this; Address = %address; Port = %port; };
|
||||
if (!%this.allowMultiConnect)
|
||||
%this.connections[%address] = %connection;
|
||||
else
|
||||
%this.connections[%address, %port] = %connection;
|
||||
|
||||
%this.connectionCount++;
|
||||
%this.onClientConnect(%address, %connection);
|
||||
logEcho("Received client connection from " @ %address);
|
||||
|
||||
%this.schedule(10000,"connectionDropped",%connection);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Callbacks -- make these do whatever you please!
|
||||
function HTTPServer::onClientConnect(%this, %address, %socket)
|
||||
{
|
||||
echo("Received connection from " @ %address @ ". ID:" @ %socket);
|
||||
return true;
|
||||
}
|
||||
function HTTPServer::onClientRejected(%this, %socket, %reason) // %reason is always zero as of now.
|
||||
{
|
||||
return true;
|
||||
}
|
||||
function HTTPServer::onClientDisconnect(%this, %socket)
|
||||
{
|
||||
logEcho("Received Disconnect (" @ %socket @ ")");
|
||||
%socket.delete();
|
||||
return true;
|
||||
}
|
||||
function HTTPServer::onLine(%this, %socket, %line)
|
||||
{
|
||||
%reqType = getWord(%line, 0);
|
||||
if (%reqType $= "GET")
|
||||
{
|
||||
%req = getWord(%line, 1);
|
||||
%reqLen = strLen(%req);
|
||||
%socket.request = getSubStr(%req, 1, %reqLen);
|
||||
%socket.request = strReplace(%socket.request, "%20", " ");
|
||||
%socket.request = %this.Root @ %socket.request;
|
||||
%socket.requestType = "GET";
|
||||
}
|
||||
|
||||
%data = "<HTML><header><title>404 - Not Found</title></header><body>Oops!<br>File not found.</body></HTML>";
|
||||
%forbiddenData = "<HTML><header><title>403- Forbidden</title></header><body>Oops!<br>You're not allowed to see this.</body></HTML>";
|
||||
|
||||
%packet = new ScriptObject(){ class = "HTTPResponsePacket"; };
|
||||
//return;
|
||||
// We received the end-of-packet from a socket
|
||||
if (%line $= "")
|
||||
{
|
||||
//Shitty
|
||||
if (strStr(%socket.request,".") != -1)
|
||||
{
|
||||
if (!isFile(%socket.request))
|
||||
%packet.setStatusCode(404);
|
||||
|
||||
else if (%socket.request $= "prefs/ClientPrefs.cs")
|
||||
{
|
||||
%packet.setStatusCode(403);
|
||||
%data = %forbiddenData;
|
||||
}
|
||||
else if (getFileExtensionFromString(%socket.request) $= "cs")
|
||||
{
|
||||
%packet.setStatusCode(200);
|
||||
|
||||
// FIXME: INSECURE and gay
|
||||
exec(%socket.request);
|
||||
%class = strReplace(getFileNameFromString(%socket.request), ".cs", ""); // FIXME: Crappy
|
||||
%instance = new ScriptObject() { class = %class; };
|
||||
%data = %instance.contents();
|
||||
%instance.delete();
|
||||
}
|
||||
else
|
||||
{
|
||||
%packet.setStatusCode(403);
|
||||
%data = %forbiddenData;
|
||||
}
|
||||
|
||||
// Check the file type
|
||||
%extension = getFileExtensionFromString(%socket.request);
|
||||
if (%extension $= "html" || %extension $= "htm")
|
||||
{
|
||||
%script = strReplace(%socket.request,".html",".cs");
|
||||
if (isFile(%script))
|
||||
{
|
||||
exec(%script);
|
||||
%Object = new ScriptObject(){ class = "ServerApp"; };
|
||||
%data = %Object.execute(%data);
|
||||
%Object.delete();
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
%packet.setStatusCode(200);
|
||||
%data = "<HTML>\n<header>\n<title>\nDirectory\n</title>\n</header>\n<body><h1>Directory of " @ %socket.request @ "</h1>\n";
|
||||
for( %file = findFirstFile( %socket.request @ "*.*" ); %file !$= ""; %file = findNextFile( %socket.request @ "*.*" ) )
|
||||
{
|
||||
%file = strReplace(%file, %socket.request, "");
|
||||
if (strStr(%file, "/") != -1)
|
||||
{
|
||||
%dir = getSubStr(%file, 0, strStr(%file, "/")) @ "/";
|
||||
if (!%dirAdded[%dir])
|
||||
{
|
||||
%data = %data @ "<a href=\"" @ strReplace(%dir, " ","%20") @ "\">" @ %dir @ "</a><br>\n";
|
||||
%dirAdded[%dir] = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
%data = %data @ "<a href=\"" @ strReplace(%file, " ", "%20") @ "\">" @ %file @ "</a><br>\n";
|
||||
}
|
||||
%data = %data @ "</body>\n</HTML>\n";
|
||||
}
|
||||
%packet.setHeader("Date",formatTimeString("DD, dd MM yy hh:nn:ss ") @ "Eastern");
|
||||
%packet.setHeader("Server","Tribes 2");
|
||||
%packet.setHeader("Content-Type","text/html");
|
||||
%packet.setPayload(%data);
|
||||
%socket.sendPacket(%packet);
|
||||
%packet.delete();
|
||||
%this.connectionDropped(%socket);
|
||||
}
|
||||
if (isObject(%packet))
|
||||
%packet.delete();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Packet Functions (used for packet generation/reading)
|
||||
function HTTPResponsePacket::setHeader(%this, %name, %value)
|
||||
{
|
||||
if (%this.headerCount == "")
|
||||
%this.headerCount = 0;
|
||||
|
||||
if (%this.headers[%name] $= "")
|
||||
{
|
||||
%this.headerName[%this.headerCount] = %name;
|
||||
%this.headerCount++;
|
||||
}
|
||||
%this.headers[%name] = %name @ ": " @ %value @ "\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
function HTTPResponsePacket::setStatusCode(%this, %code)
|
||||
{
|
||||
%this.statusCode = "HTTP/1.1 " @ %code SPC "OK\n";
|
||||
return true;
|
||||
}
|
||||
|
||||
function HTTPResponsePacket::setPayload(%this, %data)
|
||||
{
|
||||
%this.payLoad = %data;
|
||||
%this.payloadSize = strLen(%data);
|
||||
%this.setHeader("Content-Length", %this.payloadSize);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Lib Functions
|
||||
function generateString(%length, %alpha)
|
||||
{
|
||||
%len = strLen(%alpha);
|
||||
%result = "";
|
||||
for (%i = 0; %i < %length; %i++)
|
||||
%result = %result @ getSubStr(%alpha, getRandom(0, %len), 1);
|
||||
return %result;
|
||||
}
|
||||
|
||||
// --
|
||||
// BoL Specific Code -- automatically load the server if enabled
|
||||
if (!IsObject(HTTPServerPrefs))
|
||||
new ScriptObject(HTTPServerPrefs) { class = "BasicDataParser"; };
|
||||
HTTPServerPrefs.empty();
|
||||
HTTPServerPrefs.load("prefs/WebServer.conf");
|
||||
%generic = HTTPServerPrefs.get("Generic",0);
|
||||
if(%generic.element("Enabled") $= "true")
|
||||
{
|
||||
new ScriptObject(WebServer) { class = "HTTPServer"; };
|
||||
WebServer.listen(%generic.element("Host"),%generic.element("Port"),%generic.element("StartWorkers"));
|
||||
}
|
||||
// --
|
||||
49
scripts/modscripts/server/RPG/ClientFunctions.cs
Normal file
49
scripts/modscripts/server/RPG/ClientFunctions.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// BoLFunctions.cs
|
||||
// T2BoL Specific Functions
|
||||
// Copyright (c) 2012 Robert MacGregor
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function GameConnection::saveState(%this)
|
||||
{
|
||||
if ($CurrentMissionType !$= "RPG")
|
||||
{
|
||||
error("Not running the BoL gamemode.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function GameConnection::loadState(%this, %file)
|
||||
{
|
||||
if ($CurrentMissionType !$= "RPG")
|
||||
{
|
||||
error("Not running the BoL gamemode.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function AIConnection::saveState(%this)
|
||||
{
|
||||
if ($CurrentMissionType !$= "RPG")
|
||||
{
|
||||
error("Not running the BoL gamemode.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
function AIConnection::loadState(%this, %file)
|
||||
{
|
||||
if ($CurrentMissionType !$= "RPG")
|
||||
{
|
||||
error("Not running the BoL gamemode.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
31
scripts/modscripts/server/RPG/GameTriggers.cs
Normal file
31
scripts/modscripts/server/RPG/GameTriggers.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// GameTriggers.cs
|
||||
// Trigger code for RPG Gamemode
|
||||
// Copyright (c) 2012 Robert MacGregor
|
||||
//==============================================================================
|
||||
|
||||
$BOL::Triggers::Territory = 0;
|
||||
$BOL::Triggers::Damage = 1;
|
||||
$BOL::Triggers::TeleportStart = 2;
|
||||
$PDA::Triggers::TeleportEnd = 3;
|
||||
|
||||
function RPGGame::onEnterTrigger(%game, %name, %data, %obj, %colObj)
|
||||
{
|
||||
switch (%obj.Type)
|
||||
{
|
||||
case $BOL::Triggers::Territory:
|
||||
echo("LOL");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
function RPGGame::onLeaveTrigger(%game, %name, %data, %obj, %colObj)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
function RPGGame::onTickTrigger(%game, %name, %data, %obj)
|
||||
{
|
||||
|
||||
return true;
|
||||
}
|
||||
63
scripts/modscripts/server/RPG/Interact.cs
Normal file
63
scripts/modscripts/server/RPG/Interact.cs
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
//--$BOL::PDA::Page::Interact----------------------------------------------------------------------------
|
||||
// Interact.cs
|
||||
// Functions for object interaction in T2BoL
|
||||
// Copyright (c) 2012 Robert MacGregor
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
$BOL::Interact::Type::General = 0; // Generic; jus makes conversation
|
||||
|
||||
$BOL::Interact::Range = 50; // In Meters
|
||||
function serverCmdInteractWithObject(%client)
|
||||
{
|
||||
if (!IsObject(%client.player) || %client.player.getState() !$= "Move")
|
||||
{
|
||||
messageClient(%client, 'MsgClient', "\c3Sorry, you appear to be dead.");
|
||||
return false;
|
||||
}
|
||||
|
||||
%player = %client.player;
|
||||
%pos = getWords(%player.getEyeTransform(), 0, 2);
|
||||
%vec = %player.getMuzzleVector($WeaponSlot);
|
||||
%targetpos=vectoradd(%pos,vectorscale(%vec,5000));
|
||||
|
||||
%object = getWord(containerRayCast(%pos,%targetpos,$TypeMasks::PlayerObjectType | $TypeMasks::VehicleObjectType,%player),0);
|
||||
echo(%object);
|
||||
if (!isObject(%object) || !%object.isInteractive)
|
||||
return false;
|
||||
|
||||
%client.pdaPage = $BOL::PDA::Page::Interacted;
|
||||
serverCmdShowHud(%client, 'scoreScreen');
|
||||
return true;
|
||||
}
|
||||
|
||||
function Player::interactListUpdate(%this)
|
||||
{
|
||||
if (!isObject(%this.interactList))
|
||||
%this.interactList = Array.create();
|
||||
|
||||
// We don't want to run multiple threads ...
|
||||
cancel(%this.interactListUpdateThread);
|
||||
// We also don't need dead people or bots to be doing this either
|
||||
if ((%this.getState() !$= "Move" && %this.getState() !$= "Mounted") || %this.client.isAIControlled())
|
||||
return;
|
||||
|
||||
%found = Array.create(); // This takes up one objID per call, but objID's go up to 2^32, so this shouldn't matter as it helps make cleaner code here
|
||||
%found_anything = false;
|
||||
InitContainerRadiusSearch(%this.getWorldBoxCenter(), $BOL::Interact::Range, $TypeMasks::PlayerObjectType | $TypeMasks::VehicleObjectType);
|
||||
while ((%target = containerSearchNext()) != 0)
|
||||
{
|
||||
//if (!calcExplosionCoverage(%this.getWorldBoxCenter(), %target,$TypeMasks::PlayerObjectType | $TypeMasks::VehicleObjectType))
|
||||
// continue;
|
||||
%found.setElement(%found.count(), %target);
|
||||
if(isObject(%target) && %target !$= %this && !%this.interactList.hasElementValue(%target))
|
||||
%this.interactList.setElement(%this.interactList.count(), %target);
|
||||
}
|
||||
|
||||
// Remove any non-found elements from the interact list
|
||||
for (%i = %this.interactList.count(); %i > -1; %i--)
|
||||
if (!%found.hasElementValue(%this.interactList.element(%i)))
|
||||
%this.interactList.removeElement(%i);
|
||||
|
||||
%found.delete();
|
||||
%this.interactListUpdateThread = %this.schedule(100, "interactListUpdate");
|
||||
}
|
||||
268
scripts/modscripts/server/RPG/PDA.cs
Normal file
268
scripts/modscripts/server/RPG/PDA.cs
Normal file
|
|
@ -0,0 +1,268 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// PDA.cs
|
||||
// PDA code for T2BoL
|
||||
// Copyright (c) 2012 Robert MacGregor
|
||||
//==============================================================================
|
||||
|
||||
// 0-100
|
||||
$BOL::PDA::Page::Main = 0;
|
||||
|
||||
$BOL::PDA::Page::Applications = 1;
|
||||
$BOL::PDA::Page::Close = 2; // Not even necessarily a page but it's used to signal the client wants to close
|
||||
$BOL::PDA::Page::Stats = 3;
|
||||
$BOL::PDA::Page::Save = 4;
|
||||
$BOL::PDA::Page::FactionManagement = 5;
|
||||
|
||||
$BOL::PDA::Page::Radio = 6;
|
||||
$BOL::PDA::Page::Voice = 7;
|
||||
|
||||
$BOL::PDA::Function::Increment = 1;
|
||||
$BOL::PDA::Function::Decrement = 2;
|
||||
|
||||
$BOL::PDA::Page::EMail = 8;
|
||||
$BOL::PDA::Page::Inbox = 9;
|
||||
$BOL::PDA::Page::Outbox = 10;
|
||||
$BOL::PDA::Page::Compose = 11;
|
||||
|
||||
$BOL::PDA::Page::Wiki = 12;
|
||||
|
||||
// 101-201
|
||||
$BOL::PDA::Page::Interact = 101;
|
||||
$BOL::PDA::Page::Interacted = 102;
|
||||
$BOL::PDA::Page::Hack = 103;
|
||||
$BOL::PDA::Page::Information = 104;
|
||||
|
||||
function RPGGame::updateScoreHud(%game, %client, %tag)
|
||||
{
|
||||
if (%client.PDAPage == $BOL::PDA::Page::Main || %client.PDAPage == $BOL::PDA::Page::Interact)
|
||||
Game.processGameLink(%client, %client.PDAPage);
|
||||
}
|
||||
|
||||
function RPGGame::processGameLink(%game, %client, %arg1, %arg2, %arg3, %arg4, %arg5)
|
||||
{
|
||||
%index = 0;
|
||||
if (%arg1 != $BOL::PDA::Page::Close)
|
||||
%client.PDAPage = %arg1;
|
||||
messageClient( %client, 'ClearHud', "", 'scoreScreen', 0 );
|
||||
|
||||
switch(%arg1)
|
||||
{
|
||||
//------------------------------------------------------------------------------
|
||||
// PDA Applications
|
||||
//------------------------------------------------------------------------------
|
||||
case $BOL::PDA::Page::Applications:
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", '<just:center>Applications | Main');
|
||||
messageClient( %client, 'SetScoreHudHeader', "", "<just:center>| <a:gamelink\t" @ $BOL::PDA::Page::Wiki @ "\t1>Wiki</a> | <color:FF0000>Applications<color:66EEEE> | <a:gamelink\t" @ $BOL::PDA::Page::EMail @ "\t0>E-Mail</a> | <just:right><a:gamelink\t" @ $BOL::PDA::Page::Close @ "\t1>Close</a>");
|
||||
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>Command List:");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\t" @ $BOL::PDA::Page::Stats @ "\t1>- Self Diagnosis</a>");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\t" @ $BOL::PDA::Page::Interact @ "\t0>- Interact with Object</a>");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\t" @ $BOL::PDA::Page::Radio @ "\t0>- Radio</a>");
|
||||
%index++;
|
||||
if (!$Host::GlobalChat)
|
||||
{
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\t" @ $BOL::PDA::Page::Voice @ "\t0>- Voice Settings</a>");
|
||||
%index++;
|
||||
}
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\t" @ $BOL::PDA::Page::FactionManagement @ "\t1>- Faction Management</a>");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\t" @ $BOL::PDA::Page::Save @ "\t1>- Save State</a>");
|
||||
return;
|
||||
|
||||
case $BOL::PDA::Page::Stats:
|
||||
messageClient( %client, 'SetScoreHudHeader', "", "<just:center>Automated Self Diagnosis Systems v1.2<just:right><a:gamelink\t" @ $BOL::PDA::Page::Close @ "\t1>Close</a>");
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", '<just:center>Copyright (c) 3030 S.G.S. Corporation');
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>Subject Name: " @ %client.namebase);
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>Subject Species: " @ %client.race);
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>Subject Condition: " @ 100 - mfloor(100*%client.player.getDamageLevel()) @ "%");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, " ");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\t" @ $BOL::PDA::Page::Stats @ "\t1>REFRESH</a>");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\t" @ $BOL::PDA::Page::Applications@ "\t1>RETURN TO MAIN</a>");
|
||||
return;
|
||||
|
||||
case $BOL::PDA::Page::Radio:
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", '<just:center>Applications | Radio');
|
||||
|
||||
if (!%client.hasRadio)
|
||||
{
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>-- You do not have a radio to manage --");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, " ");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\t" @ $BOL::PDA::Page::Applications@ "\t1>RETURN TO MAIN</a>");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (%arg2)
|
||||
{
|
||||
case $BOL::PDA::Function::Increment:
|
||||
ServerCmdIncreaseRadioFrequency(%client, true);
|
||||
case $BOL::PDA::Function::Decrement:
|
||||
ServerCmdDecreaseRadioFrequency(%client, true);
|
||||
}
|
||||
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>Radio Status: Normal");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>Current Frequency: " @ %client.radioFrequency @ "MHz");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\t" @ $BOL::PDA::Page::Radio @ "\t" @ $BOL::PDA::Function::Increment @ ">[Increment Frequency</a> - <a:gamelink\t" @ $BOL::PDA::Page::Radio @ "\t" @ $BOL::PDA::Function::Decrement @ ">Decrement Frequency]</a>");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, " ");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\t" @ $BOL::PDA::Page::Applications@ "\t1>RETURN TO MAIN</a>");
|
||||
return;
|
||||
|
||||
case $BOL::PDA::Page::Voice:
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", '<just:center>Applications | Voice Settings');
|
||||
|
||||
switch (%arg2)
|
||||
{
|
||||
case $BOL::PDA::Function::Increment:
|
||||
serverCmdIncreaseVoiceRange(%client, true);
|
||||
case $BOL::PDA::Function::Decrement:
|
||||
serverCmdDecreaseVoiceRange(%client, true);
|
||||
}
|
||||
|
||||
%voice = %client.voiceMode;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>Voice Status: Normal");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>Current Voice: \x22" @ $BOL::Voice::Display[%voice] @ "\x22 (" @ $BOL::Voice::Range[%voice] @ " meters)");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\t" @ $BOL::PDA::Page::Voice @ "\t" @ $BOL::PDA::Function::Increment @ ">[Increment Range</a> - <a:gamelink\t" @ $BOL::PDA::Page::Voice @ "\t" @ $BOL::PDA::Function::Decrement @ ">Decrement Range]</a>");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, " ");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\t" @ $BOL::PDA::Page::Applications@ "\t1>RETURN TO MAIN</a>");
|
||||
return;
|
||||
|
||||
case $BOL::PDA::Page::Interact:
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", '<just:center>Applications | Interact with Object');
|
||||
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>-- Objects within Range --");
|
||||
%index++;
|
||||
|
||||
%client_team = getTargetSensorGroup(%client.target);
|
||||
%object_count = %client.player.interactList.count();
|
||||
if (%object_count > 0)
|
||||
for (%i = 0; %i < %object_count; %i++)
|
||||
{
|
||||
%object = %client.player.interactList.element(%i);
|
||||
if (isObject(%object))
|
||||
{
|
||||
%object_target = %object.target;
|
||||
if (%object_target != -1)
|
||||
{
|
||||
%object_team = getTargetSensorGroup(%object_target);
|
||||
%object_friendly = %client_team == %object_team;
|
||||
%object_friend_text = %object_friendly ? "Friendly" : "Enemy";
|
||||
%display = %object_friend_text SPC %object.getClassName() SPC "\x22" @ getTaggedString(getTargetName(%object_target)) @ "\x22";
|
||||
}
|
||||
else
|
||||
%display = "Unknown" SPC %object.getClassName() SPC "(" @ %object @ ")";
|
||||
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>" @ %display);
|
||||
%index++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>There are no objects in range.");
|
||||
%index++;
|
||||
}
|
||||
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, " ");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\t" @ $BOL::PDA::Page::Applications@ "\t1>RETURN TO MAIN</a>");
|
||||
return;
|
||||
|
||||
|
||||
case $BOL::PDA::Page::FactionManagement:
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", '<just:center>Applications | Faction Management');
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\t" @ $BOL::PDA::Page::Applications@ "\t1>RETURN TO MAIN</a>");
|
||||
return;
|
||||
|
||||
case $BOL::PDA::Page::Save:
|
||||
messageClient( %client, 'SetScoreHudHeader', "", '<just:center>Save State<just:right><a:gamelink\tCLOSE\t1>Close</a>');
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>Save function is not supported as of now!");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\t" @ $BOL::PDA::Page::Applications @ "\t1>RETURN TO MAIN</a>");
|
||||
return;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// PDA E-Mail System
|
||||
//------------------------------------------------------------------------------
|
||||
case $BOL::PDA::Page::Inbox:
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", '<just:center>E-Mail | Your Inbox');
|
||||
return;
|
||||
case $BOL::PDA::Page::Outbox:
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", '<just:center>E-Mail | Your Outbox');
|
||||
return;
|
||||
case $BOL::PDA::Page::Compose:
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", '<just:center>E-Mail | Compose a New Mail');
|
||||
return;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Interaction Commands
|
||||
//------------------------------------------------------------------------------
|
||||
case $BOL::PDA::Page::Interact:
|
||||
return;
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Handle for Normal PDA functions
|
||||
//------------------------------------------------------------------------------
|
||||
case $BOL::PDA::Page::Main:
|
||||
messageClient( %client, 'SetScoreHudHeader', "", "<just:center>| <a:gamelink\t" @ $BOL::PDA::Page::Wiki @ "\t1>Wiki</a> | <a:gamelink\t" @ $BOL::PDA::Page::Applications @ "\t1>Applications</a> | <a:gamelink\t" @ $BOL::PDA::Page::EMail @ "\t1>E-Mail</a> | <just:right><a:gamelink\t" @ $BOL::PDA::Page::Close @ "\t1>Close</a>");
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", '<just:center>Welcome to the PDA');
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>Welcome to the PDA, this is where you will accomplish some daily tasks.");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>Click any of the text in the subheader to begin exploring your PDA.");
|
||||
return;
|
||||
|
||||
case $BOL::PDA::Page::EMail:
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", '<just:center>E-Mail | Main');
|
||||
messageClient( %client, 'SetScoreHudHeader', "", "<just:center>| <a:gamelink\t" @ $BOL::PDA::Page::Wiki @ "\t1>Wiki</a> | <a:gamelink\t" @ $BOL::PDA::Page::Applications @ "\t1>Applications</a> | <color:FF0000>E-Mail<color:66EEEE> | <just:right><a:gamelink\t" @ $BOL::PDA::Page::Close @ "\t1>Close</a>");
|
||||
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>E-Mail Functions:");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center> - <a:gamelink\t" @ $BOL::PDA::Page::Inbox @ "\t1>Your Inbox (?)</a>");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center> - <a:gamelink\t" @ $BOL::PDA::Page::Outbox @ "\t1>Your Outbox (?)</a>");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center> - <a:gamelink\t" @ $BOL::PDA::Page::Compose @ "\t1>Compose a New Mail</a>");
|
||||
return;
|
||||
|
||||
case $BOL::PDA::Page::Close:
|
||||
serverCmdHideHud(%client, 'scoreScreen');
|
||||
commandToClient(%client, 'DisplayHuds');
|
||||
return;
|
||||
|
||||
case $BOL::PDA::Page::Wiki:
|
||||
messageClient( %client, 'SetScoreHudHeader', "", "<just:center>| <color:FF0000>Wiki<color:66EEEE> | <a:gamelink\t" @ $BOL::PDA::Page::Applications @ "\t1>Applications</a> | <a:gamelink\t" @ $BOL::PDA::Page::EMail @ "\t1>E-Mail</a> | <just:right><a:gamelink\t" @ $BOL::PDA::Page::Close @ "\t1>Close</a>");
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", '<just:center>Wiki | Main');
|
||||
return;
|
||||
|
||||
default: // In case something stupid happens
|
||||
messageClient( %client, 'SetScoreHudHeader', "", "<just:center>| Information | <a:gamelink\t" @ $BOL::PDA::Page::Applications @ "\t1>Applications</a> | <a:gamelink\t" @ $BOL::PDA::Page::EMail @ "\t1>E-Mail</a> | <a:gamelink\t" @ $BOL::PDA::Page::Wiki @ "\t1>Wiki</a> | <just:right><a:gamelink\t" @ $BOL::PDA::Page::Close @ "\t1>Close</a>");
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", '<just:center>Error | Main');
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>-- An ERROR has occurred in the PDA Subsystem code --");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>-- Please report this error to DarkDragonDX --");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>Unknown PDA page: " @ %arg1);
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, " ");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\t" @ $BOL::PDA::Page::Main @ "\t1>-- RETURN TO MAIN --</a>");
|
||||
return;
|
||||
}
|
||||
}
|
||||
32
scripts/modscripts/server/RPG/PDAApplication.cs
Normal file
32
scripts/modscripts/server/RPG/PDAApplication.cs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// PDAApplication.cs
|
||||
// Application SDK for the PDA. (to make my life easier)
|
||||
// Copyright (c) 2012 Robert MacGregor
|
||||
//==============================================================================
|
||||
|
||||
function PDAApplication::main(%this, %client)
|
||||
{
|
||||
}
|
||||
|
||||
function PDAApplication::action(%this, %client, %page)
|
||||
{
|
||||
}
|
||||
|
||||
function PDAApplication::exit(%this, %client, %page)
|
||||
{
|
||||
}
|
||||
|
||||
// API Functions
|
||||
function PDAApplication::setTitle(%this, %title)
|
||||
{
|
||||
// Won't do anything for now because the title is a clientside thing, actually.
|
||||
}
|
||||
|
||||
function PDAApplication::cls(%this)
|
||||
{
|
||||
}
|
||||
|
||||
// The script parses <URL=
|
||||
function PDAApplication::setLine(%this, %lineNo, %columnStart, %data)
|
||||
{
|
||||
}
|
||||
1
scripts/modscripts/server/RPG/RadioChat.cs
Normal file
1
scripts/modscripts/server/RPG/RadioChat.cs
Normal file
|
|
@ -0,0 +1 @@
|
|||
//------------------------------------------------------------------------------
// radioChat.cs
// Functions for radio voice in T2BoL
// Copyright (c) 2012 Robert MacGregor
//------------------------------------------------------------------------------
$BOL::Radio::Max = 10;
$BOL::Radio::Min = 1;
$BOL::Radio::Units = "MHz";
function ServerCmdIncreaseRadioFrequency(%client, %noDisplay)
{
if (!%client.hasRadio)
{
messageClient(%client, 'msgClient', "\c3You have no radio to tune.");
return;
}
else if ($CurrentMissionType !$= "RPG")
{
messageClient(%client, 'msgClient', "\c3Server is not running the RPG gamemode currently.");
return;
}
if (%client.radioFrequency == 0)
%client.radioFrequency = 1;
if (%client.radioFrequency >= $BOL::Radio::Max)
%client.radioFrequency = $BOL::Radio::Min;
else
%client.radioFrequency++;
if (!%noDisplay)
messageClient(%client, 'msgClient',"\c3You tune your radio to " @ %client.radioFrequency @ $BOL::Radio::Units @ ".");
}
function ServerCmdDecreaseRadioFrequency(%client, %noDisplay)
{
if (!%client.hasRadio)
{
messageClient(%client, 'msgClient', "\c3You have no radio to tune.");
return;
}
if (%client.radioFrequency == 0)
%client.radioFrequency = 1;
if (%client.radioFrequency <= $BOL::Radio::Min)
%client.radioFrequency = $BOL::Radio::Max;
else
%client.radioFrequency--;
if (!%noDisplay)
messageClient(%client, 'msgClient',"\c3You tune your radio to " @ %client.radioFrequency @ $BOL::Radio::Units @ ".");
}
function radioBroadcast( %text, %frequency )
{
%units = $BOL::Radio::Units;
%count = ClientGroup.getCount();
for ( %i = 0; %i < %count; %i++ )
{
%client = ClientGroup.getObject( %i );
if ( %client.hasRadio && %client.radioFrequency == %frequency )
messageClient(%client,'msgClient',"\c3(" @ %frequency @ %units @ "): " @ %text @ "~wfx/misc/static.wav");
}
}
function radioChatMessageTeam( %sender, %team, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10 )
{
if (!%sender.hasRadio)
{
messageClient(%sender,'msgNoRadio',"\c3You must have a radio.");
return;
}
%frequency = %sender.radioFrequency;
if (%frequency < $BOL::Radio::Min || %frequency > $BOL::Radio::Max)
{
%sender.radioFrequency = $BOL::Radio::Min;
messageClient(%sender,'msgClient',"\c3Your radio appears to be in dire need of retuning.");
return;
}
%units = $BOL::Radio::Units;
%count = ClientGroup.getCount();
for ( %i = 0; %i < %count; %i++ )
{
%client = ClientGroup.getObject(%i);
if ( %client.hasRadio && %client.radioFrequency == %sender.radioFrequency )
messageClient(%client,'msgClient',"\c3"@ %sender.namebase@ " (" @ %frequency @ %units @ "): "@%a2@" ~wfx/misc/static.wav");
}
}
|
||||
98
scripts/modscripts/server/RPG/RangedVoice.cs
Normal file
98
scripts/modscripts/server/RPG/RangedVoice.cs
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// rangedVoice.cs
|
||||
// Functions for ranged voice in T2BoL
|
||||
// Copyright (c) 2012 Robert MacGregor
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
$BOL::Voice::Whisper = 0;
|
||||
$BOL::Voice::Range[0] = 15;
|
||||
$BOL::Voice::Display[0] = "Whispering";
|
||||
|
||||
$BOL::Voice::Speak = 1;
|
||||
$BOL::voice::Range[1] = 25;
|
||||
$BOL::Voice::Display[1] = "Speaking";
|
||||
|
||||
$BOL::Voice::Yell = 2;
|
||||
$BOL::Voice::Range[2] = 50;
|
||||
$BOL::Voice::Display[2] = "Yelling";
|
||||
|
||||
$BOL::Voice::Scream = 3;
|
||||
$BOL::Voice::Range[3] = 100;
|
||||
$BOL::Voice::Display[3] = "Screaming";
|
||||
|
||||
$BOL::Voice::Total = 4;
|
||||
|
||||
function serverCmdIncreaseVoiceRange(%client, %noDisplay)
|
||||
{
|
||||
if ($CurrentMissionType $= "RPG" && $Host::GlobalChat)
|
||||
{
|
||||
messageClient(%client, 'msgClient', "\c3Server has global chat enabled.");
|
||||
return;
|
||||
}
|
||||
else if ($CurrentMissionType !$= "RPG")
|
||||
{
|
||||
messageClient(%client, 'msgClient', "\c3Server is not running the RPG gamemode currently.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (%client.voiceMode >= $BOL::Voice::Total-1)
|
||||
%client.voiceMode = 0;
|
||||
else
|
||||
%client.voiceMode++;
|
||||
%display = $BOL::Voice::Display[%client.voiceMode];
|
||||
%range = $BOL::Voice::Range[%client.voiceMode];
|
||||
if (!%noDisplay)
|
||||
messageClient(%client, 'msgClient',"\c3Voice mode set to \"" @ %display @ "\" (" @ %range @ "m)");
|
||||
}
|
||||
|
||||
function serverCmdDecreaseVoiceRange(%client, %noDisplay)
|
||||
{
|
||||
if ($CurrentMissionType $= "RPG" && $Host::GlobalChat)
|
||||
{
|
||||
messageClient(%client, 'msgClient', "\c3Server has global chat enabled.");
|
||||
return;
|
||||
}
|
||||
else if ($CurrentMissionType !$= "RPG")
|
||||
{
|
||||
messageClient(%client, 'msgClient', "\c3Server is not running the RPG gamemode currently.");
|
||||
return;
|
||||
}
|
||||
|
||||
if (%client.voiceMode <= 0)
|
||||
%client.voiceMode = $BOL::Voice::Total-1;
|
||||
else
|
||||
%client.voiceMode--;
|
||||
%display = $BOL::Voice::Display[%client.voiceMode];
|
||||
%range = $BOL::Voice::Range[%client.voiceMode];
|
||||
if (!%noDisplay)
|
||||
messageClient(%client, 'msgClient',"\c3Voice mode set to \"" @ %display @ "\" (" @ %range @ "m)");
|
||||
}
|
||||
|
||||
function rangedchatMessageAll(%sender, %msgString, %a1, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10)
|
||||
{
|
||||
%mode = %sender.voiceMode;
|
||||
|
||||
if (%mode < 0 || %mode >= $BOL::Voice::Total)
|
||||
{
|
||||
%sender.voiceMode = 0;
|
||||
%mode = 0;
|
||||
messageClient(%sender,'msgClient',"\c3Your throat feels agitated.");
|
||||
}
|
||||
%voicedist = $BOL::Voice::Range[%sender.voiceMode];
|
||||
%display = $BOL::Voice::Display[%sender.voiceMode];
|
||||
%count = MissionCleanup.getCount();
|
||||
|
||||
for (%i = 0; %i < %count; %i++)
|
||||
{
|
||||
%obj = MissionCleanup.getObject(%i);
|
||||
if (%obj.getClassName() $= "Player")
|
||||
{
|
||||
%dist = vectorDist(%sender.player.getPosition(),%obj.getPosition());
|
||||
if (%dist <= %voicedist)
|
||||
{
|
||||
%string = addTaggedString("(" @ %display @ " - " @ %voicedist @ "m) " @ getTaggedString(%a1));
|
||||
chatMessageClient( %obj.client, %sender, %sender.voiceTag, %sender.voicePitch, %msgString, %string, %a2, %a3, %a4, %a5, %a6, %a7, %a8, %a9, %a10 );
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
302
scripts/modscripts/server/RPG/dataImport.cs
Normal file
302
scripts/modscripts/server/RPG/dataImport.cs
Normal file
|
|
@ -0,0 +1,302 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// scripts/modScripts/server/dataImport.cs
|
||||
// Copyright (c) 2012 Robert MacGregor
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function gameConnection::writeSaveFile(%this)
|
||||
{
|
||||
//Compile Main Variable List
|
||||
%mission = $CurrentMission;
|
||||
%player = %this.player;
|
||||
%transform = %player.getTransform();
|
||||
%velocity = %player.getVelocity();
|
||||
%damage = %player.getDamageLevel();
|
||||
%race = %this.race;
|
||||
%armor = %this.armor;
|
||||
%energy = %player.getEnergyLevel();
|
||||
%whiteout = %player.getWhiteout();
|
||||
%damageFlash = %player.getDamageFlash();
|
||||
%cash = %this.cash;
|
||||
%hasRadio = %this.hasRadio;
|
||||
%underStandsHuman = %this.underStandsHuman;
|
||||
%underStandsBioderm = %this.underStandsBioderm;
|
||||
%underStandsDraakan = %this.underStandsDraakan;
|
||||
%underStandsCriollos = %this.underStandsCriollos;
|
||||
|
||||
%time = formatTimeString("hh:nn A");
|
||||
%date = formatTimeString("mm/dd/yy");
|
||||
|
||||
%file = "data/game/saves/" @ %mission @ "/" @ %this.guid @ ".txt";
|
||||
%fileObj = new fileObject();
|
||||
%fileObj.openForWrite(%file);
|
||||
%fileObj.writeLine(";Saved by" SPC %this.nameBase SPC "on" SPC %date SPC "at" SPC %time);
|
||||
%fileObj.writeLine("");
|
||||
|
||||
//Todo: Make this writing method more efficient ...
|
||||
%fileObj.writeLine("[Character]");
|
||||
%fileObj.writeLine("transform = \x22" @ %transform @ "\x22;");
|
||||
%fileObj.writeLine("velocity = \x22" @ %velocity @ "\x22;");
|
||||
%fileObj.writeLine("damage = \x22" @ %damage @ "\x22;");
|
||||
%fileObj.writeLine("race = \x22" @ %race @ "\x22;");
|
||||
%fileObj.writeLine("armor = \x22" @ %armor @ "\x22;");
|
||||
%fileObj.writeLine("energy = \x22" @ %energy @ "\x22;");
|
||||
%fileObj.writeLine("whiteOut = \x22" @ %whiteout @ "\x22;");
|
||||
%fileObj.writeLine("damageFlash = \x22" @ %damageFlash @ "\x22;");
|
||||
%fileObj.writeLine("cash = \x22" @ %cash @ "\x22;");
|
||||
%fileObj.writeLine("hasRadio = \x22" @ %hasRadio @ "\x22;");
|
||||
%fileObj.writeLine("underStandsHuman = \x22" @ %underStandsHuman @ "\x22;");
|
||||
%fileObj.writeLine("underStandsBioderm = \x22" @ %underStandsBioderm @ "\x22;");
|
||||
%fileObj.writeLine("underStandsDraakan = \x22" @ %underStandsDraakan @ "\x22;");
|
||||
%fileObj.writeLine("underStandsCriollos = \x22" @ %underStandsCriollos @ "\x22;");
|
||||
%fileObj.writeLine("");
|
||||
|
||||
//Compile Inventory List
|
||||
%slotCount = %player.weaponSlotCount;
|
||||
%healthKits = %player.invRepairKit;
|
||||
%fileObj.writeLine("[Inventory]");
|
||||
%fileObj.writeLine("slotCount = \x22" @ %slotCount @ "\x22;");
|
||||
|
||||
for (%i = 0; %i < %slotCount; %i++)
|
||||
{
|
||||
%weaponName = %player.weaponSlot[%i];
|
||||
%weaponAmmo = eval("%weaponAmmo = %player.inv" @ %weaponName @ "Ammo" @ ";");
|
||||
%fileObj.writeLine("slot" @ %i SPC "= \x22" @ %weaponName @ "\x22;");
|
||||
%fileObj.writeLine("slot" @ %i @ "Ammo" SPC "= \x22" @ %weaponAmmo @ "\x22;");
|
||||
}
|
||||
|
||||
%fileObj.writeLine("healthKits = \x22" @ %healthKits @ "\x22;");
|
||||
%fileObj.detach();
|
||||
logEcho(" -- Save File Written for Player:" SPC %this.namebase SPC "--");
|
||||
return true;
|
||||
}
|
||||
|
||||
function gameConnection::applySaveFile(%this)
|
||||
{
|
||||
//Compile Main Variable List
|
||||
%mission = $CurrentMission;
|
||||
%file = "data/game/saves/" @ %mission @ "/" @ %this.guid @ ".txt";
|
||||
|
||||
if (!isFile(%file))
|
||||
return false;
|
||||
|
||||
%transform = getBlockData(%file,"Character",1,"transform");
|
||||
%velocity = getBlockData(%file,"Character",1,"velocity");
|
||||
%damage = getBlockData(%file,"Character",1,"damage");
|
||||
%race = getBlockData(%file,"Character",1,"race");
|
||||
%armor = getBlockData(%file,"Character",1,"armor");
|
||||
%energy = getBlockData(%file,"Character",1,"energyLevel");
|
||||
%whiteout = getBlockData(%file,"Character",1,"whiteOut");
|
||||
%damageFlash = getBlockData(%file,"Character",1,"damageFlash");
|
||||
%cash = getBlockData(%file,"Character",1,"cash");
|
||||
%hasRadio = getBlockData(%file,"Character",1,"hasRadio");
|
||||
%underStandsHuman = getBlockData(%file,"Character",1,"underStandsHuman");
|
||||
%underStandsBioderm = getBlockData(%file,"Character",1,"underStandsBioderm");
|
||||
%underStandsDraakan = getBlockData(%file,"Character",1,"underStandsDraakan");
|
||||
%underStandsCriollos = getBlockData(%file,"Character",1,"underStandsCriollos");
|
||||
|
||||
%player = %this.player;
|
||||
%player.setTransform(%transform);
|
||||
%player.setVelocity(%velocity);
|
||||
%player.applyDamage(%damage);
|
||||
%player.setArmor(%armor);
|
||||
%player.setEnergyLevel(%energy);
|
||||
%player.setWhiteout(%whiteOut);
|
||||
%player.setDamageFlash(%damageFlash);
|
||||
%this.cash = %cash;
|
||||
%this.underStandsHuman = %underStandsHuman;
|
||||
%this.underStandsBioderm = %underStandsBioderm;
|
||||
%this.underStandsDraakan = %underStandsDraakan;
|
||||
%this.underStandsCriollos = %underStandsCriollos;
|
||||
|
||||
return true;
|
||||
for (%i = 0; %i < %slotCount; %i++)
|
||||
{
|
||||
%weaponName = %player.weaponSlot[%i];
|
||||
%weaponAmmo = eval("%weaponAmmo = %player.inv" @ %weaponName @ "Ammo" @ ";");
|
||||
%fileObj.writeLine("slot" @ %i SPC "= \x22" @ %weaponName @ "\x22;");
|
||||
%fileObj.writeLine("slot" @ %i @ "Ammo" SPC "= \x22" @ %weaponAmmo @ "\x22;");
|
||||
}
|
||||
|
||||
%fileObj.writeLine("healthKits = \x22" @ %healthKits @ "\x22;");
|
||||
return;
|
||||
}
|
||||
|
||||
// Generic Import Functions
|
||||
function importGameData()
|
||||
{
|
||||
importGems();
|
||||
importOres();
|
||||
importCharacters();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Gem Import Functions
|
||||
function importGems()
|
||||
{
|
||||
if (!IsObject(GemData))
|
||||
{
|
||||
new ScriptObject(GemData);
|
||||
|
||||
if (!IsObject(GameData))
|
||||
new simGroup(GameData);
|
||||
|
||||
GameData.add(GemData);
|
||||
}
|
||||
else
|
||||
return true;
|
||||
|
||||
%file = "data/game/gems.txt";
|
||||
%count = getBlockCount(%file,"Gem") + 1;
|
||||
|
||||
for (%i = 1; %i < %count; %i++)
|
||||
{
|
||||
%name = getBlockData(%file,"Gem",%i,"Name");
|
||||
%price = getBlockData(%file,"Gem",%i,"Price");
|
||||
%sellPrice = getBlockData(%file,"Gem",%i,"SellPrice");
|
||||
|
||||
GemData.gem[%i] = %name;
|
||||
GemData.price[%name] = %price;
|
||||
GemData.sellPrice[%name] = %sellPrice;
|
||||
warn("Imported gem:" SPC %name);
|
||||
|
||||
GemData.gemCount = %count--;
|
||||
}
|
||||
|
||||
// Ore Import Functions
|
||||
function importOres()
|
||||
{
|
||||
if (!IsObject(OreData))
|
||||
{
|
||||
new ScriptObject(OreData);
|
||||
|
||||
if (!IsObject(GameData))
|
||||
new simGroup(GameData);
|
||||
|
||||
GameData.add(OreData);
|
||||
}
|
||||
else
|
||||
return true;
|
||||
|
||||
%file = "data/game/ores.txt";
|
||||
%count = getBlockCount(%file,"Ore") + 1;
|
||||
|
||||
for (%i = 1; %i < %count; %i++)
|
||||
{
|
||||
%name = getBlockData(%file,"Ore",%i,"Name");
|
||||
%price = getBlockData(%file,"Ore",%i,"Price");
|
||||
%sellPrice = getBlockData(%file,"Ore",%i,"SellPrice");
|
||||
|
||||
OreData.ore[%i] = %name;
|
||||
OreData.price[%name] = %price;
|
||||
OreData.sellPrice[%name] = %sellPrice;
|
||||
warn("Imported ore:" SPC %name);
|
||||
}
|
||||
OreData.oreCount = %count--;
|
||||
}
|
||||
|
||||
// Character Import Functions
|
||||
function spawnCharacter(%name,%trans,%aimPos,%team)
|
||||
{
|
||||
%object = "Character" @ %name;
|
||||
|
||||
if (!IsObject(%object))
|
||||
return false;
|
||||
|
||||
%Bname = %object.name;
|
||||
%race = %object.race;
|
||||
%skin = %object.skin;
|
||||
%voice = %object.voice;
|
||||
%voicePitch = %object.voicePitch;
|
||||
%sex = %object.sex;
|
||||
|
||||
%bot = aiConnectByName(%Bname,%team);
|
||||
%bot.race = %race;
|
||||
%bot.skin = addTaggedString(%skin);
|
||||
%bot.voice = %voice;
|
||||
%bot.voiceTag = addTaggedString(%voice);
|
||||
%bot.voicePitch = %voicePitch;
|
||||
%bot.sex = %sex;
|
||||
setVoice(%bot,%voice, %voicePitch);
|
||||
setSkin(%bot,%skin);
|
||||
setSkin(%bot,%skin);
|
||||
setTeam(%bot, %team);
|
||||
%bot.player.setArmor("light");
|
||||
%bot.player.setTransform(%trans);
|
||||
%bot.aimAt(%aimPos);
|
||||
warn("Spawned Character:" SPC %name);
|
||||
}
|
||||
|
||||
function importCharacters()
|
||||
{
|
||||
%path = "data/game/characters/*.txt";
|
||||
for( %file = findFirstFile( %path ); %file !$= ""; %file = findNextFile( %path ) )
|
||||
{
|
||||
%name = getFileNameFromString(%file);
|
||||
%pos = strStr(%name,".");
|
||||
%character = getSubStr(%name,0,%pos);
|
||||
importCharacter(%character);
|
||||
}
|
||||
}
|
||||
|
||||
function importCharacter(%character)
|
||||
{
|
||||
%prefix = "data/game/characters/";
|
||||
%file = %prefix @ %character @ ".txt";
|
||||
%charName = %character;
|
||||
%character = strReplace("Character" @ %character," ","_");
|
||||
|
||||
if (!IsFile(%file))
|
||||
return false;
|
||||
|
||||
if (!IsObject(%character))
|
||||
{
|
||||
new scriptObject(%character);
|
||||
if (!IsObject(GameData))
|
||||
new simGroup(GameData);
|
||||
|
||||
GameData.add(%character);
|
||||
}
|
||||
else
|
||||
return true;
|
||||
|
||||
//Get our variable values ...
|
||||
%name = getBlockData(%file,"Character",1,"Name");
|
||||
%race = getBlockData(%file,"Character",1,"Race");
|
||||
%sex = getBlockData(%file,"Character",1,"Sex");
|
||||
%skin = getBlockData(%file,"Character",1,"Skin");
|
||||
%voice = getBlockData(%file,"Character",1,"Voice");
|
||||
%voicePitch = getBlockData(%file,"Character",1,"VoicePitch");
|
||||
|
||||
//Import Message Arrays ... and assign them
|
||||
%arrayName[0] = "Death";
|
||||
%arrayName[1] = "Kill";
|
||||
%arrayName[2] = "Healed";
|
||||
%arrayCount = 3;
|
||||
|
||||
for (%i = 0; %i < %arrayCount; %i++)
|
||||
{
|
||||
%arrayVariableName[%i] = %arrayName[%i] @ "MessageArray";
|
||||
for (%j = 0; %j < 100; %j++)
|
||||
{
|
||||
%arrayTest = getArrayData(%file,%arrayName[%i],%j);
|
||||
if (%arrayTest !$= "}")
|
||||
{
|
||||
if (%j == 0)
|
||||
%arrayData[%i] = %arrayData[%i] @ %arrayTest;
|
||||
else
|
||||
%arrayData[%i] = %arrayData[%i] @ "\t" @ %arrayTest;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
eval(%character @ "." @ %arrayVariableName[%i] SPC "= \x22" @ %arrayData[%i] @ "\x22;");
|
||||
}
|
||||
//Assign the variables now ...
|
||||
%character.name = %name;
|
||||
%character.race = %race;
|
||||
%character.sex = %sex;
|
||||
%character.skin = %skin;
|
||||
%character.voice = %voice;
|
||||
%character.voicePitch = %voicePitch;
|
||||
warn("Imported Character:" SPC %charname);
|
||||
}
|
||||
1
scripts/modscripts/server/RPG/initialise.cs
Normal file
1
scripts/modscripts/server/RPG/initialise.cs
Normal file
|
|
@ -0,0 +1 @@
|
|||
//------------------------------------------------------------------------------
// initialise.cs
// Code executed by scripts/RPGGame.cs to load up any BoL specific components.
// Copyright (c) 2012 Robert MacGregor
//==============================================================================
exec("scripts/ModScripts/Server/RPG/ClientFunctions.cs");
exec("scripts/ModScripts/Server/RPG/GameTriggers.cs");
exec("scripts/ModScripts/Server/RPG/PDA.cs");
exec("scripts/ModScripts/Server/RPG/RangedVoice.cs");
exec("scripts/ModScripts/Server/RPG/RadioChat.cs");
exec("scripts/ModScripts/Server/RPG/Interact.cs");
|
||||
106
scripts/modscripts/server/RPG/looting.cs
Normal file
106
scripts/modscripts/server/RPG/looting.cs
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
//Component: Lootage
|
||||
//Description: You can loot corpses. (w00t)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// DATABLOCKS
|
||||
//----------------------------------------------------------------------------
|
||||
datablock ItemData(Lootbag)
|
||||
{
|
||||
className = Weapon;
|
||||
catagory = "Misc";
|
||||
shapeFile = "moneybag.dts";
|
||||
mass = 1;
|
||||
elasticity = 0.2;
|
||||
friction = 50;
|
||||
pickupRadius = 2;
|
||||
pickUpPrefix = "a bag of items";
|
||||
alwaysAmbient = true;
|
||||
description = "lootbag_model";
|
||||
|
||||
computeCRC = false;
|
||||
emap = true;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// BOUND FUNCTIONS
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//Realized this isn't required..
|
||||
//function LootBag::onAdd(%this,%obj) //Force a loot check on creation.
|
||||
//{
|
||||
//LootBagCheckForPickUp(%obj);
|
||||
//parent::onAdd(%this,%obj);
|
||||
//}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// FUNCTIONS
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
function LootBagCheckForPickUp(%this) //Not sure why, loot bags won't do a T2 system pickup..
|
||||
{
|
||||
cancel(%this.loop);
|
||||
|
||||
if (!IsObject(%this))
|
||||
return;
|
||||
|
||||
%count = MissionCleanUp.getCount();
|
||||
|
||||
for(%i = 0; %i < %count; %i++)
|
||||
{
|
||||
%test = MissionCleanUp.getObject(%i);
|
||||
|
||||
if (%test.getClassName() $= "Player" && %test.getState() !$= "dead" && !%test.client.isAIControlled())
|
||||
{
|
||||
%dist = vectorDist(%this.getPosition(),%test.getPosition());
|
||||
|
||||
if (%dist < %this.getDatablock().pickUpRadius)
|
||||
{
|
||||
LootBagPickedUp(%this,%test.client);
|
||||
return;
|
||||
}
|
||||
|
||||
%this.loop = schedule(100,0,"LootBagCheckForPickup",%this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function LootBagPickedUp(%this,%client)
|
||||
{
|
||||
%db = %client.player.getDatablock(); //The player's datablock
|
||||
%money = %this.money; //Monies?
|
||||
%numItems = %this.numItems; //Giving out items.
|
||||
%numAmmo = %this.numAmmo; //..Ammo too!
|
||||
//Does the bag have money?
|
||||
if (%money $= "")
|
||||
%hasMoney = false;
|
||||
else
|
||||
%hasMoney = true;
|
||||
|
||||
if (%money !$= "")
|
||||
%client.money = %client.money + %money; //Give some monies.
|
||||
|
||||
for (%i = 0; %i < %numItems; %i++)
|
||||
{
|
||||
if (%db.max[%this.item[%i]] != 0) //Don't want people in light armor running around with mortars, do we?
|
||||
{
|
||||
%client.player.setInventory(%this.item[%i],1);
|
||||
%client.player.setInventory(%this.ammo[%i],%this.ammoNum[%i]);
|
||||
}
|
||||
}
|
||||
%this.delete(); //Delete the bag.
|
||||
|
||||
//Let the player know.
|
||||
switch (%hasMoney)
|
||||
{
|
||||
case 0:
|
||||
if (%numItems > 1)
|
||||
messageClient(%client,'MsgClient','You picked up a bag of items that contained %1 items.',%numitems);
|
||||
else
|
||||
messageClient(%client,'MsgClient','You picked up a bag of items that contained 1 item.');
|
||||
case 1:
|
||||
if (%numItems > 1)
|
||||
messageClient(%client,'MsgClient','You picked up a bag of items that contained $%1 and %2 items.',%money,%numitems);
|
||||
else
|
||||
messageClient(%client,'MsgClient','You picked up a bag of items that contained $%1 and 1 item.',%money);
|
||||
}
|
||||
}
|
||||
39
scripts/modscripts/server/RPG/mining.cs
Normal file
39
scripts/modscripts/server/RPG/mining.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
// -----------------------------------------------------
|
||||
// Datablocks
|
||||
// Note: You can't actually target interiors with beams,
|
||||
// so make an interior and put this box around it.
|
||||
// Copyright (c) 2012 Robert MacGregor
|
||||
// -----------------------------------------------------
|
||||
datablock StaticShapeData(MiningBox) : StaticShapeDamageProfile {
|
||||
className = "MineBox";
|
||||
shapeFile = "Pmiscf.dts";
|
||||
|
||||
maxDamage = 5000;
|
||||
destroyedLevel = 0;
|
||||
disabledLevel = 0;
|
||||
|
||||
isShielded = false;
|
||||
energyPerDamagePoint = 240;
|
||||
|
||||
dynamicType = $TypeMasks::StaticShapeObjectType;
|
||||
deployedObject = true;
|
||||
cmdCategory = "DSupport";
|
||||
cmdIcon = CMDSensorIcon;
|
||||
cmdMiniIconName = "commander/MiniIcons/com_deploymotionsensor";
|
||||
targetNameTag = 'Mining Detection Box';
|
||||
deployAmbientThread = true;
|
||||
debrisShapeName = "debris_generic_small.dts";
|
||||
debris = DeployableDebris;
|
||||
heatSignature = 0;
|
||||
needsPower = false;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Code
|
||||
// Note: Weapon code is in weapons/miningTool.cs
|
||||
// -----------------------------------------------------
|
||||
function MiningBox::onAdd(%this, %obj)
|
||||
{
|
||||
%obj.startFade(1,0,1);
|
||||
%obj.applyDamage(%obj.getDataBlock().maxDamage); //Start the rock off
|
||||
}
|
||||
193
scripts/modscripts/server/RPG/propertyOwning.cs
Normal file
193
scripts/modscripts/server/RPG/propertyOwning.cs
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
// --------------------------------------------------------
|
||||
// A script that allows one to buy property.
|
||||
// The script is in a BETA state, so it may have bugs.
|
||||
//
|
||||
// TODO:
|
||||
// Make the script take rotation into consideration..
|
||||
// Find a way to 'purchase' interiors
|
||||
// --------------------------------------------------------
|
||||
|
||||
function InteriorInstance::buyObject(%this,%objectID,%client,%team)
|
||||
{
|
||||
if (%this.generatorCount $= "")
|
||||
%this.generatorCount = 0;
|
||||
if (%this.inventoryCount $= "")
|
||||
%this.inventoryCount = 0;
|
||||
if (%this.sensorCount $= "")
|
||||
%this.sensorCount = 0;
|
||||
if (%this.sentryCount $= "")
|
||||
%this.sentryCount = 0;
|
||||
if (%this.bannerCount $= "")
|
||||
%this.bannerCount = 0;
|
||||
if (%this.turretBaseCount $= "")
|
||||
%this.turretBaseCount = 0;
|
||||
|
||||
switch(%objectID)
|
||||
{
|
||||
case 0: //Generator
|
||||
if (%this.generatorCount == $Property::Max[%this.interiorFile,0])
|
||||
return false;
|
||||
|
||||
%shape = new StaticShape()
|
||||
{
|
||||
DataBlock = GeneratorLarge;
|
||||
Position = vectorAdd($Property::Offset[%this.interiorFile,0,%this.generatorCount],%this.getPosition());
|
||||
Rotation = $Property::Rotation[%this.interiorFile,0,%this.generatorCount];
|
||||
Team = %team;
|
||||
};
|
||||
|
||||
GeneratorLarge.gainPower(%shape);
|
||||
%this.generatorCount++;
|
||||
|
||||
case 1: //Inventory
|
||||
if (%this.generatorCount == 0 || %this.inventoryCount == $Property::Max[%this.interiorFile,1]) //Don't create if there's no generators
|
||||
return false;
|
||||
|
||||
%shape = new StaticShape()
|
||||
{
|
||||
DataBlock = StationInventory;
|
||||
Position = vectorAdd($Property::Offset[%this.interiorFile,1,%this.inventoryCount],%this.getPosition());
|
||||
Rotation = $Property::Rotation[%this.interiorFile,1,%this.inventoryCount];
|
||||
Team = %team;
|
||||
};
|
||||
|
||||
StationInventory.gainPower(%shape);
|
||||
%this.inventoryCount++;
|
||||
|
||||
case 2: //Sensor (Medium)
|
||||
if (%this.generatorCount == 0 || %this.sensorCount == $Property::Max[%this.interiorFile,2])
|
||||
return false;
|
||||
|
||||
%shape = new StaticShape()
|
||||
{
|
||||
DataBlock = SensorMediumPulse;
|
||||
Position = vectorAdd($Property::Offset[%this.interiorFile,2,%this.sensorCount],%this.getPosition());
|
||||
Rotation = $Property::Rotation[%this.interiorFile,2,%this.sensorCount];
|
||||
Team = %team;
|
||||
};
|
||||
SensorMediumPulse.gainPower(%shape);
|
||||
%this.sensorCount++;
|
||||
|
||||
case 3: //Sensor (Large)
|
||||
if (%this.generatorCount == 0 || %this.sensorCount == $Property::Max[%this.interiorFile,2])
|
||||
return false;
|
||||
|
||||
%shape = new StaticShape()
|
||||
{
|
||||
DataBlock = SensorLargePulse;
|
||||
Position = vectorAdd($Property::Offset[%this.interiorFile,3,%this.sensorCount],%this.getPosition());
|
||||
Rotation = $Property::Rotation[%this.interiorFile,3,%this.sensorCount];
|
||||
Team = %team;
|
||||
};
|
||||
|
||||
SensorLargePulse.gainPower(%shape);
|
||||
%this.sensorCount++;
|
||||
|
||||
case 4: //Sentry Turrets
|
||||
if (%this.generatorCount == 0 || %this.sentryCount == $Property::Max[%this.interiorFile,4])
|
||||
return false;
|
||||
|
||||
%shape = new StaticShape()
|
||||
{
|
||||
DataBlock = SentryTurret;
|
||||
Position = vectorAdd($Property::Offset[%this.interiorFile,4,%this.sentryCount],%this.getPosition());
|
||||
Rotation = $Property::Rotation[%this.interiorFile,4,%this.sentryCount];
|
||||
Team = %team;
|
||||
};
|
||||
SentryTurret.gainPower(%shape);
|
||||
%this.sentryCount++;
|
||||
|
||||
case 5: //Banner (Strength)
|
||||
if (%this.bannerCount == $Property::Max[%this.interiorFile,5])
|
||||
return false;
|
||||
%shape = new StaticShape()
|
||||
{
|
||||
DataBlock = Banner_Strength;
|
||||
Position = vectorAdd($Property::Offset[%this.interiorFile,5,%this.bannerCount],%this.getPosition());
|
||||
Rotation = $Property::Rotation[%this.interiorFile,5,%this.bannerCount];
|
||||
Team = %team;
|
||||
};
|
||||
%this.bannerCount++;
|
||||
|
||||
case 6: //Large Turret Base
|
||||
if (%this.generatorCount == 0 || %this.turretBaseCount == $Property::Max[%this.interiorFile,6])
|
||||
return false;
|
||||
|
||||
%shape = new StaticShape()
|
||||
{
|
||||
DataBlock = TurretBaseLarge;
|
||||
Position = vectorAdd($Property::Offset[%this.interiorFile,6,%this.turretBaseCount],%this.getPosition());
|
||||
Rotation = $Property::Rotation[%this.interiorFile,6,%this.turretBaseCount];
|
||||
Team = %team;
|
||||
};
|
||||
|
||||
%this.turretBaseCount++;
|
||||
}
|
||||
|
||||
%this.getGroup().add(%shape);
|
||||
setTargetName(%shape.target,addTaggedString(%client.namebase @ "'s"));
|
||||
setTargetSensorGroup(%shape.getTarget(), %team);
|
||||
%shape.setSelfPowered();
|
||||
return %shape;
|
||||
}
|
||||
|
||||
function staticShape::setPosition(%this,%pos)
|
||||
{
|
||||
%this.setTransform(%pos);
|
||||
return %this;
|
||||
}
|
||||
|
||||
function staticShape::getRotation(%this)
|
||||
{
|
||||
%trans = %this.getTransform();
|
||||
return getWord(%trans, 3) SPC getWord(%trans, 4) SPC getWord(%trans,5);
|
||||
}
|
||||
|
||||
function objectIDToDatablock(%objectID)
|
||||
{
|
||||
switch(%objectID)
|
||||
{
|
||||
case 0: return "GeneratorLarge";
|
||||
case 1: return 0;
|
||||
default: return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//This the array that stores all the positions and rotations for purchases of objects. I'll eventually move this to be a part of the basicFileProcessing.
|
||||
//Beagle Tower (bbunk2)
|
||||
//Generators
|
||||
$Property::Offset["bbunk2.dif",0,0] = "0.136109 6.92569 3.80877";
|
||||
$Property::Rotation["bbunk2.dif",0,0] = "1 0 0 0";
|
||||
//Inventory
|
||||
$Property::Offset["bbunk2.dif",1,0] = "-13.5045 6.57603 -6.49712";
|
||||
$Property::Rotation["bbunk2.dif",1,0] = "0 0 -1 88.8085";
|
||||
$Property::Offset["bbunk2.dif",1,1] = "13.5045 6.57603 -6.49712";
|
||||
$Property::Rotation["bbunk2.dif",1,1] = "0 0 1 88.8085";
|
||||
//Medium Sensors
|
||||
$Property::Offset["bbunk2.dif",2,0] = "-0.0187805 3.42132 30.8251";
|
||||
$Property::Rotation["bbunk2.dif",2,0] = "1 0 0 0";
|
||||
//Large Sensors
|
||||
$Property::Offset["bbunk2.dif",3,0] = "-0.0187805 3.42132 30.8251";
|
||||
$Property::Rotation["bbunk2.dif",3,0] = "1 0 0 0";
|
||||
//Sentry Turrets
|
||||
$Property::Offset["bbunk2.dif",4,0] = "0.018325 -0.513021 9.99179";
|
||||
$Property::Rotation["bbunk2.dif",4,0] = "0.706825 0.707389 0.000371874 179.92";
|
||||
$Property::Offset["bbunk2.dif",4,1] = "-0.092863 10.5404 -0.443447";
|
||||
$Property::Rotation["bbunk2.dif",4,1] = "0.577209 -0.577449 -0.577392 119.938";
|
||||
//Banners (Strength)
|
||||
$Property::Offset["bbunk2.dif",5,0] = "-0.150952 9.53516 9.82968";
|
||||
$Property::Rotation["bbunk2.dif",5,0] = "0 0 1 179.909";
|
||||
//Large Turret Base
|
||||
$Property::Offset["bbunk2.dif",6,0] = "0.0332212 11.5991 27.9961";
|
||||
$Property::Rotation["bbunk2.dif",6,0] = "1 0 0 0";
|
||||
|
||||
//Max values for each interior
|
||||
$Property::Max["bbunk2.dif",0] = 1; //Max generators
|
||||
$Property::Max["bbunk2.dif",1] = 2; //Max Inventories
|
||||
$Property::Max["bbunk2.dif",2] = 1; //Max Medium Sensors
|
||||
$Property::Max["bbunk2.dif",3] = 1; //Max Large Sensors
|
||||
$Property::Max["bbunk2.dif",4] = 2; //Max Sentry Turrets
|
||||
$Property::Max["bbunk2.dif",5] = 1; //Max Banners (Strength)
|
||||
$Property::Max["bbunk2.dif",6] = 1; //Max Turret Bases
|
||||
50
scripts/modscripts/server/RPG/serverNetworking.cs
Normal file
50
scripts/modscripts/server/RPG/serverNetworking.cs
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// scripts/modScripts/server/serverNetworking.cs
|
||||
// Copyright (c) 2012 Robert MacGregor
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
if (!IsObject(ServerNetwork))
|
||||
new TCPObject(ServerNetwork);
|
||||
|
||||
function ServerNetwork::onConnect(%this)
|
||||
{
|
||||
}
|
||||
|
||||
function ServerNetwork::onConnectFailed(%this)
|
||||
{
|
||||
if (%this.testingServer)
|
||||
{
|
||||
error("Error: Unable to verify connection to server "@%this.testIP@" at port "@%this.testPort@"!");
|
||||
%this.testIP = "";
|
||||
%this.testPort = "";
|
||||
%this.testingServer = false;
|
||||
}
|
||||
}
|
||||
|
||||
function ServerNetwork::onDisconnect(%this)
|
||||
{
|
||||
}
|
||||
|
||||
function ServerNetwork::onDisconnectFailed(%this)
|
||||
{
|
||||
}
|
||||
|
||||
function ServerNetwork::listen(%this)
|
||||
{
|
||||
}
|
||||
|
||||
function ServerNetwork::send(%this)
|
||||
{
|
||||
}
|
||||
|
||||
function ServerNetwork::onLine(%this, %line)
|
||||
{
|
||||
}
|
||||
|
||||
function ServerNetwork::testServerIP(%this, %IP, %port)
|
||||
{
|
||||
%this.testingServer = true;
|
||||
%this.testIP = %ip;
|
||||
%this.testPort = %port;
|
||||
%this.connect(%ip @ ":" @ %port);
|
||||
}
|
||||
182
scripts/modscripts/server/TCPServer.cs
Normal file
182
scripts/modscripts/server/TCPServer.cs
Normal file
|
|
@ -0,0 +1,182 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// TCPServer.cs
|
||||
// Needed this type of thing for communication between servers in the game,
|
||||
// so after some googling -- this is what I put out.
|
||||
// forum.blockland.us/index.php?topic=105360
|
||||
// Copyright (c) 2012 Robert MacGregor
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// Replicate Code for Servers
|
||||
$TCPServer::ServerReplicate = "function *UNIQUESOCKET*::onConnectRequest(%this, %address, %socket)" @
|
||||
"{" @
|
||||
"%this.Parent.connectionCreated(%address, %socket); " @
|
||||
"return true;" @
|
||||
"}";
|
||||
// Replicate Code for Clients
|
||||
$TCPServer::ClientReplicate = "function *UNIQUESOCKET*::onLine(%this, %line)" @
|
||||
"{" @
|
||||
"%this.Parent.onLine(%this, %line);" @
|
||||
"return true;" @
|
||||
"}" @
|
||||
"function *UNIQUESOCKET*::onDisconnect(%this) { %this.Parent.connectionDropped(%this); return true; }";
|
||||
|
||||
function TCPServer::listen(%this, %address, %port, %maxClients)
|
||||
{
|
||||
%uniqueNameLength = 6; // Adjust this if need be, but there should never be a reason to
|
||||
%this.allowMultiConnect = false; // If false, when a client connects twice, its old connection is killed and replaced with a new one.
|
||||
if (%this.isListening)
|
||||
return false;
|
||||
if (%maxClients < 1 || %maxClients == 0)
|
||||
%maxClients = 8;
|
||||
%oldAddr = $Host::BindAddress;
|
||||
%address = strlwr(%address);
|
||||
if (%address $= "local" || %address $="localhost" ) %address = "127.0.0.1";
|
||||
else if (%address $= "any") %address = "0.0.0.0";
|
||||
|
||||
%charList = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
// Generate A name for a TCPObject (and make sure it's unique)
|
||||
%uniqueStringLen = 6; // Adjust this if needed, but there shouldn't be a reason to
|
||||
%uniqueString = "";
|
||||
while (true)
|
||||
{
|
||||
%uniqueString = generateString(%uniqueNameLength, %charList);
|
||||
if (!isObject(%uniqueString)) break;
|
||||
else %uniqueString = "";
|
||||
}
|
||||
%evalCode = $TCPServer::ServerReplicate;
|
||||
%evalCode = strReplace(%evalCode, "*UNIQUESOCKET*", %uniqueString);
|
||||
eval(%evalCode);
|
||||
|
||||
// Generate a list of unique names that this TCPServer will use (to keep down function def count)
|
||||
for (%i = 0; %i < %maxClients; %i++)
|
||||
while (true)
|
||||
{
|
||||
%uniqueName = generateString(%uniqueNameLength, %charList);
|
||||
if (!isObject(%uniqueName))
|
||||
{
|
||||
%eval = strReplace($TCPServer::ClientReplicate, "*UNIQUESOCKET*", %uniqueName);
|
||||
eval(%eval);
|
||||
%this.uniqueName[%i] = %uniqueName;
|
||||
%this.uniqueNameInUse[%uniqueName] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Create the Socket and we'll rock n' roll
|
||||
$Host::BindAddress = %address;
|
||||
%this.Server = new TCPObject(%uniqueString);
|
||||
%this.Server.listen(%port);
|
||||
%this.Server.Parent = %this;
|
||||
%this.connectionCount = 0;
|
||||
%this.maximumClients = %maxClients;
|
||||
$Host::BindAddress = %oldAddr;
|
||||
%this.isListening = true;
|
||||
|
||||
logEcho("Server " @ %uniqueString SPC "is ready on " @ %address @ ":" @ %port);
|
||||
return true;
|
||||
}
|
||||
|
||||
function TCPServer::disconnect(%this)
|
||||
{
|
||||
}
|
||||
|
||||
function TCPServer::connectionDropped(%this, %socket)
|
||||
{
|
||||
if (!%this.allowMultiConnect)
|
||||
%this.connections[%socket.Address] = "";
|
||||
else
|
||||
%this.connections[%socket.Address, %socket.Port] = "";
|
||||
%this.connectionCount--;
|
||||
%this.onClientDisconnect(%socket);
|
||||
}
|
||||
|
||||
function TCPServer::connectionCreated(%this, %address, %socket)
|
||||
{
|
||||
%isReplicate = false;
|
||||
// Get the Port No. and Address respectively
|
||||
%address = strReplace(%address, "IP:","");
|
||||
%portPos = strStr(%address, ":");
|
||||
%port = getSubStr(%address, %portPos+1, strLen(%address));
|
||||
%address = getSubStr(%address, 0, %portPos);
|
||||
if (!%this.allowMultiConnect && %this.connections[%address] != 0)
|
||||
{
|
||||
%this.connections[%address].disconnect();
|
||||
%this.connections[%address].delete();
|
||||
%isReplicate = true;
|
||||
}
|
||||
|
||||
if (%this.connectionCount >= %this.maximumClients)
|
||||
{
|
||||
// Create the connection so we can disconnect it *lol*
|
||||
%connection = new TCPObject(%uniqueName,%socket) { class = ConnectionTCP; parent = %this; Address = %address; Port = %port; };
|
||||
%this.onClientRejected(%connection, 0);
|
||||
logEcho("Unable to accept connection from " @ %address SPC " -- already at maximum client count! (" @ %this.maximumClients @ ")");
|
||||
%connection.disconnect();
|
||||
%connection.delete();
|
||||
return false;
|
||||
}
|
||||
|
||||
// Pick a unique name
|
||||
%uniqueName = "";
|
||||
for (%i = 0; %i < %this.maximumClients; %i++)
|
||||
{
|
||||
%name = %this.uniqueName[%i];
|
||||
if (!%this.uniqueNameInUse[%name])
|
||||
{
|
||||
%uniqueName = %name;
|
||||
%this.uniqueNameInUse[%name] = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
// Create The Client Socket
|
||||
%connection = new TCPObject(%uniqueName,%socket) { class = ConnectionTCP; parent = %this; Address = %address; Port = %port; };
|
||||
|
||||
if (!%this.allowMultiConnect)
|
||||
%this.connections[%address] = %connection;
|
||||
else
|
||||
%this.connections[%address, %port] = %connection;
|
||||
|
||||
%this.connectionCount++;
|
||||
%this.onClientConnect(%address, %connection);
|
||||
logEcho("Received client connection from " @ %address);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// Callbacks -- make these do whatever you please!
|
||||
function TCPServer::onClientConnect(%this, %address, %socket)
|
||||
{
|
||||
%this.client = %socket;
|
||||
echo("Received connection from " @ %address @ ". ID:" @ %socket);
|
||||
return true;
|
||||
}
|
||||
function TCPServer::onClientRejected(%this, %socket, %reason) // %reason is always zero as of now.
|
||||
{
|
||||
return true;
|
||||
}
|
||||
function TCPServer::onClientDisconnect(%this, %socket)
|
||||
{
|
||||
error("Received Disconnect (" @ %socket @ ")");
|
||||
return true;
|
||||
}
|
||||
function TCPServer::onLine(%this, %socket, %line)
|
||||
{
|
||||
messageAll('msgClient',"Telnet: " @ %line);
|
||||
echo(%socket SPC "says: " @ %line);
|
||||
return true;
|
||||
}
|
||||
|
||||
function TCPServer::message(%this, %message)
|
||||
{
|
||||
%this.client.send(%message @ "\n");
|
||||
}
|
||||
|
||||
// Lib Functions
|
||||
function generateString(%length, %alpha)
|
||||
{
|
||||
%len = strLen(%alpha);
|
||||
%result = "";
|
||||
for (%i = 0; %i < %length; %i++)
|
||||
%result = %result @ getSubStr(%alpha, getRandom(0, %len), 1);
|
||||
return %result;
|
||||
}
|
||||
405
scripts/modscripts/server/bloodbioderm.cs
Normal file
405
scripts/modscripts/server/bloodbioderm.cs
Normal file
|
|
@ -0,0 +1,405 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// Bioderm Death Effects v3.0
|
||||
// Effects by: LuCiD
|
||||
//==============================================================================
|
||||
|
||||
// see player.cs for functions.
|
||||
//------------------------------------------------------------------------------
|
||||
// Splash Mist
|
||||
//==============================================================================
|
||||
datablock ParticleData(BiodermPlayerSplashMist)
|
||||
{
|
||||
dragCoefficient = 2.0;
|
||||
gravityCoefficient = -0.05;
|
||||
inheritedVelFactor = 0.0;
|
||||
constantAcceleration = 0.0;
|
||||
lifetimeMS = 600;
|
||||
lifetimeVarianceMS = 100;
|
||||
useInvAlpha = false;
|
||||
spinRandomMin = -90.0;
|
||||
spinRandomMax = 500.0;
|
||||
textureName = "particleTest";
|
||||
colors[0] = "0.1 0.9 0.1 0.5";
|
||||
colors[1] = "0.2 0.09 0.05 0.5";
|
||||
colors[2] = "0.0 0.4 0.0 0.0";
|
||||
sizes[0] = 0.5;
|
||||
sizes[1] = 0.5;
|
||||
sizes[2] = 0.8;
|
||||
times[0] = 0.0;
|
||||
times[1] = 0.5;
|
||||
times[2] = 1.0;
|
||||
};
|
||||
|
||||
datablock ParticleEmitterData(BiodermPlayerSplashMistEmitter)
|
||||
{
|
||||
ejectionPeriodMS = 6;
|
||||
periodVarianceMS = 0;
|
||||
ejectionVelocity = 3.0;
|
||||
velocityVariance = 2.0;
|
||||
ejectionOffset = 0.0;
|
||||
thetaMin = 85;
|
||||
thetaMax = 85;
|
||||
phiReferenceVel = 0;
|
||||
phiVariance = 360;
|
||||
overrideAdvances = false;
|
||||
lifetimeMS = 450;
|
||||
particles = "BiodermPlayerSplashMist";
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Bioderm Green Pool
|
||||
//==============================================================================
|
||||
datablock ShockwaveData(GreenBloodHit)
|
||||
{
|
||||
width = 3.0;
|
||||
numSegments = 164;
|
||||
numVertSegments = 35;
|
||||
velocity = -1.5;
|
||||
acceleration = 2.0;
|
||||
lifetimeMS = 800;
|
||||
height = 0.1;
|
||||
verticalCurve = 0.5;
|
||||
|
||||
mapToTerrain = false;
|
||||
renderBottom = true;
|
||||
orientToNormal = true;
|
||||
|
||||
texture[0] = "special/shockwave4";
|
||||
texture[1] = "special/droplet";//"special/gradient";
|
||||
texWrap = 8.0;
|
||||
|
||||
times[0] = 0.0;
|
||||
times[1] = 0.5;
|
||||
times[2] = 1.0;
|
||||
|
||||
colors[0] = "0.1 0.9 0.1 0.5";
|
||||
colors[1] = "0.5 0.06 0.05 0.5";
|
||||
colors[2] = "0.0 0.4 0.0 0.0";
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Bioderm Blood
|
||||
//==============================================================================
|
||||
datablock ParticleData(BiodermBloodParticle)
|
||||
{
|
||||
dragCoeffiecient = 0.0;
|
||||
gravityCoefficient = 120.0; // drops quickly
|
||||
inheritedVelFactor = 0;
|
||||
|
||||
lifetimeMS = 1600; // lasts 2 second
|
||||
lifetimeVarianceMS = 000; // ...more or less
|
||||
|
||||
textureName = "snowflake8x8";//"particletest";
|
||||
|
||||
useInvAlpha = true;
|
||||
spinRandomMin = -30.0;
|
||||
spinRandomMax = 30.0;
|
||||
|
||||
colors[0] = "0.1 0.9 0.1 0.5";
|
||||
colors[1] = "0.2 0.06 0.05 0.5";
|
||||
colors[2] = "0.0 0.4 0.0 0.0";
|
||||
|
||||
sizes[0] = 0.2;
|
||||
sizes[1] = 0.05;
|
||||
sizes[2] = 0.06;
|
||||
|
||||
times[0] = 0.0;
|
||||
times[1] = 0.2;
|
||||
times[2] = 1.0;
|
||||
};
|
||||
|
||||
datablock ParticleEmitterData(BiodermBloodEmitter)
|
||||
{
|
||||
ejectionPeriodMS = 15;
|
||||
periodVarianceMS = 5;
|
||||
|
||||
ejectionVelocity = 1.25;
|
||||
velocityVariance = 0.50;
|
||||
|
||||
thetaMin = 0.0;
|
||||
thetaMax = 90.0;
|
||||
|
||||
particles = "BiodermBloodParticle";
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Bioderm Droplets Particle
|
||||
//==============================================================================
|
||||
datablock ParticleData( BiodermDropletsParticle )
|
||||
{
|
||||
dragCoefficient = 1;
|
||||
gravityCoefficient = 0.5;
|
||||
inheritedVelFactor = 0.5;
|
||||
constantAcceleration = 0.1;
|
||||
lifetimeMS = 300;
|
||||
lifetimeVarianceMS = 100;
|
||||
textureName = "special/droplet";
|
||||
colors[0] = "0.1 0.9 0.1 1.0";
|
||||
colors[1] = "0.2 0.06 0.05 1.0";
|
||||
colors[2] = "0.0 0.4 0.0 0.0";
|
||||
sizes[0] = 0.8;
|
||||
sizes[1] = 0.3;
|
||||
sizes[2] = 0.0;
|
||||
times[0] = 0.0;
|
||||
times[1] = 0.5;
|
||||
times[2] = 1.0;
|
||||
};
|
||||
|
||||
datablock ParticleEmitterData( BiodermDropletsEmitter )
|
||||
{
|
||||
ejectionPeriodMS = 7;
|
||||
periodVarianceMS = 0;
|
||||
ejectionVelocity = 2;
|
||||
velocityVariance = 1.0;
|
||||
ejectionOffset = 0.0;
|
||||
thetaMin = 60;
|
||||
thetaMax = 80;
|
||||
phiReferenceVel = 0;
|
||||
phiVariance = 360;
|
||||
overrideAdvances = false;
|
||||
orientParticles = true;
|
||||
particles = "BiodermDropletsParticle";
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Bioderm Explosion
|
||||
//==============================================================================
|
||||
datablock ExplosionData(BiodermExplosion)
|
||||
{
|
||||
soundProfile = BloodSplashSound;
|
||||
particleEmitter = BiodermBloodEmitter;
|
||||
particleDensity = 250;
|
||||
particleRadius = 1.25;
|
||||
faceViewer = true;
|
||||
|
||||
emitter[0] = BiodermPlayerSplashMistEmitter;
|
||||
emitter[1] = BiodermDropletsEmitter;
|
||||
shockwave = GreenBloodHit;
|
||||
};
|
||||
|
||||
datablock GrenadeProjectileData(BiodermBlood)
|
||||
{
|
||||
projectileShapeName = "turret_muzzlepoint.dts"; //Really small and hard to see
|
||||
emitterDelay = -1;
|
||||
directDamage = 0.15;
|
||||
hasDamageRadius = false;
|
||||
indirectDamage = 0.0;
|
||||
damageRadius = 0.15;
|
||||
radiusDamageType = $DamageType::ArmorDeath;
|
||||
kickBackStrength = 0;
|
||||
bubbleEmitTime = 1.0;
|
||||
//sound = BloodSplashSound;
|
||||
explosion = BiodermExplosion;
|
||||
//explodeOnMaxBounce = true;
|
||||
velInheritFactor = 0.5;
|
||||
baseEmitter[0] = BiodermBloodEmitter;
|
||||
|
||||
grenadeElasticity = 0.4;
|
||||
grenadeFriction = 0.2;
|
||||
armingDelayMS = 100; // was 400
|
||||
muzzleVelocity = 0;
|
||||
drag = 0.1;
|
||||
|
||||
};
|
||||
//------------------------------------------------------------------------------
|
||||
// Purple Bioderm blood
|
||||
//==============================================================================
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Purple Splash Mist
|
||||
//==============================================================================
|
||||
datablock ParticleData(PurpleBiodermPlayerSplashMist)
|
||||
{
|
||||
dragCoefficient = 2.0;
|
||||
gravityCoefficient = -0.05;
|
||||
inheritedVelFactor = 0.0;
|
||||
constantAcceleration = 0.0;
|
||||
lifetimeMS = 600;
|
||||
lifetimeVarianceMS = 100;
|
||||
useInvAlpha = false;
|
||||
spinRandomMin = -90.0;
|
||||
spinRandomMax = 500.0;
|
||||
textureName = "particleTest";
|
||||
colors[0] = "0.25 0.12 0.40 0.5";
|
||||
colors[1] = "0.25 0.12 0.40 0.5";
|
||||
colors[2] = "0.4 0.0 0.5 0.0";
|
||||
sizes[0] = 0.5;
|
||||
sizes[1] = 0.5;
|
||||
sizes[2] = 0.8;
|
||||
times[0] = 0.0;
|
||||
times[1] = 0.5;
|
||||
times[2] = 1.0;
|
||||
};
|
||||
|
||||
datablock ParticleEmitterData(PurpleBiodermPlayerSplashMistEmitter)
|
||||
{
|
||||
ejectionPeriodMS = 6;
|
||||
periodVarianceMS = 0;
|
||||
ejectionVelocity = 3.0;
|
||||
velocityVariance = 2.0;
|
||||
ejectionOffset = 0.0;
|
||||
thetaMin = 85;
|
||||
thetaMax = 85;
|
||||
phiReferenceVel = 0;
|
||||
phiVariance = 360;
|
||||
overrideAdvances = false;
|
||||
lifetimeMS = 450;
|
||||
particles = "PurpleBiodermPlayerSplashMist";
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Bioderm Purple Pool
|
||||
//==============================================================================
|
||||
datablock ShockwaveData(PurpleBloodHit)
|
||||
{
|
||||
width = 3.0;
|
||||
numSegments = 164;
|
||||
numVertSegments = 35;
|
||||
velocity = -1.5;
|
||||
acceleration = 2.0;
|
||||
lifetimeMS = 800;
|
||||
height = 0.1;
|
||||
verticalCurve = 0.5;
|
||||
|
||||
mapToTerrain = false;
|
||||
renderBottom = true;
|
||||
orientToNormal = true;
|
||||
|
||||
texture[0] = "special/shockwave4";
|
||||
texture[1] = "special/droplet";//"special/gradient";
|
||||
texWrap = 8.0;
|
||||
|
||||
times[0] = 0.0;
|
||||
times[1] = 0.5;
|
||||
times[2] = 1.0;
|
||||
|
||||
colors[0] = "0.25 0.12 0.40 0.5";
|
||||
colors[1] = "0.25 0.12 0.40 0.5";
|
||||
colors[2] = "0.4 0.0 0.5 0.0";
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Purple Bioderm Blood
|
||||
//==============================================================================
|
||||
datablock ParticleData(PurpleBiodermBloodParticle)
|
||||
{
|
||||
dragCoeffiecient = 0.0;
|
||||
gravityCoefficient = 120.0; // drops quickly
|
||||
inheritedVelFactor = 0;
|
||||
|
||||
lifetimeMS = 1550; // lasts 2 second
|
||||
lifetimeVarianceMS = 300; // ...more or less
|
||||
|
||||
textureName = "snowflake8x8";//"particletest";
|
||||
|
||||
useInvAlpha = true;
|
||||
spinRandomMin = -30.0;
|
||||
spinRandomMax = 30.0;
|
||||
|
||||
colors[0] = "0.25 0.12 0.40 0.5";
|
||||
colors[1] = "0.25 0.12 0.40 0.5";
|
||||
colors[2] = "0.4 0.0 0.5 0.0";
|
||||
|
||||
sizes[0] = 0.2;
|
||||
sizes[1] = 0.05;
|
||||
sizes[2] = 0.05;
|
||||
|
||||
times[0] = 0.0;
|
||||
times[1] = 0.2;
|
||||
times[2] = 1.0;
|
||||
};
|
||||
|
||||
datablock ParticleEmitterData(PurpleBiodermBloodEmitter)
|
||||
{
|
||||
ejectionPeriodMS = 15;
|
||||
periodVarianceMS = 5;
|
||||
|
||||
ejectionVelocity = 1.25;
|
||||
velocityVariance = 0.50;
|
||||
|
||||
thetaMin = 0.0;
|
||||
thetaMax = 90.0;
|
||||
|
||||
particles = "PurpleBiodermBloodParticle";
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// purple Bioderm Droplets Particle
|
||||
//==============================================================================
|
||||
datablock ParticleData( PurpleBiodermDropletsParticle )
|
||||
{
|
||||
dragCoefficient = 1;
|
||||
gravityCoefficient = 0.5;
|
||||
inheritedVelFactor = 0.5;
|
||||
constantAcceleration = -0.0;
|
||||
lifetimeMS = 300;
|
||||
lifetimeVarianceMS = 100;
|
||||
textureName = "special/droplet";
|
||||
colors[0] = "0.25 0.12 0.40 0.5";
|
||||
colors[1] = "0.25 0.12 0.40 0.5";
|
||||
colors[2] = "0.4 0.0 0.5 0.0";
|
||||
sizes[0] = 0.8;
|
||||
sizes[1] = 0.3;
|
||||
sizes[2] = 0.0;
|
||||
times[0] = 0.0;
|
||||
times[1] = 0.5;
|
||||
times[2] = 1.0;
|
||||
};
|
||||
|
||||
datablock ParticleEmitterData( PurpleBiodermDropletsEmitter )
|
||||
{
|
||||
ejectionPeriodMS = 7;
|
||||
periodVarianceMS = 0;
|
||||
ejectionVelocity = 2;
|
||||
velocityVariance = 1.0;
|
||||
ejectionOffset = 0.0;
|
||||
thetaMin = 60;
|
||||
thetaMax = 80;
|
||||
phiReferenceVel = 0;
|
||||
phiVariance = 360;
|
||||
overrideAdvances = false;
|
||||
orientParticles = true;
|
||||
particles = "PurpleBiodermDropletsParticle";
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Purple Bioderm Explosion
|
||||
//==============================================================================
|
||||
datablock ExplosionData(PurpleBiodermExplosion)
|
||||
{
|
||||
soundProfile = BloodSplashSound;
|
||||
particleEmitter = PurpleBiodermBloodEmitter;
|
||||
particleDensity = 250;
|
||||
particleRadius = 1.25;
|
||||
faceViewer = true;
|
||||
|
||||
emitter[0] = PurpleBiodermPlayerSplashMistEmitter;
|
||||
emitter[1] = PurpleBiodermDropletsEmitter;
|
||||
shockwave = PurpleBloodHit;
|
||||
};
|
||||
|
||||
datablock GrenadeProjectileData(PurpleBiodermBlood)
|
||||
{
|
||||
projectileShapeName = "turret_muzzlepoint.dts"; //Really small and hard to see
|
||||
emitterDelay = -1;
|
||||
directDamage = 0.0;
|
||||
hasDamageRadius = false;
|
||||
indirectDamage = 0.0;
|
||||
damageRadius = 0.0;
|
||||
radiusDamageType = $DamageType::Default;
|
||||
kickBackStrength = 0;
|
||||
bubbleEmitTime = 1.0;
|
||||
//sound = BloodSplashSound;
|
||||
explosion = PurpleBiodermExplosion;
|
||||
//explodeOnMaxBounce = true;
|
||||
velInheritFactor = 0.5;
|
||||
baseEmitter[0] = PurpleBiodermBloodEmitter;
|
||||
|
||||
grenadeElasticity = 0.4;
|
||||
grenadeFriction = 0.2;
|
||||
armingDelayMS = 100; // was 400
|
||||
muzzleVelocity = 0;
|
||||
drag = 0.1;
|
||||
};
|
||||
|
||||
|
||||
213
scripts/modscripts/server/bloodhuman.cs
Normal file
213
scripts/modscripts/server/bloodhuman.cs
Normal file
|
|
@ -0,0 +1,213 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// Human Death Effects v3.0
|
||||
// Effects By: LuCiD
|
||||
//==============================================================================
|
||||
|
||||
// see player.cs for functions.
|
||||
datablock AudioProfile(BloodSplashSound)
|
||||
{
|
||||
filename = "fx/armor/light_LF_water.wav";
|
||||
description = AudioClosest3d;
|
||||
preload = true;
|
||||
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Splash Mist
|
||||
//==============================================================================
|
||||
datablock ParticleData(HumanRedPlayerSplashMist)
|
||||
{
|
||||
dragCoefficient = 2.0;
|
||||
gravityCoefficient = -0.05;
|
||||
inheritedVelFactor = 0.0;
|
||||
constantAcceleration = 0.0;
|
||||
lifetimeMS = 600;
|
||||
lifetimeVarianceMS = 100;
|
||||
useInvAlpha = false;
|
||||
spinRandomMin = -90.0;
|
||||
spinRandomMax = 500.0;
|
||||
textureName = "particleTest";
|
||||
colors[0] = "0.9 0.1 0.1 0.5";
|
||||
colors[1] = "0.6 0.05 0.05 0.5";
|
||||
colors[2] = "0.4 0.0 0.0 0.0";
|
||||
sizes[0] = 0.5;
|
||||
sizes[1] = 0.5;
|
||||
sizes[2] = 0.8;
|
||||
times[0] = 0.0;
|
||||
times[1] = 0.5;
|
||||
times[2] = 1.0;
|
||||
};
|
||||
|
||||
datablock ParticleEmitterData(HumanRedPlayerSplashMistEmitter)
|
||||
{
|
||||
ejectionPeriodMS = 6;
|
||||
periodVarianceMS = 1;
|
||||
ejectionVelocity = 4.0;
|
||||
velocityVariance = 2.0;
|
||||
ejectionOffset = 0.0;
|
||||
thetaMin = 85;
|
||||
thetaMax = 85;
|
||||
phiReferenceVel = 0;
|
||||
phiVariance = 360;
|
||||
overrideAdvances = false;
|
||||
lifetimeMS = 450;
|
||||
particles = "HumanRedPlayerSplashMist";
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Human Red Pool
|
||||
//==============================================================================
|
||||
datablock ShockwaveData(RedBloodHit)
|
||||
{
|
||||
width = 3.0;
|
||||
numSegments = 164;
|
||||
numVertSegments = 35;
|
||||
velocity = -1.5;
|
||||
acceleration = 2.0;
|
||||
lifetimeMS = 800;
|
||||
height = 0.1;
|
||||
verticalCurve = 0.5;
|
||||
|
||||
mapToTerrain = false;
|
||||
renderBottom = true;
|
||||
orientToNormal = true;
|
||||
|
||||
texture[0] = "special/shockwave4";
|
||||
texture[1] = "special/droplet";//"special/gradient";
|
||||
texWrap = 8.0;
|
||||
|
||||
times[0] = 0.0;
|
||||
times[1] = 0.5;
|
||||
times[2] = 1.0;
|
||||
|
||||
colors[0] = "0.9 0.1 0.1 0.5";
|
||||
colors[1] = "0.6 0.05 0.05 0.5";
|
||||
colors[2] = "0.4 0.0 0.0 0.0";
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Human Red Blood
|
||||
//==============================================================================
|
||||
datablock ParticleData(HumanRedBloodParticle)
|
||||
{
|
||||
dragCoeffiecient = 0.0;
|
||||
gravityCoefficient = 120.0;
|
||||
inheritedVelFactor = 0.0;
|
||||
|
||||
lifetimeMS = 1600;
|
||||
lifetimeVarianceMS = 000;
|
||||
|
||||
textureName = "snowflake8x8";//"particletest";
|
||||
|
||||
useInvAlpha = true;
|
||||
spinRandomMin = -30.0;
|
||||
spinRandomMax = 30.0;
|
||||
|
||||
colors[0] = "0.9 0.1 0.1 0.5";
|
||||
colors[1] = "0.6 0.05 0.05 0.5";
|
||||
colors[2] = "0.4 0.0 0.0 0.0";
|
||||
|
||||
sizes[0] = 0.2;
|
||||
sizes[1] = 0.05;
|
||||
sizes[2] = 0.06;
|
||||
|
||||
times[0] = 0.0;
|
||||
times[1] = 0.2;
|
||||
times[2] = 1.0;
|
||||
};
|
||||
|
||||
datablock ParticleEmitterData(HumanRedBloodEmitter)
|
||||
{
|
||||
ejectionPeriodMS = 15;
|
||||
periodVarianceMS = 5;
|
||||
|
||||
ejectionVelocity = 1.25;
|
||||
velocityVariance = 0.50;
|
||||
|
||||
thetaMin = 0.0;
|
||||
thetaMax = 90.0;
|
||||
|
||||
particles = "HumanRedBloodParticle";
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Human Red Droplets Particle
|
||||
//==============================================================================
|
||||
datablock ParticleData( HumanRedDropletsParticle )
|
||||
{
|
||||
dragCoefficient = 1;
|
||||
gravityCoefficient = 0.5;
|
||||
inheritedVelFactor = 0.5;
|
||||
constantAcceleration = 0.1;
|
||||
lifetimeMS = 300;
|
||||
lifetimeVarianceMS = 100;
|
||||
textureName = "special/droplet";
|
||||
colors[0] = "0.9 0.1 0.1 1.0";
|
||||
colors[1] = "0.6 0.05 0.05 1.0";
|
||||
colors[2] = "0.4 0.0 0.0 0.0";
|
||||
sizes[0] = 0.8;
|
||||
sizes[1] = 0.3;
|
||||
sizes[2] = 0.0;
|
||||
times[0] = 0.0;
|
||||
times[1] = 0.5;
|
||||
times[2] = 1.0;
|
||||
};
|
||||
|
||||
datablock ParticleEmitterData( HumanRedDropletsEmitter )
|
||||
{
|
||||
ejectionPeriodMS = 7;
|
||||
periodVarianceMS = 0;
|
||||
ejectionVelocity = 2;
|
||||
velocityVariance = 1.0;
|
||||
ejectionOffset = 0.0;
|
||||
thetaMin = 60;
|
||||
thetaMax = 80;
|
||||
phiReferenceVel = 0;
|
||||
phiVariance = 360;
|
||||
overrideAdvances = false;
|
||||
orientParticles = true;
|
||||
particles = "HumanRedDropletsParticle";
|
||||
};
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Human Red Explosion
|
||||
//==============================================================================
|
||||
datablock ExplosionData(HumanRedExplosion)
|
||||
{
|
||||
soundProfile = BloodSplashSound;
|
||||
particleEmitter = HumanRedBloodEmitter;
|
||||
particleDensity = 250;
|
||||
particleRadius = 1.25;
|
||||
faceViewer = true;
|
||||
|
||||
emitter[0] = HumanRedPlayerSplashMistEmitter;
|
||||
emitter[1] = HumanRedDropletsEmitter;
|
||||
shockwave = RedBloodHit;
|
||||
};
|
||||
|
||||
datablock GrenadeProjectileData(HumanBlood)
|
||||
{
|
||||
projectileShapeName = "turret_muzzlepoint.dts"; //Really small and hard to see
|
||||
emitterDelay = -1;
|
||||
directDamage = 0.0;
|
||||
hasDamageRadius = false;
|
||||
indirectDamage = 0.0;
|
||||
damageRadius = 0.0;
|
||||
radiusDamageType = $DamageType::Default;
|
||||
kickBackStrength = 0;
|
||||
bubbleEmitTime = 1.0;
|
||||
//sound = BloodSplashSound;
|
||||
explosion = HumanRedExplosion;
|
||||
//explodeOnMaxBounce = true;
|
||||
velInheritFactor = 0.5;
|
||||
baseEmitter[0] = HumanRedBloodEmitter;
|
||||
|
||||
grenadeElasticity = 0.4;
|
||||
grenadeFriction = 0.2;
|
||||
armingDelayMS = 100; // was 400
|
||||
muzzleVelocity = 0;
|
||||
drag = 0.1;
|
||||
|
||||
};
|
||||
|
||||
|
||||
301
scripts/modscripts/server/dataImport.cs
Normal file
301
scripts/modscripts/server/dataImport.cs
Normal file
|
|
@ -0,0 +1,301 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// scripts/modScripts/server/dataImport.cs
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
function gameConnection::writeSaveFile(%this)
|
||||
{
|
||||
//Compile Main Variable List
|
||||
%mission = $CurrentMission;
|
||||
%player = %this.player;
|
||||
%transform = %player.getTransform();
|
||||
%velocity = %player.getVelocity();
|
||||
%damage = %player.getDamageLevel();
|
||||
%race = %this.race;
|
||||
%armor = %this.armor;
|
||||
%energy = %player.getEnergyLevel();
|
||||
%whiteout = %player.getWhiteout();
|
||||
%damageFlash = %player.getDamageFlash();
|
||||
%cash = %this.cash;
|
||||
%hasRadio = %this.hasRadio;
|
||||
%underStandsHuman = %this.underStandsHuman;
|
||||
%underStandsBioderm = %this.underStandsBioderm;
|
||||
%underStandsDraakan = %this.underStandsDraakan;
|
||||
%underStandsCriollos = %this.underStandsCriollos;
|
||||
|
||||
%time = formatTimeString("hh:nn A");
|
||||
%date = formatTimeString("mm/dd/yy");
|
||||
|
||||
%file = "data/game/saves/" @ %mission @ "/" @ %this.guid @ ".txt";
|
||||
%fileObj = new fileObject();
|
||||
%fileObj.openForWrite(%file);
|
||||
%fileObj.writeLine(";Saved by" SPC %this.nameBase SPC "on" SPC %date SPC "at" SPC %time);
|
||||
%fileObj.writeLine("");
|
||||
|
||||
//Todo: Make this writing method more efficient ...
|
||||
%fileObj.writeLine("[Character]");
|
||||
%fileObj.writeLine("transform = \x22" @ %transform @ "\x22;");
|
||||
%fileObj.writeLine("velocity = \x22" @ %velocity @ "\x22;");
|
||||
%fileObj.writeLine("damage = \x22" @ %damage @ "\x22;");
|
||||
%fileObj.writeLine("race = \x22" @ %race @ "\x22;");
|
||||
%fileObj.writeLine("armor = \x22" @ %armor @ "\x22;");
|
||||
%fileObj.writeLine("energy = \x22" @ %energy @ "\x22;");
|
||||
%fileObj.writeLine("whiteOut = \x22" @ %whiteout @ "\x22;");
|
||||
%fileObj.writeLine("damageFlash = \x22" @ %damageFlash @ "\x22;");
|
||||
%fileObj.writeLine("cash = \x22" @ %cash @ "\x22;");
|
||||
%fileObj.writeLine("hasRadio = \x22" @ %hasRadio @ "\x22;");
|
||||
%fileObj.writeLine("underStandsHuman = \x22" @ %underStandsHuman @ "\x22;");
|
||||
%fileObj.writeLine("underStandsBioderm = \x22" @ %underStandsBioderm @ "\x22;");
|
||||
%fileObj.writeLine("underStandsDraakan = \x22" @ %underStandsDraakan @ "\x22;");
|
||||
%fileObj.writeLine("underStandsCriollos = \x22" @ %underStandsCriollos @ "\x22;");
|
||||
%fileObj.writeLine("");
|
||||
|
||||
//Compile Inventory List
|
||||
%slotCount = %player.weaponSlotCount;
|
||||
%healthKits = %player.invRepairKit;
|
||||
%fileObj.writeLine("[Inventory]");
|
||||
%fileObj.writeLine("slotCount = \x22" @ %slotCount @ "\x22;");
|
||||
|
||||
for (%i = 0; %i < %slotCount; %i++)
|
||||
{
|
||||
%weaponName = %player.weaponSlot[%i];
|
||||
%weaponAmmo = eval("%weaponAmmo = %player.inv" @ %weaponName @ "Ammo" @ ";");
|
||||
%fileObj.writeLine("slot" @ %i SPC "= \x22" @ %weaponName @ "\x22;");
|
||||
%fileObj.writeLine("slot" @ %i @ "Ammo" SPC "= \x22" @ %weaponAmmo @ "\x22;");
|
||||
}
|
||||
|
||||
%fileObj.writeLine("healthKits = \x22" @ %healthKits @ "\x22;");
|
||||
%fileObj.detach();
|
||||
logEcho(" -- Save File Written for Player:" SPC %this.namebase SPC "--");
|
||||
return true;
|
||||
}
|
||||
|
||||
function gameConnection::applySaveFile(%this)
|
||||
{
|
||||
//Compile Main Variable List
|
||||
%mission = $CurrentMission;
|
||||
%file = "data/game/saves/" @ %mission @ "/" @ %this.guid @ ".txt";
|
||||
|
||||
if (!isFile(%file))
|
||||
return false;
|
||||
|
||||
%transform = getBlockData(%file,"Character",1,"transform");
|
||||
%velocity = getBlockData(%file,"Character",1,"velocity");
|
||||
%damage = getBlockData(%file,"Character",1,"damage");
|
||||
%race = getBlockData(%file,"Character",1,"race");
|
||||
%armor = getBlockData(%file,"Character",1,"armor");
|
||||
%energy = getBlockData(%file,"Character",1,"energyLevel");
|
||||
%whiteout = getBlockData(%file,"Character",1,"whiteOut");
|
||||
%damageFlash = getBlockData(%file,"Character",1,"damageFlash");
|
||||
%cash = getBlockData(%file,"Character",1,"cash");
|
||||
%hasRadio = getBlockData(%file,"Character",1,"hasRadio");
|
||||
%underStandsHuman = getBlockData(%file,"Character",1,"underStandsHuman");
|
||||
%underStandsBioderm = getBlockData(%file,"Character",1,"underStandsBioderm");
|
||||
%underStandsDraakan = getBlockData(%file,"Character",1,"underStandsDraakan");
|
||||
%underStandsCriollos = getBlockData(%file,"Character",1,"underStandsCriollos");
|
||||
|
||||
%player = %this.player;
|
||||
%player.setTransform(%transform);
|
||||
%player.setVelocity(%velocity);
|
||||
%player.applyDamage(%damage);
|
||||
%player.setArmor(%armor);
|
||||
%player.setEnergyLevel(%energy);
|
||||
%player.setWhiteout(%whiteOut);
|
||||
%player.setDamageFlash(%damageFlash);
|
||||
%this.cash = %cash;
|
||||
%this.underStandsHuman = %underStandsHuman;
|
||||
%this.underStandsBioderm = %underStandsBioderm;
|
||||
%this.underStandsDraakan = %underStandsDraakan;
|
||||
%this.underStandsCriollos = %underStandsCriollos;
|
||||
|
||||
return true;
|
||||
for (%i = 0; %i < %slotCount; %i++)
|
||||
{
|
||||
%weaponName = %player.weaponSlot[%i];
|
||||
%weaponAmmo = eval("%weaponAmmo = %player.inv" @ %weaponName @ "Ammo" @ ";");
|
||||
%fileObj.writeLine("slot" @ %i SPC "= \x22" @ %weaponName @ "\x22;");
|
||||
%fileObj.writeLine("slot" @ %i @ "Ammo" SPC "= \x22" @ %weaponAmmo @ "\x22;");
|
||||
}
|
||||
|
||||
%fileObj.writeLine("healthKits = \x22" @ %healthKits @ "\x22;");
|
||||
return;
|
||||
}
|
||||
|
||||
// Generic Import Functions
|
||||
function importGameData()
|
||||
{
|
||||
importGems();
|
||||
importOres();
|
||||
importCharacters();
|
||||
return true;
|
||||
}
|
||||
|
||||
// Gem Import Functions
|
||||
function importGems()
|
||||
{
|
||||
if (!IsObject(GemData))
|
||||
{
|
||||
new ScriptObject(GemData);
|
||||
|
||||
if (!IsObject(GameData))
|
||||
new simGroup(GameData);
|
||||
|
||||
GameData.add(GemData);
|
||||
}
|
||||
else
|
||||
return true;
|
||||
|
||||
%file = "data/game/gems.txt";
|
||||
%count = getBlockCount(%file,"Gem") + 1;
|
||||
|
||||
for (%i = 1; %i < %count; %i++)
|
||||
{
|
||||
%name = getBlockData(%file,"Gem",%i,"Name");
|
||||
%price = getBlockData(%file,"Gem",%i,"Price");
|
||||
%sellPrice = getBlockData(%file,"Gem",%i,"SellPrice");
|
||||
|
||||
GemData.gem[%i] = %name;
|
||||
GemData.price[%name] = %price;
|
||||
GemData.sellPrice[%name] = %sellPrice;
|
||||
warn("Imported gem:" SPC %name);
|
||||
|
||||
GemData.gemCount = %count--;
|
||||
}
|
||||
|
||||
// Ore Import Functions
|
||||
function importOres()
|
||||
{
|
||||
if (!IsObject(OreData))
|
||||
{
|
||||
new ScriptObject(OreData);
|
||||
|
||||
if (!IsObject(GameData))
|
||||
new simGroup(GameData);
|
||||
|
||||
GameData.add(OreData);
|
||||
}
|
||||
else
|
||||
return true;
|
||||
|
||||
%file = "data/game/ores.txt";
|
||||
%count = getBlockCount(%file,"Ore") + 1;
|
||||
|
||||
for (%i = 1; %i < %count; %i++)
|
||||
{
|
||||
%name = getBlockData(%file,"Ore",%i,"Name");
|
||||
%price = getBlockData(%file,"Ore",%i,"Price");
|
||||
%sellPrice = getBlockData(%file,"Ore",%i,"SellPrice");
|
||||
|
||||
OreData.ore[%i] = %name;
|
||||
OreData.price[%name] = %price;
|
||||
OreData.sellPrice[%name] = %sellPrice;
|
||||
warn("Imported ore:" SPC %name);
|
||||
}
|
||||
OreData.oreCount = %count--;
|
||||
}
|
||||
|
||||
// Character Import Functions
|
||||
function spawnCharacter(%name,%trans,%aimPos,%team)
|
||||
{
|
||||
%object = "Character" @ %name;
|
||||
|
||||
if (!IsObject(%object))
|
||||
return false;
|
||||
|
||||
%Bname = %object.name;
|
||||
%race = %object.race;
|
||||
%skin = %object.skin;
|
||||
%voice = %object.voice;
|
||||
%voicePitch = %object.voicePitch;
|
||||
%sex = %object.sex;
|
||||
|
||||
%bot = aiConnectByName(%Bname,%team);
|
||||
%bot.race = %race;
|
||||
%bot.skin = addTaggedString(%skin);
|
||||
%bot.voice = %voice;
|
||||
%bot.voiceTag = addTaggedString(%voice);
|
||||
%bot.voicePitch = %voicePitch;
|
||||
%bot.sex = %sex;
|
||||
setVoice(%bot,%voice, %voicePitch);
|
||||
setSkin(%bot,%skin);
|
||||
setSkin(%bot,%skin);
|
||||
setTeam(%bot, %team);
|
||||
%bot.player.setArmor("light");
|
||||
%bot.player.setTransform(%trans);
|
||||
%bot.aimAt(%aimPos);
|
||||
warn("Spawned Character:" SPC %name);
|
||||
}
|
||||
|
||||
function importCharacters()
|
||||
{
|
||||
%path = "data/game/characters/*.txt";
|
||||
for( %file = findFirstFile( %path ); %file !$= ""; %file = findNextFile( %path ) )
|
||||
{
|
||||
%name = getFileNameFromString(%file);
|
||||
%pos = strStr(%name,".");
|
||||
%character = getSubStr(%name,0,%pos);
|
||||
importCharacter(%character);
|
||||
}
|
||||
}
|
||||
|
||||
function importCharacter(%character)
|
||||
{
|
||||
%prefix = "data/game/characters/";
|
||||
%file = %prefix @ %character @ ".txt";
|
||||
%charName = %character;
|
||||
%character = strReplace("Character" @ %character," ","_");
|
||||
|
||||
if (!IsFile(%file))
|
||||
return false;
|
||||
|
||||
if (!IsObject(%character))
|
||||
{
|
||||
new scriptObject(%character);
|
||||
if (!IsObject(GameData))
|
||||
new simGroup(GameData);
|
||||
|
||||
GameData.add(%character);
|
||||
}
|
||||
else
|
||||
return true;
|
||||
|
||||
//Get our variable values ...
|
||||
%name = getBlockData(%file,"Character",1,"Name");
|
||||
%race = getBlockData(%file,"Character",1,"Race");
|
||||
%sex = getBlockData(%file,"Character",1,"Sex");
|
||||
%skin = getBlockData(%file,"Character",1,"Skin");
|
||||
%voice = getBlockData(%file,"Character",1,"Voice");
|
||||
%voicePitch = getBlockData(%file,"Character",1,"VoicePitch");
|
||||
|
||||
//Import Message Arrays ... and assign them
|
||||
%arrayName[0] = "Death";
|
||||
%arrayName[1] = "Kill";
|
||||
%arrayName[2] = "Healed";
|
||||
%arrayCount = 3;
|
||||
|
||||
for (%i = 0; %i < %arrayCount; %i++)
|
||||
{
|
||||
%arrayVariableName[%i] = %arrayName[%i] @ "MessageArray";
|
||||
for (%j = 0; %j < 100; %j++)
|
||||
{
|
||||
%arrayTest = getArrayData(%file,%arrayName[%i],%j);
|
||||
if (%arrayTest !$= "}")
|
||||
{
|
||||
if (%j == 0)
|
||||
%arrayData[%i] = %arrayData[%i] @ %arrayTest;
|
||||
else
|
||||
%arrayData[%i] = %arrayData[%i] @ "\t" @ %arrayTest;
|
||||
}
|
||||
else
|
||||
break;
|
||||
}
|
||||
eval(%character @ "." @ %arrayVariableName[%i] SPC "= \x22" @ %arrayData[%i] @ "\x22;");
|
||||
}
|
||||
//Assign the variables now ...
|
||||
%character.name = %name;
|
||||
%character.race = %race;
|
||||
%character.sex = %sex;
|
||||
%character.skin = %skin;
|
||||
%character.voice = %voice;
|
||||
%character.voicePitch = %voicePitch;
|
||||
warn("Imported Character:" SPC %charname);
|
||||
}
|
||||
13
scripts/modscripts/server/initialize.cs
Normal file
13
scripts/modscripts/server/initialize.cs
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// Server Scripts Init
|
||||
//==============================================================================
|
||||
exec("scripts/modScripts/server/propData.cs");
|
||||
exec("scripts/modScripts/server/mining.cs");
|
||||
exec("scripts/modScripts/server/propertyOwning.cs");
|
||||
exec("scripts/modScripts/server/looting.cs");
|
||||
exec("scripts/modScripts/server/serverFunctions.cs");
|
||||
exec("scripts/modScripts/server/bloodHuman.cs");
|
||||
exec("scripts/modScripts/server/bloodBioderm.cs");
|
||||
exec("scripts/modScripts/server/dataImport.cs");
|
||||
exec("scripts/modScripts/server/serverNetworking.cs");
|
||||
|
||||
106
scripts/modscripts/server/looting.cs
Normal file
106
scripts/modscripts/server/looting.cs
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
//Component: Lootage
|
||||
//Description: You can loot corpses. (w00t)
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// DATABLOCKS
|
||||
//----------------------------------------------------------------------------
|
||||
datablock ItemData(Lootbag)
|
||||
{
|
||||
className = Weapon;
|
||||
catagory = "Misc";
|
||||
shapeFile = "moneybag.dts";
|
||||
mass = 1;
|
||||
elasticity = 0.2;
|
||||
friction = 50;
|
||||
pickupRadius = 2;
|
||||
pickUpPrefix = "a bag of items";
|
||||
alwaysAmbient = true;
|
||||
description = "lootbag_model";
|
||||
|
||||
computeCRC = false;
|
||||
emap = true;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// BOUND FUNCTIONS
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
//Realized this isn't required..
|
||||
//function LootBag::onAdd(%this,%obj) //Force a loot check on creation.
|
||||
//{
|
||||
//LootBagCheckForPickUp(%obj);
|
||||
//parent::onAdd(%this,%obj);
|
||||
//}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// FUNCTIONS
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
function LootBagCheckForPickUp(%this) //Not sure why, loot bags won't do a T2 system pickup..
|
||||
{
|
||||
cancel(%this.loop);
|
||||
|
||||
if (!IsObject(%this))
|
||||
return;
|
||||
|
||||
%count = MissionCleanUp.getCount();
|
||||
|
||||
for(%i = 0; %i < %count; %i++)
|
||||
{
|
||||
%test = MissionCleanUp.getObject(%i);
|
||||
|
||||
if (%test.getClassName() $= "Player" && %test.getState() !$= "dead" && !%test.client.isAIControlled())
|
||||
{
|
||||
%dist = vectorDist(%this.getPosition(),%test.getPosition());
|
||||
|
||||
if (%dist < %this.getDatablock().pickUpRadius)
|
||||
{
|
||||
LootBagPickedUp(%this,%test.client);
|
||||
return;
|
||||
}
|
||||
|
||||
%this.loop = schedule(100,0,"LootBagCheckForPickup",%this);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function LootBagPickedUp(%this,%client)
|
||||
{
|
||||
%db = %client.player.getDatablock(); //The player's datablock
|
||||
%money = %this.money; //Monies?
|
||||
%numItems = %this.numItems; //Giving out items.
|
||||
%numAmmo = %this.numAmmo; //..Ammo too!
|
||||
//Does the bag have money?
|
||||
if (%money $= "")
|
||||
%hasMoney = false;
|
||||
else
|
||||
%hasMoney = true;
|
||||
|
||||
if (%money !$= "")
|
||||
%client.money = %client.money + %money; //Give some monies.
|
||||
|
||||
for (%i = 0; %i < %numItems; %i++)
|
||||
{
|
||||
if (%db.max[%this.item[%i]] != 0) //Don't want people in light armor running around with mortars, do we?
|
||||
{
|
||||
%client.player.setInventory(%this.item[%i],1);
|
||||
%client.player.setInventory(%this.ammo[%i],%this.ammoNum[%i]);
|
||||
}
|
||||
}
|
||||
%this.delete(); //Delete the bag.
|
||||
|
||||
//Let the player know.
|
||||
switch (%hasMoney)
|
||||
{
|
||||
case 0:
|
||||
if (%numItems > 1)
|
||||
messageClient(%client,'MsgClient','You picked up a bag of items that contained %1 items.',%numitems);
|
||||
else
|
||||
messageClient(%client,'MsgClient','You picked up a bag of items that contained 1 item.');
|
||||
case 1:
|
||||
if (%numItems > 1)
|
||||
messageClient(%client,'MsgClient','You picked up a bag of items that contained $%1 and %2 items.',%money,%numitems);
|
||||
else
|
||||
messageClient(%client,'MsgClient','You picked up a bag of items that contained $%1 and 1 item.',%money);
|
||||
}
|
||||
}
|
||||
38
scripts/modscripts/server/mining.cs
Normal file
38
scripts/modscripts/server/mining.cs
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
// -----------------------------------------------------
|
||||
// Datablocks
|
||||
// Note: You can't actually target interiors with beams,
|
||||
// so make an interior and put this box around it.
|
||||
// -----------------------------------------------------
|
||||
datablock StaticShapeData(MiningBox) : StaticShapeDamageProfile {
|
||||
className = "MineBox";
|
||||
shapeFile = "Pmiscf.dts";
|
||||
|
||||
maxDamage = 5000;
|
||||
destroyedLevel = 0;
|
||||
disabledLevel = 0;
|
||||
|
||||
isShielded = false;
|
||||
energyPerDamagePoint = 240;
|
||||
|
||||
dynamicType = $TypeMasks::StaticShapeObjectType;
|
||||
deployedObject = true;
|
||||
cmdCategory = "DSupport";
|
||||
cmdIcon = CMDSensorIcon;
|
||||
cmdMiniIconName = "commander/MiniIcons/com_deploymotionsensor";
|
||||
targetNameTag = 'Mining Detection Box';
|
||||
deployAmbientThread = true;
|
||||
debrisShapeName = "debris_generic_small.dts";
|
||||
debris = DeployableDebris;
|
||||
heatSignature = 0;
|
||||
needsPower = false;
|
||||
};
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Code
|
||||
// Note: Weapon code is in weapons/miningTool.cs
|
||||
// -----------------------------------------------------
|
||||
function MiningBox::onAdd(%this, %obj)
|
||||
{
|
||||
%obj.startFade(1,0,1);
|
||||
%obj.applyDamage(%obj.getDataBlock().maxDamage); //Start the rock off
|
||||
}
|
||||
44
scripts/modscripts/server/propData.cs
Normal file
44
scripts/modscripts/server/propData.cs
Normal file
|
|
@ -0,0 +1,44 @@
|
|||
//Component: Destructable Props
|
||||
//Description: Not much to describe.. stuff that blows up or can be broken.
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// DATABLOCKS
|
||||
//----------------------------------------------------------------------------
|
||||
datablock StaticShapeData(DeployedSpine) : StaticShapeDamageProfile {
|
||||
className = "spine";
|
||||
shapeFile = "Pmiscf.dts";
|
||||
|
||||
maxDamage = 0.5;
|
||||
destroyedLevel = 0.5;
|
||||
disabledLevel = 0.3;
|
||||
|
||||
isShielded = true;
|
||||
energyPerDamagePoint = 240;
|
||||
maxEnergy = 50;
|
||||
rechargeRate = 0.25;
|
||||
|
||||
explosion = HandGrenadeExplosion;
|
||||
expDmgRadius = 3.0;
|
||||
expDamage = 0.1;
|
||||
expImpulse = 200.0;
|
||||
|
||||
dynamicType = $TypeMasks::StaticShapeObjectType;
|
||||
deployedObject = true;
|
||||
cmdCategory = "DSupport";
|
||||
cmdIcon = CMDSensorIcon;
|
||||
cmdMiniIconName = "commander/MiniIcons/com_deploymotionsensor";
|
||||
targetNameTag = 'Light Support Beam';
|
||||
deployAmbientThread = true;
|
||||
debrisShapeName = "debris_generic_small.dts";
|
||||
debris = DeployableDebris;
|
||||
heatSignature = 0;
|
||||
needsPower = true;
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
// FUNCTIONS
|
||||
//----------------------------------------------------------------------------
|
||||
function DetructableSecurityCamera::onDestroyed(%this, %obj)
|
||||
{
|
||||
schedule(1000,0,"delete",%obj);
|
||||
}
|
||||
193
scripts/modscripts/server/propertyOwning.cs
Normal file
193
scripts/modscripts/server/propertyOwning.cs
Normal file
|
|
@ -0,0 +1,193 @@
|
|||
// --------------------------------------------------------
|
||||
// A script that allows one to buy property.
|
||||
// The script is in a BETA state, so it may have bugs.
|
||||
//
|
||||
// TODO:
|
||||
// Make the script take rotation into consideration..
|
||||
// Find a way to 'purchase' interiors
|
||||
// --------------------------------------------------------
|
||||
|
||||
function InteriorInstance::buyObject(%this,%objectID,%client,%team)
|
||||
{
|
||||
if (%this.generatorCount $= "")
|
||||
%this.generatorCount = 0;
|
||||
if (%this.inventoryCount $= "")
|
||||
%this.inventoryCount = 0;
|
||||
if (%this.sensorCount $= "")
|
||||
%this.sensorCount = 0;
|
||||
if (%this.sentryCount $= "")
|
||||
%this.sentryCount = 0;
|
||||
if (%this.bannerCount $= "")
|
||||
%this.bannerCount = 0;
|
||||
if (%this.turretBaseCount $= "")
|
||||
%this.turretBaseCount = 0;
|
||||
|
||||
switch(%objectID)
|
||||
{
|
||||
case 0: //Generator
|
||||
if (%this.generatorCount == $Property::Max[%this.interiorFile,0])
|
||||
return false;
|
||||
|
||||
%shape = new StaticShape()
|
||||
{
|
||||
DataBlock = GeneratorLarge;
|
||||
Position = vectorAdd($Property::Offset[%this.interiorFile,0,%this.generatorCount],%this.getPosition());
|
||||
Rotation = $Property::Rotation[%this.interiorFile,0,%this.generatorCount];
|
||||
Team = %team;
|
||||
};
|
||||
|
||||
GeneratorLarge.gainPower(%shape);
|
||||
%this.generatorCount++;
|
||||
|
||||
case 1: //Inventory
|
||||
if (%this.generatorCount == 0 || %this.inventoryCount == $Property::Max[%this.interiorFile,1]) //Don't create if there's no generators
|
||||
return false;
|
||||
|
||||
%shape = new StaticShape()
|
||||
{
|
||||
DataBlock = StationInventory;
|
||||
Position = vectorAdd($Property::Offset[%this.interiorFile,1,%this.inventoryCount],%this.getPosition());
|
||||
Rotation = $Property::Rotation[%this.interiorFile,1,%this.inventoryCount];
|
||||
Team = %team;
|
||||
};
|
||||
|
||||
StationInventory.gainPower(%shape);
|
||||
%this.inventoryCount++;
|
||||
|
||||
case 2: //Sensor (Medium)
|
||||
if (%this.generatorCount == 0 || %this.sensorCount == $Property::Max[%this.interiorFile,2])
|
||||
return false;
|
||||
|
||||
%shape = new StaticShape()
|
||||
{
|
||||
DataBlock = SensorMediumPulse;
|
||||
Position = vectorAdd($Property::Offset[%this.interiorFile,2,%this.sensorCount],%this.getPosition());
|
||||
Rotation = $Property::Rotation[%this.interiorFile,2,%this.sensorCount];
|
||||
Team = %team;
|
||||
};
|
||||
SensorMediumPulse.gainPower(%shape);
|
||||
%this.sensorCount++;
|
||||
|
||||
case 3: //Sensor (Large)
|
||||
if (%this.generatorCount == 0 || %this.sensorCount == $Property::Max[%this.interiorFile,2])
|
||||
return false;
|
||||
|
||||
%shape = new StaticShape()
|
||||
{
|
||||
DataBlock = SensorLargePulse;
|
||||
Position = vectorAdd($Property::Offset[%this.interiorFile,3,%this.sensorCount],%this.getPosition());
|
||||
Rotation = $Property::Rotation[%this.interiorFile,3,%this.sensorCount];
|
||||
Team = %team;
|
||||
};
|
||||
|
||||
SensorLargePulse.gainPower(%shape);
|
||||
%this.sensorCount++;
|
||||
|
||||
case 4: //Sentry Turrets
|
||||
if (%this.generatorCount == 0 || %this.sentryCount == $Property::Max[%this.interiorFile,4])
|
||||
return false;
|
||||
|
||||
%shape = new StaticShape()
|
||||
{
|
||||
DataBlock = SentryTurret;
|
||||
Position = vectorAdd($Property::Offset[%this.interiorFile,4,%this.sentryCount],%this.getPosition());
|
||||
Rotation = $Property::Rotation[%this.interiorFile,4,%this.sentryCount];
|
||||
Team = %team;
|
||||
};
|
||||
SentryTurret.gainPower(%shape);
|
||||
%this.sentryCount++;
|
||||
|
||||
case 5: //Banner (Strength)
|
||||
if (%this.bannerCount == $Property::Max[%this.interiorFile,5])
|
||||
return false;
|
||||
%shape = new StaticShape()
|
||||
{
|
||||
DataBlock = Banner_Strength;
|
||||
Position = vectorAdd($Property::Offset[%this.interiorFile,5,%this.bannerCount],%this.getPosition());
|
||||
Rotation = $Property::Rotation[%this.interiorFile,5,%this.bannerCount];
|
||||
Team = %team;
|
||||
};
|
||||
%this.bannerCount++;
|
||||
|
||||
case 6: //Large Turret Base
|
||||
if (%this.generatorCount == 0 || %this.turretBaseCount == $Property::Max[%this.interiorFile,6])
|
||||
return false;
|
||||
|
||||
%shape = new StaticShape()
|
||||
{
|
||||
DataBlock = TurretBaseLarge;
|
||||
Position = vectorAdd($Property::Offset[%this.interiorFile,6,%this.turretBaseCount],%this.getPosition());
|
||||
Rotation = $Property::Rotation[%this.interiorFile,6,%this.turretBaseCount];
|
||||
Team = %team;
|
||||
};
|
||||
|
||||
%this.turretBaseCount++;
|
||||
}
|
||||
|
||||
%this.getGroup().add(%shape);
|
||||
setTargetName(%shape.target,addTaggedString(%client.namebase @ "'s"));
|
||||
setTargetSensorGroup(%shape.getTarget(), %team);
|
||||
%shape.setSelfPowered();
|
||||
return %shape;
|
||||
}
|
||||
|
||||
function staticShape::setPosition(%this,%pos)
|
||||
{
|
||||
%this.setTransform(%pos);
|
||||
return %this;
|
||||
}
|
||||
|
||||
function staticShape::getRotation(%this)
|
||||
{
|
||||
%trans = %this.getTransform();
|
||||
return getWord(%trans, 3) SPC getWord(%trans, 4) SPC getWord(%trans,5);
|
||||
}
|
||||
|
||||
function objectIDToDatablock(%objectID)
|
||||
{
|
||||
switch(%objectID)
|
||||
{
|
||||
case 0: return "GeneratorLarge";
|
||||
case 1: return 0;
|
||||
default: return -1;
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
|
||||
//This the array that stores all the positions and rotations for purchases of objects. I'll eventually move this to be a part of the basicFileProcessing.
|
||||
//Beagle Tower (bbunk2)
|
||||
//Generators
|
||||
$Property::Offset["bbunk2.dif",0,0] = "0.136109 6.92569 3.80877";
|
||||
$Property::Rotation["bbunk2.dif",0,0] = "1 0 0 0";
|
||||
//Inventory
|
||||
$Property::Offset["bbunk2.dif",1,0] = "-13.5045 6.57603 -6.49712";
|
||||
$Property::Rotation["bbunk2.dif",1,0] = "0 0 -1 88.8085";
|
||||
$Property::Offset["bbunk2.dif",1,1] = "13.5045 6.57603 -6.49712";
|
||||
$Property::Rotation["bbunk2.dif",1,1] = "0 0 1 88.8085";
|
||||
//Medium Sensors
|
||||
$Property::Offset["bbunk2.dif",2,0] = "-0.0187805 3.42132 30.8251";
|
||||
$Property::Rotation["bbunk2.dif",2,0] = "1 0 0 0";
|
||||
//Large Sensors
|
||||
$Property::Offset["bbunk2.dif",3,0] = "-0.0187805 3.42132 30.8251";
|
||||
$Property::Rotation["bbunk2.dif",3,0] = "1 0 0 0";
|
||||
//Sentry Turrets
|
||||
$Property::Offset["bbunk2.dif",4,0] = "0.018325 -0.513021 9.99179";
|
||||
$Property::Rotation["bbunk2.dif",4,0] = "0.706825 0.707389 0.000371874 179.92";
|
||||
$Property::Offset["bbunk2.dif",4,1] = "-0.092863 10.5404 -0.443447";
|
||||
$Property::Rotation["bbunk2.dif",4,1] = "0.577209 -0.577449 -0.577392 119.938";
|
||||
//Banners (Strength)
|
||||
$Property::Offset["bbunk2.dif",5,0] = "-0.150952 9.53516 9.82968";
|
||||
$Property::Rotation["bbunk2.dif",5,0] = "0 0 1 179.909";
|
||||
//Large Turret Base
|
||||
$Property::Offset["bbunk2.dif",6,0] = "0.0332212 11.5991 27.9961";
|
||||
$Property::Rotation["bbunk2.dif",6,0] = "1 0 0 0";
|
||||
|
||||
//Max values for each interior
|
||||
$Property::Max["bbunk2.dif",0] = 1; //Max generators
|
||||
$Property::Max["bbunk2.dif",1] = 2; //Max Inventories
|
||||
$Property::Max["bbunk2.dif",2] = 1; //Max Medium Sensors
|
||||
$Property::Max["bbunk2.dif",3] = 1; //Max Large Sensors
|
||||
$Property::Max["bbunk2.dif",4] = 2; //Max Sentry Turrets
|
||||
$Property::Max["bbunk2.dif",5] = 1; //Max Banners (Strength)
|
||||
$Property::Max["bbunk2.dif",6] = 1; //Max Turret Bases
|
||||
53
scripts/modscripts/server/serverFunctions.cs
Normal file
53
scripts/modscripts/server/serverFunctions.cs
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// Scripts/DO_NOT_DELETE/serverFunctions.cs (OPEN SOURCE)
|
||||
// If you see this text, you have obtained the official copy of this file from
|
||||
// one of the developers. Otherwise, your decompiler is so advanced that it can
|
||||
// somehow get commented lines in a script.
|
||||
// -- Dark Dragon DX
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//This should be used if I make some sort of online System
|
||||
function setVoice(%client, %voice, %voicepitch)
|
||||
{
|
||||
freeClientTarget(%client);
|
||||
%client.voice = %voice;
|
||||
%client.voicetag = addtaggedstring(%voice);
|
||||
%client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', 0, 0, %client.voicePitch);
|
||||
|
||||
if (IsObject(%client.player))
|
||||
%client.player.setTarget(%client.target);
|
||||
}
|
||||
|
||||
function setSkin(%client, %skin)
|
||||
{
|
||||
freeClientTarget(%client);
|
||||
%client.skin = addtaggedstring(%skin);
|
||||
%client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', 0, 0, %client.voicePitch);
|
||||
|
||||
if (IsObject(%client.player))
|
||||
%client.player.setTarget(%client.target);
|
||||
}
|
||||
|
||||
function setName(%client, %name)
|
||||
{
|
||||
freeClientTarget(%client);
|
||||
%client.namebase = %name;
|
||||
%client.name = addtaggedstring(%name);
|
||||
%client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', 0, 0, %client.voicePitch);
|
||||
|
||||
if (IsObject(%client.player))
|
||||
%client.player.setTarget(%client.target);
|
||||
|
||||
//Update the client in the lobby.
|
||||
HideClient(%client);
|
||||
ShowClient(%client);
|
||||
}
|
||||
|
||||
function setTeam(%client,%team)
|
||||
{
|
||||
%client.team = %team;
|
||||
%client.setSensorGroup(%team);
|
||||
setTargetSensorGroup(%client.target,%team);
|
||||
}
|
||||
|
||||
|
||||
49
scripts/modscripts/server/serverNetworking.cs
Normal file
49
scripts/modscripts/server/serverNetworking.cs
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// scripts/modScripts/server/serverNetworking.cs
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
if (!IsObject(ServerNetwork))
|
||||
new TCPObject(ServerNetwork);
|
||||
|
||||
function ServerNetwork::onConnect(%this)
|
||||
{
|
||||
}
|
||||
|
||||
function ServerNetwork::onConnectFailed(%this)
|
||||
{
|
||||
if (%this.testingServer)
|
||||
{
|
||||
error("Error: Unable to verify connection to server "@%this.testIP@" at port "@%this.testPort@"!");
|
||||
%this.testIP = "";
|
||||
%this.testPort = "";
|
||||
%this.testingServer = false;
|
||||
}
|
||||
}
|
||||
|
||||
function ServerNetwork::onDisconnect(%this)
|
||||
{
|
||||
}
|
||||
|
||||
function ServerNetwork::onDisconnectFailed(%this)
|
||||
{
|
||||
}
|
||||
|
||||
function ServerNetwork::listen(%this)
|
||||
{
|
||||
}
|
||||
|
||||
function ServerNetwork::send(%this)
|
||||
{
|
||||
}
|
||||
|
||||
function ServerNetwork::onLine(%this, %line)
|
||||
{
|
||||
}
|
||||
|
||||
function ServerNetwork::testServerIP(%this, %IP, %port)
|
||||
{
|
||||
%this.testingServer = true;
|
||||
%this.testIP = %ip;
|
||||
%this.testPort = %port;
|
||||
%this.connect(%ip @ ":" @ %port);
|
||||
}
|
||||
294
scripts/modscripts/server/torqueExServer.cs
Normal file
294
scripts/modscripts/server/torqueExServer.cs
Normal file
|
|
@ -0,0 +1,294 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// torqueExServer.cs
|
||||
// Torque Extensions for Servers
|
||||
// Copyright (c) 2012 Robert MacGregor
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: setVoice
|
||||
// Argument %client: The client object to change the voice of.
|
||||
// Argument %voice: The name of the voice to change to
|
||||
// Argument %voicepitch: The voicepitch to use
|
||||
// Description: Changes the voice of the targeted client object.
|
||||
//==============================================================================
|
||||
function setVoice(%client, %voice, %voicepitch)
|
||||
{
|
||||
freeClientTarget(%client);
|
||||
%client.voice = %voice;
|
||||
%client.voicePitch = %voicePitch;
|
||||
%client.voicetag = addtaggedstring(%voice);
|
||||
%client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', 0, 0, %client.voicePitch);
|
||||
|
||||
if (IsObject(%client.player))
|
||||
%client.player.setTarget(%client.target);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: setSkin
|
||||
// Argument %client: The client object to change the voice of.
|
||||
// Argument %skin: The skin to change to.
|
||||
// Description: Changes the skin of the targeted client object.
|
||||
//==============================================================================
|
||||
function setSkin(%client, %skin)
|
||||
{
|
||||
freeClientTarget(%client);
|
||||
%client.skin = addtaggedstring(%skin);
|
||||
%client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', 0, 0, %client.voicePitch);
|
||||
|
||||
// If the client has a player object
|
||||
if (IsObject(%client.player))
|
||||
%client.player.setTarget(%client.target);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: setName
|
||||
// Argument %client: The client object to change the skin of.
|
||||
// Argument %name: The name to change to.
|
||||
// Description: Changes the name of the targeted client object.
|
||||
//==============================================================================
|
||||
function setName(%client, %name, %lobbyUpdate)
|
||||
{
|
||||
freeClientTarget(%client);
|
||||
%client.namebase = %name;
|
||||
%client.name = addtaggedstring(%name);
|
||||
%client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', 0, 0, %client.voicePitch);
|
||||
|
||||
if (IsObject(%client.player))
|
||||
%client.player.setTarget(%client.target);
|
||||
|
||||
// Update the client in the lobby if we wanted to
|
||||
if (%lobbyUpdate)
|
||||
{
|
||||
hideClientInLobby(%client);
|
||||
ShowClientInLobby(%client);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: setTeam
|
||||
// Argument %client: The client object to change the team of.
|
||||
// Argument %name: The team to change to.
|
||||
// Description: Changes the team of the targeted client object.
|
||||
//==============================================================================
|
||||
function setTeam(%client,%team)
|
||||
{
|
||||
%client.team = %team;
|
||||
%client.setSensorGroup(%team);
|
||||
setTargetSensorGroup(%client.target,%team);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: hideClientInLobby
|
||||
// Argument %client: The client to hide.
|
||||
// Description: Hides this client object from the lobby only.
|
||||
// (Doesn't have anything to do with the server list)
|
||||
//==============================================================================
|
||||
function hideClientInLobby(%client)
|
||||
{
|
||||
messageAllExcept( %client, -1, 'MsgClientDrop', "", Game.kickClientName, %client );
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: showClientInLobby
|
||||
// Argument %client: The client to show.
|
||||
// Description: Shows this client object in the lobby only.
|
||||
// (Doesn't have anything to do with the server list)
|
||||
//==============================================================================
|
||||
function showClientInLobby(%client)
|
||||
{
|
||||
messageAllExcept(%client, -1, 'MsgClientJoin', "", %client.name, %client, %client.target, %client.isAIControlled(), %client.isAdmin, %client.isSuperAdmin, %client.isSmurf, %client.Guid);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: hideClientInList
|
||||
// Argument %client: The client to hide.
|
||||
// Description: Hides the client in the server list only.
|
||||
// WARNING!!! Running this on actual GameConnections is destructive. The game
|
||||
// will refuse to update the client anymore until they are reshown. This is
|
||||
// only known to work on AI's without a problem.
|
||||
//==============================================================================
|
||||
function hideClientInList(%client)
|
||||
{
|
||||
if (!IsObject(HiddenClientGroup))
|
||||
{
|
||||
new SimGroup(HiddenClientGroup);
|
||||
ServerGroup.add(HiddenClientGroup);
|
||||
}
|
||||
|
||||
if (HiddenClientGroup.isMember(%client))
|
||||
return false;
|
||||
|
||||
$HostGamePlayerCount--;
|
||||
if (%client.isAIControlled())
|
||||
$HostGameBotCount--;
|
||||
|
||||
HiddenClientGroup.add(%client);
|
||||
return true;
|
||||
}
|
||||
|
||||
function listHiddenPlayers()
|
||||
{
|
||||
for (%i = 0; %i < HiddenClientGroup.getCount(); %i++)
|
||||
{
|
||||
%cl = HiddenClientGroup.getObject(%i);
|
||||
%status = %cl.isAIControlled() ? "Bot" : "Player";
|
||||
echo("client: " @ %cl @ " player: " @ %cl.player @ " name: " @ %cl.namebase @ " team: " @ %cl.team @ " status: " @ %status);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: showClientInList
|
||||
// Argument %client: The client to show.
|
||||
// Description: Shows the client in the server list only.
|
||||
//==============================================================================
|
||||
function showClientInList(%client)
|
||||
{
|
||||
if (ClientGroup.isMember(%client))
|
||||
return false;
|
||||
|
||||
$HostGamePlayerCount++;
|
||||
if (%client.isAIControlled())
|
||||
$HostGameBotCount++;
|
||||
ClientGroup.add(%client);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: plnametocid
|
||||
// Argument %name: The name of a client.
|
||||
// Description: Returns the client ID of a player whose name closest matches
|
||||
// %name. (Does not take the hidden group into consideration)
|
||||
// Note: This code was pulled from construction, the author is unknown to me.
|
||||
//==============================================================================
|
||||
function plnametocid(%name)
|
||||
{
|
||||
%count = ClientGroup.getCount(); //counts total clients
|
||||
for(%i = 0; %i < %count; %i++) //loops till all clients are accounted for
|
||||
{
|
||||
%obj = ClientGroup.getObject(%i); //gets the clientid based on the ordering hes in on the list
|
||||
%nametest=%obj.namebase; //pointless step but i didnt feel like removing it....
|
||||
%nametest=strlwr(%nametest); //make name lowercase
|
||||
%name=strlwr(%name); //same as above, for the other name
|
||||
if(strstr(%nametest,%name) != -1) //is all of name test used in name
|
||||
return %obj; //if so return the clientid and stop the function
|
||||
}
|
||||
return 0; //if none fits return 0 and end function
|
||||
}
|
||||
|
||||
function forceSpawn(%client)
|
||||
{
|
||||
Game.spawnPlayer( %client, false );
|
||||
CloseScoreScreen(%client);
|
||||
return true;
|
||||
}
|
||||
|
||||
function ServerCMDCheckHTilt(%client){ } // CCM-based clients spam fix, for some reason they spam this to the server whenever they strafe.
|
||||
|
||||
// TypeMasks
|
||||
$TypeMasks::AllObjectType = -1; //Same thing as everything, thanks to Krash123 for telling me this. :)
|
||||
$TypeMasks::InteractiveObjectType = $TypeMasks::PlayerObjectType | $TypeMasks::VehicleObjectType | $TypeMasks::WaterObjectType | $TypeMasks::ProjectileObjectType | $TypeMasks::ItemObjectType | $TypeMasks::CorpseObjectType;
|
||||
$TypeMasks::UnInteractiveObjectType = $TypeMasks::StaticObjectType | $TypeMasks::TerrainObjectType | $TypeMasks::InteriorObjectType | $TypeMasks::StaticTSObjectType | $TypeMasks::StaticRenderedObjectType;
|
||||
$TypeMasks::BaseAssetObjectType = $TypeMasks::ForceFieldObjectType | $TypeMasks::TurretObjectType | $TypeMasks::SensorObjectType | $TypeMasks::StationObjectType | $TypeMasks::GeneratorObjectType;
|
||||
$TypeMasks::GameSupportObjectType = $TypeMasks::TriggerObjectType | $TypeMasks::MarkerObjectType | $TypeMasks::CameraObjectType | $TypeMasks::VehicleBlockerObjectType | $TypeMasks::PhysicalZoneObjectType;
|
||||
$TypeMasks::GameContentObjectType = $TypeMasks::ExplosionObjectType | $TypeMasks::CorpseObjectType | $TypeMasks::DebrisObjectType;
|
||||
$TypeMasks::DefaultLOSObjectType = $TypeMasks::TerrainObjectType | $TypeMasks::InteriorObjectType | $TypeMasks::StaticObjectType;
|
||||
|
||||
|
||||
// --- Binding Functions
|
||||
function GameConnection::setVoice(%this, %voice, %voicepitch) { return setVoice(%this, %voice, %voicepitch); }
|
||||
function GameConnection::setSkin(%this, %skin) { return setSkin(%this, %skin); }
|
||||
function GameConnection::setName(%this, %name){ return setName(%this, %name); }
|
||||
function GameConnection::setTeam(%this, %team){ return setTeam(%this, %team); }
|
||||
function GameConnection::hideInLobby(%this){ return hideClientInLobby(%this); }
|
||||
function GameConnection::showInLobby(%this){ return showClientInLobby(%this); }
|
||||
function Gameconnection::spawn(%this){ return forceSpawn(%this); }
|
||||
// function GameConnection::hideClientInList(%this){ return hideClientInList(%this); }
|
||||
// function GameConnection::showClientInList(%this){ return showClientInList(%this); }
|
||||
|
||||
function AIConnection::setVoice(%this, %voice, %voicepitch) { return setVoice(%this, %voice, %voicepitch); }
|
||||
function AIConnection::setSkin(%this, %skin) { return setSkin(%this, %skin); }
|
||||
function AIConnection::setName(%this, %name){ return setName(%this, %name); }
|
||||
function AIConnection::setTeam(%this, %team){ return setTeam(%this, %team); }
|
||||
function AIConnection::hide(%this){ return hideClientInLobby(%this); }
|
||||
function AIConnection::show(%this){ return showClientInLobby(%this); }
|
||||
function AIConnection::hideClientInList(%this){ return hideClientInList(%this); }
|
||||
function AIConnection::showClientInList(%this){ return showClientInList(%this); }
|
||||
|
||||
function AIConnection::disengageTasks(%this)
|
||||
{
|
||||
// Don't quite remember exactly what the minimal
|
||||
// requirements here to get the same effect is,
|
||||
// but this works fine as it is it seems.
|
||||
AIUnassignClient(%this); // Have no idea what this does!
|
||||
%this.stop();
|
||||
%this.clearTasks(); // Clear the Behavior Tree
|
||||
%this.clearStep();
|
||||
%this.lastDamageClient = -1;
|
||||
%this.lastDamageTurret = -1;
|
||||
%this.shouldEngage = -1;
|
||||
%this.setEngageTarget(-1);
|
||||
%this.setTargetObject(-1);
|
||||
%this.pilotVehicle = false;
|
||||
%this.defaultTasksAdded = false;
|
||||
return true;
|
||||
}
|
||||
|
||||
function Player::setVoice(%this, %voice, %voicepitch)
|
||||
{
|
||||
if (!isObject(%this.Client))
|
||||
{
|
||||
%this.Client = new ScriptObject(); // Glue!
|
||||
%this.Client.Player = %this;
|
||||
}
|
||||
return setVoice(%this.Client, %voice, %voicepitch);
|
||||
}
|
||||
|
||||
function Player::setSkin(%this, %skin)
|
||||
{
|
||||
if (!isObject(%this.Client))
|
||||
{
|
||||
%this.Client = new ScriptObject();
|
||||
%this.Client.Player = %this;
|
||||
}
|
||||
return setSkin(%this, %skin);
|
||||
}
|
||||
|
||||
function Player::setName(%this, %name, %lobbyUpdate)
|
||||
{
|
||||
if (!isObject(%this.Client))
|
||||
{
|
||||
%this.Client = new ScriptObject();
|
||||
%this.Client.Player = %this;
|
||||
}
|
||||
return setName(%this, %name, %lobbyUpdate);
|
||||
}
|
||||
|
||||
function Player::setTeam(%this, %team)
|
||||
{
|
||||
if (!isObject(%this.Client))
|
||||
{
|
||||
%this.Client = new ScriptObject();
|
||||
%this.Client.Player = %this;
|
||||
}
|
||||
return setTeam(%this, %team);
|
||||
}
|
||||
|
||||
// This package is used to hook several functions that will induce bugs due to usage of this code
|
||||
package ExOverrides
|
||||
{
|
||||
function fixMe(){}
|
||||
};
|
||||
if (!isActivePackage(ExOverrides))
|
||||
activatePackage(ExOverrides);
|
||||
else
|
||||
{
|
||||
deactivatePackage(ExOverrides);
|
||||
activatePackage(ExOverrides);
|
||||
}
|
||||
83
scripts/modscripts/shared/Array.cs
Normal file
83
scripts/modscripts/shared/Array.cs
Normal file
|
|
@ -0,0 +1,83 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// Array.cs
|
||||
// Array object you can pass around.
|
||||
// Copyright (c) 2012 Robert MacGregor
|
||||
//==============================================================================
|
||||
|
||||
function ArrayFactory::create(%this, %name)
|
||||
{
|
||||
if (isObject(%name))
|
||||
%name = "";
|
||||
%object = new ScriptObject(%name) { class = "ArrayObject"; };
|
||||
%object.elementCount = 0;
|
||||
return %object;
|
||||
}
|
||||
|
||||
function ArrayObject::setElement(%this, %index, %object)
|
||||
{
|
||||
%replaced = false;
|
||||
if (%this.Element[%index] != "")
|
||||
%replaced = true;
|
||||
else
|
||||
{
|
||||
%this.elementIndex[%index] = %this.elementCount;
|
||||
%this.elementIndices[%this.elementCount] = %index;
|
||||
%this.elementCount++;
|
||||
}
|
||||
|
||||
%this.Element[%index] = %object;
|
||||
return %replaced;
|
||||
}
|
||||
|
||||
function ArrayObject::list(%this)
|
||||
{
|
||||
%list = Array.create();
|
||||
for (%i = 0; %i < %this.elementCount; %i++)
|
||||
%list.setElement(%i, %this.Element[%this.elementIndices[%i]]);
|
||||
return %list;
|
||||
}
|
||||
|
||||
function ArrayObject::removeElement(%this, %index)
|
||||
{
|
||||
if (%this.Element[%index] != "")
|
||||
{
|
||||
%this.Element[%index] = "";
|
||||
for (%i = %this.elementIndex[%index]; %i < %this.elementCount; %i++)
|
||||
%this.elementIndices[%i] = %this.elementIndices[%i+1];
|
||||
%this.elementCount--;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
return false;
|
||||
}
|
||||
|
||||
function ArrayObject::hasElementValue(%this, %value)
|
||||
{
|
||||
for (%i = 0; %i < %this.elementCount; %i++)
|
||||
if (%this.Element[%i] == %value)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function ArrayObject::isElement(%this, %index)
|
||||
{
|
||||
if (%this.Element[%index] == "")
|
||||
return false;
|
||||
else
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function ArrayObject::element(%this, %index)
|
||||
{
|
||||
return %this.Element[%index];
|
||||
}
|
||||
|
||||
function ArrayObject::count(%this)
|
||||
{
|
||||
return %this.elementCount;
|
||||
}
|
||||
|
||||
if (!IsObject(Array))
|
||||
new ScriptObject(Array) { class = "ArrayFactory"; };
|
||||
276
scripts/modscripts/shared/BasicData.cs
Normal file
276
scripts/modscripts/shared/BasicData.cs
Normal file
|
|
@ -0,0 +1,276 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// basicDataStorage.cs
|
||||
// Originally written for T2BoL mod back in the day, now is being rewritten
|
||||
// for the original implementation was pretty crappy.
|
||||
// Requires: Array.cs
|
||||
// Copyright (c) 2012 Robert MacGregor
|
||||
//==============================================================================
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: BasicDataParser.load
|
||||
// Argument %file: The file to parse and load into memory.
|
||||
// Description: This function is the main function of everything; it loads
|
||||
// %file into memory.
|
||||
// Return: True if the function succeeded, false if otherwise failed.
|
||||
//==============================================================================
|
||||
function BasicDataParser::load(%this, %file)
|
||||
{
|
||||
// Make sure we have our values initialised (math doesn't work right on nonexistent variables!)
|
||||
if (%this.filesLoaded == "")
|
||||
%this.filesLoaded = 0;
|
||||
if (%this.blockEntryCount == "")
|
||||
%this.blockEntryCount = 0;
|
||||
if (%this.blockInstances == "")
|
||||
%this.blockInstances = 0;
|
||||
|
||||
%currentSeconds = formatTimeString("ss");
|
||||
// Check to see if the data is valid (returns false if we tried to load a nonexistent file)
|
||||
if (!isFile(%file))
|
||||
{
|
||||
error("basicDataStorage.cs: Attempted to load non-existent file " @ %file @ "!");
|
||||
return false;
|
||||
}
|
||||
// Check to see if this file is already loaded
|
||||
if (%this.isLoaded(%file))
|
||||
{
|
||||
error("basicDataStorage.cs: Attempted to reload data file " @ %file SPC "while it's already in memory! (try unloading or emptying)");
|
||||
return false;
|
||||
}
|
||||
// Add the file entry to memory (for the file check above)
|
||||
%this.files[%this.filesLoaded] = %file;
|
||||
%this.fileIndex[%file] = %this.filesLoaded;
|
||||
%this.filesLoaded++;
|
||||
|
||||
// Load the file into memory (function is from fileProcessing.cs)
|
||||
%fileData = strReplace(stripChars(getFileBuffer(%file),"\t"),"\n","\t");
|
||||
%lineCount = getFieldCount(%fileData);
|
||||
|
||||
%isProcessingBlock = false; // Used to set processing mode
|
||||
%currentBlock = 0;
|
||||
%hadError = false;
|
||||
// Iterate through all lines
|
||||
for (%i = 0; %i < %lineCount; %i++)
|
||||
{
|
||||
%currentLine = getField(%fileData,%i);
|
||||
// Check to see if this line contains a block definition or not
|
||||
%openingBlock = strStr(%currentLine, "[");
|
||||
%closingBlock = strStr(%currentLine, "]");
|
||||
|
||||
// If we have a block definition, it should be against left margin
|
||||
if (%openingBlock == 0 && %closingBlock > 0 && !%isProcessingBlock)
|
||||
{
|
||||
%isProcessingBlock = true;
|
||||
%blockName = getSubStr(%currentLine,%openingBlock+1,%closingBlock-1);
|
||||
|
||||
if (%this.blockInstances[%blockName] == "")
|
||||
{
|
||||
%this.blockInstances[%blockName] = 0;
|
||||
%this.blockEntry[%this.blockEntryCount] = %blockName;
|
||||
%this.blockEntryCount++;
|
||||
}
|
||||
// Create the array to store our block data
|
||||
%currentBlock = Array.create();
|
||||
%currentBlock.Name = %blockName;
|
||||
%currentBlock.File = %file;
|
||||
|
||||
%this.blocks[%blockName,%this.blockInstances] = %currentBlock;
|
||||
%this.blockInstances[%blockName]++;
|
||||
%this.blockInstances++;
|
||||
continue;
|
||||
}
|
||||
// Results in an error
|
||||
else if (%openingBlock == 0 && %closingBlock > 0 && %isProcessingBlock)
|
||||
{
|
||||
error("basicDataStorage.cs: Error loading file "@ %file @ ", block spacing error.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we're processing the actual block
|
||||
if (%isProcessingBlock)
|
||||
{
|
||||
if (%currentLine $="" || %i == %lineCount)
|
||||
{
|
||||
%isProcessingBlock = false;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
%eqPos = strStr(%currentLine,"="); // This is safe since the equals sign should be first.
|
||||
if (%eqPos == -1)
|
||||
{
|
||||
error("basicDataStorage.cs: Unable to read entry for block" SPC %currentBlock.Name @ " in file" SPC %file @ "!");
|
||||
%isProcessingBlock = false;
|
||||
%hadError = true;
|
||||
continue;
|
||||
}
|
||||
// Note: I got lazy here, just don't have semicolons in your data entries..
|
||||
%semiPos = strStr(%currentLine,";");
|
||||
if (%semiPos == -1 || getSubStrOccurance(%currentLine,";") > 1)
|
||||
{
|
||||
error("basicDataStorage.cs: Unable to read entry for block" SPC %currentBlock.Name @ " in file" SPC %file @ "!");
|
||||
%isProcessingBlock = false;
|
||||
%hadError = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
%entryName = trim(getSubStr(%currentLine,0,%eqPos-1));
|
||||
%entryValue = trim(getSubStr(%currentLine,%eqPos+1, mAbs(%eqPos-%semiPos)-1 ));
|
||||
%currentBlock.setElement(%entryName,%entryValue);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!%hadError)
|
||||
warn("basicDataStorage.cs: Successfully loaded file" SPC %file SPC "in " @ formatTimeString("ss") - %currentSeconds SPC "seconds.");
|
||||
return !%hadError;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: BasicDataParser.unload
|
||||
// Argument %file: The file of who's entries should be unloaded.
|
||||
// Description: This function is used to unload data by filename -- useful for
|
||||
// reloading data from specific files.
|
||||
// Return: True if the function was successful, false if otherwise failed.
|
||||
//==============================================================================
|
||||
function BasicDataParser::unload(%this, %file)
|
||||
{
|
||||
if (!%this.isLoaded(%file))
|
||||
{
|
||||
error("basicDataStorage.cs: Attempted to unload non-loaded data file " @ %file @ "!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Unload any data associated with this file now
|
||||
%removed = "";
|
||||
for (%i = 0; %i < %this.blockEntryCount; %i++)
|
||||
{
|
||||
%name = %this.blockEntry[%i];
|
||||
for (%h = 0; %h < %this.blockInstances[%name]; %h++)
|
||||
if (%this.blocks[%name, %h].File $= %file)
|
||||
{
|
||||
%this.blocks[%name, %h].delete();
|
||||
%this.blocks[%name, %h] = "";
|
||||
%this.blockEntry[%i] = "";
|
||||
%removed = trim(%removed SPC %i);
|
||||
|
||||
if (%this.blockInstances[%name] == 1)
|
||||
%this.blockInstances[%name] = "";
|
||||
else
|
||||
%this.blockInstances[%name]--;
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate through our block entries and correct the imbalance
|
||||
for (%i = 0; %i < getWordCount(%removed); %i++)
|
||||
{
|
||||
for (%h = i; %h < %this.blockEntryCount; %h++)
|
||||
%this.blockEntry[%h-%i] = %this.blockEntry[%h+1];
|
||||
%this.blockEntryCount--;
|
||||
}
|
||||
|
||||
// Now remove the file entry
|
||||
for (%i = %this.fileIndex[%file]; %i < %this.filesLoaded; %i++)
|
||||
if (%i != %this.filesLoaded-1)
|
||||
{
|
||||
%this.files[%i] = %this.files[%i+1];
|
||||
%this.fileIndex[%this.files[%i+1]] = %i;
|
||||
}
|
||||
else
|
||||
{
|
||||
%this.fileIndex[%file] = "";
|
||||
%this.files[%i] = "";
|
||||
}
|
||||
|
||||
// Decrement the files loaded count and return true
|
||||
%this.filesLoaded--;
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: BasicDataParser.count
|
||||
// Argument %block: The bloick entry to count the occurances of
|
||||
// Return: The occurances of %block in this parser object. If there is no
|
||||
// such entry of %block anywhere, false (0) is returned.
|
||||
//==============================================================================
|
||||
function BasicDataParser::count(%this, %block)
|
||||
{
|
||||
// Return zero if the block has no entries even registered
|
||||
if (%this.blockInstances[%block] == "")
|
||||
return false;
|
||||
else
|
||||
// Return the block Instances otherwise
|
||||
return %this.blockInstances[%block];
|
||||
return false; // Shouldn't happen
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: BasicDataParser.empty
|
||||
// Description: Empties the entire object of any information it may have
|
||||
// loaded anytime.
|
||||
// Return: True is always returned from this function.
|
||||
//==============================================================================
|
||||
function BasicDataParser::empty(%this)
|
||||
{
|
||||
// Iterate through our block entries and destroy them
|
||||
for (%i = 0; %i < %this.blockEntryCount; %i++)
|
||||
{
|
||||
%name = %this.blockEntry[%i];
|
||||
for (%h = 0; %h < %this.blockInstances[%name]; %h++)
|
||||
{
|
||||
%this.blocks[%name, %h].delete();
|
||||
%this.blocks[%name, %h] = "";
|
||||
}
|
||||
%this.blockInstances[%name] = "";
|
||||
%this.blockEntry[%i] = "";
|
||||
}
|
||||
|
||||
// Remove the files loaded entries now
|
||||
for (%i = 0; %i < %this.filesLoaded; %i++)
|
||||
{
|
||||
%this.fileIndex[%this.files[%i]] = "";
|
||||
%this.files[%i] = "";
|
||||
}
|
||||
|
||||
// Reset some variables to 0 and return true
|
||||
%this.filesLoaded = 0;
|
||||
%this.blockInstances = 0;
|
||||
%this.blockEntryCount = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: BasicDataParser.isLoaded
|
||||
// Argument %file: The file to check the loaded status of.
|
||||
// Description: Returns if %file is loaded into memory of this object or not.
|
||||
// Return: A boolean representing the loaded status.
|
||||
//==============================================================================
|
||||
function BasicDataParser::isLoaded(%this, %file)
|
||||
{
|
||||
// Check to see if this file is already loaded
|
||||
for (%i = 0; %i < %this.filesLoaded; %i++)
|
||||
if (%this.files[%i] $= %file)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: BasicDataParser.get
|
||||
// Argument %block: The name of the block to return.
|
||||
// Argument %occurance: The block index we need to return -- if there's
|
||||
// multiple entries of %block.
|
||||
// Description: This function is used to retrieve block entries loaded from
|
||||
// within any of the files this object has parsed.
|
||||
// Return: An Array (array.cs) containing relevent information to the requested
|
||||
// block. If there is no such entry of %block, false is returned.
|
||||
//==============================================================================
|
||||
function BasicDataParser::get(%this, %block, %occurance)
|
||||
{
|
||||
// Check ti see uf thus block has only once entry -- in which case %occurance is ignored
|
||||
if (%this.count(%block) == 1) return %this.blocks[%block, 0];
|
||||
// Otherwise we use %occurance to return the specific index
|
||||
else if (%occurance >= 0 && %occurance <= %this.count(%block)) return %this.blocks[%block, %occurance];
|
||||
|
||||
return false;
|
||||
}
|
||||
80
scripts/modscripts/shared/FileFunctions.cs
Normal file
80
scripts/modscripts/shared/FileFunctions.cs
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
// -----------------------------------------------------
|
||||
// FileFunctions.cs
|
||||
// Basic file functions
|
||||
// Copyright (c) 2012 Robert MacGregor
|
||||
// -----------------------------------------------------
|
||||
function getFileBuffer(%file)
|
||||
{
|
||||
if (!IsFile(%file))
|
||||
return -1;
|
||||
|
||||
new FileObject(FileBuffer);
|
||||
FileBuffer.openForRead(%file);
|
||||
|
||||
while (!FileBuffer.isEOF())
|
||||
%buffer = %buffer @ FileBuffer.readLine() @ "\n";
|
||||
FileBuffer.detach();
|
||||
return %buffer; //Long string. >.>
|
||||
}
|
||||
|
||||
function getLine(%file, %line)
|
||||
{
|
||||
if (!IsFile(%file))
|
||||
return -1;
|
||||
|
||||
new FileObject(FileLine);
|
||||
FileLine.openForRead(%file);
|
||||
|
||||
for (%i = 0; %i < %line; %i++)
|
||||
%line = FileLine.readLine();
|
||||
FileLine.detach();
|
||||
return %line;
|
||||
}
|
||||
|
||||
function getLine(%file, %line)
|
||||
{
|
||||
if (!IsFile(%file))
|
||||
return -1;
|
||||
|
||||
new FileObject(FileLine);
|
||||
FileLine.openForRead(%file);
|
||||
|
||||
for (%i = 0; %i < %line; %i++)
|
||||
%line = FileLine.readLine();
|
||||
FileLine.detach();
|
||||
return %line;
|
||||
}
|
||||
|
||||
// Returns an unsorted list of the contents of %dir (including folders)
|
||||
function getDirectory(%dir)
|
||||
{
|
||||
%array = Array.create();
|
||||
|
||||
%fileCount = 0;
|
||||
for( %file = findFirstFile( %dir @ "*.*" ); %file !$= ""; %file = findNextFile( %dir @ "*.*" ) )
|
||||
{
|
||||
%file = strReplace(%file, %socket.request, "");
|
||||
if (strStr(%file, "/") != -1)
|
||||
{
|
||||
%dir = getSubStr(%file, 0, strStr(%file, "/")) @ "/";
|
||||
if (!%dirAdded[%dir])
|
||||
{
|
||||
%data = %data @ "<a href=\"" @ strReplace(%dir, " ","%20") @ "\">" @ %dir @ "</a><br>\n";
|
||||
%dirAdded[%dir] = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
%data = %data @ "<a href=\"" @ strReplace(%file, " ", "%20") @ "\">" @ %file @ "</a><br>\n";
|
||||
}
|
||||
return %array;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Bound Functions
|
||||
// -----------------------------------------------------
|
||||
function fileObject::Detach(%this) //Detaches fileObject from file & deletes
|
||||
{
|
||||
%this.close();
|
||||
%this.delete();
|
||||
return %this;
|
||||
}
|
||||
196
scripts/modscripts/shared/StringFunctions.cs
Normal file
196
scripts/modscripts/shared/StringFunctions.cs
Normal file
|
|
@ -0,0 +1,196 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// StringFunctions.cs
|
||||
// String functions
|
||||
// Copyright (c) 2012 Robert MacGregor
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function textToHash(%text)
|
||||
{
|
||||
new fileObject(TextToHash);
|
||||
TextToHash.openForWrite("Hash.txt");
|
||||
TextToHash.writeLine(%text);
|
||||
TextToHash.detach();
|
||||
%hash = getFileCRC("Hash.txt");
|
||||
deleteFile("Hash.txt");
|
||||
return %hash;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function strReverse(%string)
|
||||
{
|
||||
%len = StrLen(%string);
|
||||
%rstring = "";
|
||||
for (%i = 0; %i < %len; %i++)
|
||||
%rstring = getSubStr(%string,%i,1) @ %rstring;
|
||||
return %rstring;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function subStrInsert(%string,%insert,%slot)
|
||||
{
|
||||
%seg = getSubStr(%string,0,%slot);
|
||||
%seg = %seg @ %insert;
|
||||
%string = %seg @ getSubStr(%string,%slot,strLen(%string));
|
||||
return %string;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function subStrRemove(%string,%slot)//Minimum: 1
|
||||
{
|
||||
%half2 = getSubStr(%string,%slot,strLen(%string));
|
||||
%half1 = getSubStr(%string,0,%slot-1);
|
||||
return %half1 @ %half2;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function strMove(%string,%factor)
|
||||
{
|
||||
%len = GetWordCount(%string);
|
||||
for (%i = 0; %i < %len; %i++)
|
||||
{
|
||||
%sub = getWord(%string,%i);
|
||||
%move = subStrInsert(%move,%sub,%i);
|
||||
}
|
||||
return %move;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function subStrMove(%string,%factor)
|
||||
{
|
||||
%len = strLen(%string);
|
||||
for (%i = 0; %i < %len; %i++)
|
||||
{
|
||||
%sub = getSubStr(%string,%i,1);
|
||||
%move = subStrInsert(%move,%sub,%factor);
|
||||
}
|
||||
return %move;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function subStrScramble(%string)
|
||||
{
|
||||
%len = strLen(%string);
|
||||
for (%i = 0; %i < %len; %i++)
|
||||
{
|
||||
%sub = getSubStr(%string,%i,1);
|
||||
%scramble = subStrInsert(%scramble,%sub,getRandom(0,%len));
|
||||
}
|
||||
return %scramble;
|
||||
}
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function strSplit(%string)
|
||||
{
|
||||
%count = strLen(%string);
|
||||
%div = %count / 2;
|
||||
return getSubStr(%string,0,%div) @ " | " @ getSubStr(%string,%div,%count);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function stripSpaces(%string)
|
||||
{
|
||||
return strReplace(%string," ","");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function stripNonNumericCharacters(%string)
|
||||
{
|
||||
%string = strLwr(%string);
|
||||
return stripChars(%string,"abcdefghijklmnopqrstuvwxyz`~!@#$%^&*()-_=+\|}]{[/?.>,<;:");
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function getSubStrOccurances(%string,%search)
|
||||
{
|
||||
%len = strLen(%string);
|
||||
%srLen = strLen(%search);
|
||||
%count = 0;
|
||||
for (%i = 0; %i < %len; %i++)
|
||||
{
|
||||
%strSearch = strStr(%string,%search);
|
||||
if (%strSearch != -1) //It exists somewhere in the string
|
||||
{
|
||||
%count++;
|
||||
%string = getSubStr(%string,%strSearch+%srLen,%len);
|
||||
}
|
||||
else
|
||||
return %count;
|
||||
}
|
||||
return %count;
|
||||
}
|
||||
|
||||
function getSubStrPos(%string,%str,%num)
|
||||
{
|
||||
%len = strLen(%string);
|
||||
%subC = 0;
|
||||
for (%i = 0; %i < %len; %i++)
|
||||
{
|
||||
%curPos = %i;
|
||||
%sub = getSubStr(%string,%i,1);
|
||||
|
||||
if (%sub $= %str)
|
||||
{
|
||||
if (%subC == %num)
|
||||
return %i;
|
||||
%subC++;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function strWhite(%string, %whiteList, %char)
|
||||
{
|
||||
%charLen = strLen(%char);
|
||||
for (%i = 0; %i < strLen(%whiteList); %i++)
|
||||
for (%h = 0; %h < %charLen; %h++)
|
||||
{
|
||||
%whiteSeg = getSubStr(%whiteList, %i, %charLen);
|
||||
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function getFileNameFromString(%string)
|
||||
{
|
||||
if (strStr(%string, "/") == -1)
|
||||
return %string;
|
||||
else
|
||||
return getSubStr(%string,getSubStrPos(%string, "/", getSubStrOccurances(%string, "/")-1)+1,strLen(%string));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
function getFileExtensionFromString(%string)
|
||||
{
|
||||
%file = getFileNameFromString(%string);
|
||||
%period = strStr(%file,".");
|
||||
if (%period == -1)
|
||||
return false;
|
||||
else
|
||||
return getSubStr(%file,strStr(%file,".")+1, strLen(%file));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
276
scripts/modscripts/shared/basicDataStorage.cs
Normal file
276
scripts/modscripts/shared/basicDataStorage.cs
Normal file
|
|
@ -0,0 +1,276 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// basicDataStorage.cs
|
||||
// Originally written for T2BoL mod back in the day, now is being rewritten
|
||||
// for the original implementation was pretty crappy.
|
||||
// Requires: Array.cs
|
||||
// Copyright (c) 2012 The DarkDragonDX
|
||||
//==============================================================================
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: BasicDataParser.load
|
||||
// Argument %file: The file to parse and load into memory.
|
||||
// Description: This function is the main function of everything; it loads
|
||||
// %file into memory.
|
||||
// Return: True if the function succeeded, false if otherwise failed.
|
||||
//==============================================================================
|
||||
function BasicDataParser::load(%this, %file)
|
||||
{
|
||||
// Make sure we have our values initialised (math doesn't work right on nonexistent variables!)
|
||||
if (%this.filesLoaded == "")
|
||||
%this.filesLoaded = 0;
|
||||
if (%this.blockEntryCount == "")
|
||||
%this.blockEntryCount = 0;
|
||||
if (%this.blockInstances == "")
|
||||
%this.blockInstances = 0;
|
||||
|
||||
%currentSeconds = formatTimeString("ss");
|
||||
// Check to see if the data is valid (returns false if we tried to load a nonexistent file)
|
||||
if (!isFile(%file))
|
||||
{
|
||||
error("basicDataStorage.cs: Attempted to load non-existent file " @ %file @ "!");
|
||||
return false;
|
||||
}
|
||||
// Check to see if this file is already loaded
|
||||
if (%this.isLoaded(%file))
|
||||
{
|
||||
error("basicDataStorage.cs: Attempted to reload data file " @ %file SPC "while it's already in memory! (try unloading or emptying)");
|
||||
return false;
|
||||
}
|
||||
// Add the file entry to memory (for the file check above)
|
||||
%this.files[%this.filesLoaded] = %file;
|
||||
%this.fileIndex[%file] = %this.filesLoaded;
|
||||
%this.filesLoaded++;
|
||||
|
||||
// Load the file into memory (function is from fileProcessing.cs)
|
||||
%fileData = strReplace(stripChars(getFileBuffer(%file),"\t"),"\n","\t");
|
||||
%lineCount = getFieldCount(%fileData);
|
||||
|
||||
%isProcessingBlock = false; // Used to set processing mode
|
||||
%currentBlock = 0;
|
||||
%hadError = false;
|
||||
// Iterate through all lines
|
||||
for (%i = 0; %i < %lineCount; %i++)
|
||||
{
|
||||
%currentLine = getField(%fileData,%i);
|
||||
// Check to see if this line contains a block definition or not
|
||||
%openingBlock = strStr(%currentLine, "[");
|
||||
%closingBlock = strStr(%currentLine, "]");
|
||||
|
||||
// If we have a block definition, it should be against left margin
|
||||
if (%openingBlock == 0 && %closingBlock > 0 && !%isProcessingBlock)
|
||||
{
|
||||
%isProcessingBlock = true;
|
||||
%blockName = getSubStr(%currentLine,%openingBlock+1,%closingBlock-1);
|
||||
|
||||
if (%this.blockInstances[%blockName] == "")
|
||||
{
|
||||
%this.blockInstances[%blockName] = 0;
|
||||
%this.blockEntry[%this.blockEntryCount] = %blockName;
|
||||
%this.blockEntryCount++;
|
||||
}
|
||||
// Create the array to store our block data
|
||||
%currentBlock = Array.create();
|
||||
%currentBlock.Name = %blockName;
|
||||
%currentBlock.File = %file;
|
||||
|
||||
%this.blocks[%blockName,%this.blockInstances] = %currentBlock;
|
||||
%this.blockInstances[%blockName]++;
|
||||
%this.blockInstances++;
|
||||
continue;
|
||||
}
|
||||
// Results in an error
|
||||
else if (%openingBlock == 0 && %closingBlock > 0 && %isProcessingBlock)
|
||||
{
|
||||
error("basicDataStorage.cs: Error loading file "@ %file @ ", block spacing error.");
|
||||
return false;
|
||||
}
|
||||
|
||||
// If we're processing the actual block
|
||||
if (%isProcessingBlock)
|
||||
{
|
||||
if (%currentLine $="" || %i == %lineCount)
|
||||
{
|
||||
%isProcessingBlock = false;
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
%eqPos = strStr(%currentLine,"="); // This is safe since the equals sign should be first.
|
||||
if (%eqPos == -1)
|
||||
{
|
||||
error("basicDataStorage.cs: Unable to read entry for block" SPC %currentBlock.Name @ " in file" SPC %file @ "!");
|
||||
%isProcessingBlock = false;
|
||||
%hadError = true;
|
||||
continue;
|
||||
}
|
||||
// Note: I got lazy here, just don't have semicolons in your data entries..
|
||||
%semiPos = strStr(%currentLine,";");
|
||||
if (%semiPos == -1 || getSubStrOccurance(%currentLine,";") > 1)
|
||||
{
|
||||
error("basicDataStorage.cs: Unable to read entry for block" SPC %currentBlock.Name @ " in file" SPC %file @ "!");
|
||||
%isProcessingBlock = false;
|
||||
%hadError = true;
|
||||
continue;
|
||||
}
|
||||
|
||||
%entryName = trim(getSubStr(%currentLine,0,%eqPos-1));
|
||||
%entryValue = trim(getSubStr(%currentLine,%eqPos+1, mAbs(%eqPos-%semiPos)-1 ));
|
||||
%currentBlock.setElement(%entryName,%entryValue);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (!%hadError)
|
||||
warn("basicDataStorage.cs: Successfully loaded file" SPC %file SPC "in " @ formatTimeString("ss") - %currentSeconds SPC "seconds.");
|
||||
return !%hadError;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: BasicDataParser.unload
|
||||
// Argument %file: The file of who's entries should be unloaded.
|
||||
// Description: This function is used to unload data by filename -- useful for
|
||||
// reloading data from specific files.
|
||||
// Return: True if the function was successful, false if otherwise failed.
|
||||
//==============================================================================
|
||||
function BasicDataParser::unload(%this, %file)
|
||||
{
|
||||
if (!%this.isLoaded(%file))
|
||||
{
|
||||
error("basicDataStorage.cs: Attempted to unload non-loaded data file " @ %file @ "!");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Unload any data associated with this file now
|
||||
%removed = "";
|
||||
for (%i = 0; %i < %this.blockEntryCount; %i++)
|
||||
{
|
||||
%name = %this.blockEntry[%i];
|
||||
for (%h = 0; %h < %this.blockInstances[%name]; %h++)
|
||||
if (%this.blocks[%name, %h].File $= %file)
|
||||
{
|
||||
%this.blocks[%name, %h].delete();
|
||||
%this.blocks[%name, %h] = "";
|
||||
%this.blockEntry[%i] = "";
|
||||
%removed = trim(%removed SPC %i);
|
||||
|
||||
if (%this.blockInstances[%name] == 1)
|
||||
%this.blockInstances[%name] = "";
|
||||
else
|
||||
%this.blockInstances[%name]--;
|
||||
}
|
||||
}
|
||||
|
||||
// Iterate through our block entries and correct the imbalance
|
||||
for (%i = 0; %i < getWordCount(%removed); %i++)
|
||||
{
|
||||
for (%h = i; %h < %this.blockEntryCount; %h++)
|
||||
%this.blockEntry[%h-%i] = %this.blockEntry[%h+1];
|
||||
%this.blockEntryCount--;
|
||||
}
|
||||
|
||||
// Now remove the file entry
|
||||
for (%i = %this.fileIndex[%file]; %i < %this.filesLoaded; %i++)
|
||||
if (%i != %this.filesLoaded-1)
|
||||
{
|
||||
%this.files[%i] = %this.files[%i+1];
|
||||
%this.fileIndex[%this.files[%i+1]] = %i;
|
||||
}
|
||||
else
|
||||
{
|
||||
%this.fileIndex[%file] = "";
|
||||
%this.files[%i] = "";
|
||||
}
|
||||
|
||||
// Decrement the files loaded count and return true
|
||||
%this.filesLoaded--;
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: BasicDataParser.count
|
||||
// Argument %block: The bloick entry to count the occurances of
|
||||
// Return: The occurances of %block in this parser object. If there is no
|
||||
// such entry of %block anywhere, false (0) is returned.
|
||||
//==============================================================================
|
||||
function BasicDataParser::count(%this, %block)
|
||||
{
|
||||
// Return zero if the block has no entries even registered
|
||||
if (%this.blockInstances[%block] == "")
|
||||
return false;
|
||||
else
|
||||
// Return the block Instances otherwise
|
||||
return %this.blockInstances[%block];
|
||||
return false; // Shouldn't happen
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: BasicDataParser.empty
|
||||
// Description: Empties the entire object of any information it may have
|
||||
// loaded anytime.
|
||||
// Return: True is always returned from this function.
|
||||
//==============================================================================
|
||||
function BasicDataParser::empty(%this)
|
||||
{
|
||||
// Iterate through our block entries and destroy them
|
||||
for (%i = 0; %i < %this.blockEntryCount; %i++)
|
||||
{
|
||||
%name = %this.blockEntry[%i];
|
||||
for (%h = 0; %h < %this.blockInstances[%name]; %h++)
|
||||
{
|
||||
%this.blocks[%name, %h].delete();
|
||||
%this.blocks[%name, %h] = "";
|
||||
}
|
||||
%this.blockInstances[%name] = "";
|
||||
%this.blockEntry[%i] = "";
|
||||
}
|
||||
|
||||
// Remove the files loaded entries now
|
||||
for (%i = 0; %i < %this.filesLoaded; %i++)
|
||||
{
|
||||
%this.fileIndex[%this.files[%i]] = "";
|
||||
%this.files[%i] = "";
|
||||
}
|
||||
|
||||
// Reset some variables to 0 and return true
|
||||
%this.filesLoaded = 0;
|
||||
%this.blockInstances = 0;
|
||||
%this.blockEntryCount = 0;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: BasicDataParser.isLoaded
|
||||
// Argument %file: The file to check the loaded status of.
|
||||
// Description: Returns if %file is loaded into memory of this object or not.
|
||||
// Return: A boolean representing the loaded status.
|
||||
//==============================================================================
|
||||
function BasicDataParser::isLoaded(%this, %file)
|
||||
{
|
||||
// Check to see if this file is already loaded
|
||||
for (%i = 0; %i < %this.filesLoaded; %i++)
|
||||
if (%this.files[%i] $= %file)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: BasicDataParser.get
|
||||
// Argument %block: The name of the block to return.
|
||||
// Argument %occurance: The block index we need to return -- if there's
|
||||
// multiple entries of %block.
|
||||
// Description: This function is used to retrieve block entries loaded from
|
||||
// within any of the files this object has parsed.
|
||||
// Return: An Array (array.cs) containing relevent information to the requested
|
||||
// block. If there is no such entry of %block, false is returned.
|
||||
//==============================================================================
|
||||
function BasicDataParser::get(%this, %block, %occurance)
|
||||
{
|
||||
// Check ti see uf thus block has only once entry -- in which case %occurance is ignored
|
||||
if (%this.count(%block) == 1) return %this.blocks[%block, 0];
|
||||
// Otherwise we use %occurance to return the specific index
|
||||
else if (%occurance >= 0 && %occurance <= %this.count(%block)) return %this.blocks[%block, %occurance];
|
||||
|
||||
return false;
|
||||
}
|
||||
80
scripts/modscripts/shared/fileProcessing.cs
Normal file
80
scripts/modscripts/shared/fileProcessing.cs
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
// -----------------------------------------------------
|
||||
// fileProcessing.cs
|
||||
// Basic file functions
|
||||
// Copyright (c) 2012 The DarkDragonDX
|
||||
// -----------------------------------------------------
|
||||
function getFileBuffer(%file)
|
||||
{
|
||||
if (!IsFile(%file))
|
||||
return -1;
|
||||
|
||||
new FileObject(FileBuffer);
|
||||
FileBuffer.openForRead(%file);
|
||||
|
||||
while (!FileBuffer.isEOF())
|
||||
%buffer = %buffer @ FileBuffer.readLine() @ "\n";
|
||||
FileBuffer.detach();
|
||||
return %buffer; //Long string. >.>
|
||||
}
|
||||
|
||||
function getLine(%file, %line)
|
||||
{
|
||||
if (!IsFile(%file))
|
||||
return -1;
|
||||
|
||||
new FileObject(FileLine);
|
||||
FileLine.openForRead(%file);
|
||||
|
||||
for (%i = 0; %i < %line; %i++)
|
||||
%line = FileLine.readLine();
|
||||
FileLine.detach();
|
||||
return %line;
|
||||
}
|
||||
|
||||
function getLine(%file, %line)
|
||||
{
|
||||
if (!IsFile(%file))
|
||||
return -1;
|
||||
|
||||
new FileObject(FileLine);
|
||||
FileLine.openForRead(%file);
|
||||
|
||||
for (%i = 0; %i < %line; %i++)
|
||||
%line = FileLine.readLine();
|
||||
FileLine.detach();
|
||||
return %line;
|
||||
}
|
||||
|
||||
// Returns an unsorted list of the contents of %dir (including folders)
|
||||
function getDirectory(%dir)
|
||||
{
|
||||
%array = Array.create();
|
||||
|
||||
%fileCount = 0;
|
||||
for( %file = findFirstFile( %dir @ "*.*" ); %file !$= ""; %file = findNextFile( %dir @ "*.*" ) )
|
||||
{
|
||||
%file = strReplace(%file, %socket.request, "");
|
||||
if (strStr(%file, "/") != -1)
|
||||
{
|
||||
%dir = getSubStr(%file, 0, strStr(%file, "/")) @ "/";
|
||||
if (!%dirAdded[%dir])
|
||||
{
|
||||
%data = %data @ "<a href=\"" @ strReplace(%dir, " ","%20") @ "\">" @ %dir @ "</a><br>\n";
|
||||
%dirAdded[%dir] = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
%data = %data @ "<a href=\"" @ strReplace(%file, " ", "%20") @ "\">" @ %file @ "</a><br>\n";
|
||||
}
|
||||
return %array;
|
||||
}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Bound Functions
|
||||
// -----------------------------------------------------
|
||||
function fileObject::Detach(%this) //Detaches fileObject from file & deletes
|
||||
{
|
||||
%this.close();
|
||||
%this.delete();
|
||||
return %this;
|
||||
}
|
||||
10
scripts/modscripts/shared/initialize.cs
Normal file
10
scripts/modscripts/shared/initialize.cs
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// initialise.cs
|
||||
// Shared Functions for T2Bol
|
||||
// Copyright (c) 2012 The DarkDragonDX
|
||||
//==============================================================================
|
||||
exec("scripts/modScripts/shared/StringFunctions.cs");
|
||||
exec("scripts/modScripts/shared/fileProcessing.cs");
|
||||
exec("scripts/modScripts/shared/basicDataStorage.cs");
|
||||
|
||||
|
||||
201
scripts/modscripts/shared/putback/basicDataStorage.cs
Normal file
201
scripts/modscripts/shared/putback/basicDataStorage.cs
Normal file
|
|
@ -0,0 +1,201 @@
|
|||
// -----------------------------------------------------
|
||||
// Block Processing
|
||||
// -----------------------------------------------------
|
||||
function getBlockCount(%file,%blockName) //Searches a data file for all occurances of 'blockName'
|
||||
{
|
||||
if (!IsFile(%file))
|
||||
return false;
|
||||
|
||||
%blockSearch = strLwr("[" @ %blockName @ "]");
|
||||
|
||||
%fileP = new FileObject();
|
||||
%fileP.openForRead(%file);
|
||||
|
||||
%count = 0;
|
||||
while (!%fileP.isEOF())
|
||||
{
|
||||
%line = %fileP.readLine();
|
||||
%lineTest = strLwr(%line);
|
||||
%Search = strStr(%lineTest,%blockSearch);
|
||||
if (%search != -1)
|
||||
%count++;
|
||||
}
|
||||
%fileP.detach();
|
||||
return %count;
|
||||
}
|
||||
|
||||
function getBlockData(%file,%blockName,%num,%data) //Gets values out of a block. Note that 1 is the first block in a file for %num
|
||||
{
|
||||
if (!IsFile(%file))
|
||||
return false;
|
||||
|
||||
%blockCount = getBlockCount(%file,%blockName);
|
||||
|
||||
if (!%blockCount || %num > %blockCount) //None of 'typeName' exist here
|
||||
return -1;
|
||||
|
||||
%blockSearch = strLwr("[" @ %blockName @ "]");
|
||||
|
||||
%fileP = new FileObject();
|
||||
%fileP.openForRead(%file);
|
||||
|
||||
%count = 0;
|
||||
%lineCount = 0;
|
||||
while (!%fileP.isEOF())
|
||||
{
|
||||
%line = %fileP.readLine();
|
||||
%lineCount++;
|
||||
|
||||
if (getSubStr(stripSpaces(%line),0,1) !$= ";") //If the beginning of the line is "commented", skip it.
|
||||
{
|
||||
%lineTest = strLwr(%line);
|
||||
%Search = strStr(%lineTest,%blockSearch);
|
||||
|
||||
if (%Search != -1 && %Count != %num)
|
||||
%count++;
|
||||
else if (%count == %num) //We found it, stop incrementing the count and find our data.
|
||||
{
|
||||
%Search = strStr(strLwr(%line),strLwr(%data));
|
||||
|
||||
%lineTest = strLwr(strReplace(%line," ","")); //See if we exited our block
|
||||
if (GetSubStr(%lineTest, 0, 1) $= "[") //The beginning of a new block
|
||||
return -1;
|
||||
|
||||
if (%search != -1) //We found it,
|
||||
{
|
||||
%fileP.detach();
|
||||
|
||||
//Since our line might have some sort of commenting after it, we better return to just the "end" symbol..
|
||||
%semiS =strStr(%line, ";");
|
||||
if (%semiS == -1)
|
||||
return -1;
|
||||
%line = getSubStr(%line, 0, %semiS);
|
||||
//Now find where "equals" is..
|
||||
%equalS = strStr(%line, "=");
|
||||
if (%equalS == -1)
|
||||
return -1;
|
||||
%line = getSubStr(%line, %equalS+1, strLen(%line));
|
||||
//Is our data in single quotations? If so, convert it to a tagged string.
|
||||
if (strStr(%line,"\x27") != -1) //It is.
|
||||
%line = addTaggedString(stripChars(%line,"\x27"));
|
||||
//Now return our string without quotations.
|
||||
%line = stripChars(stripTrailingSpaces(strReplace(%line,%data,"")),"\x22");
|
||||
return getSubStr(%line,1,strLen(%line));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
%fileP.detach();
|
||||
return false;
|
||||
}
|
||||
|
||||
//function getBlockLength(%file,%blockName,%num) Won't work until I figure out a way to signal the end of a block without adding any extra characters,
|
||||
//{
|
||||
//if (!IsFile(%file))
|
||||
//return "Not existant.";
|
||||
|
||||
//%blockSearch = "[" @ %blockName @ "]";
|
||||
//%blockSearch = strLwr(%blockSearch); //Convert to lowerCase
|
||||
|
||||
//new FileObject(GetBlockCount);
|
||||
//GetBlockCount.openForRead(%file);
|
||||
|
||||
//%count = 0;
|
||||
//%len = 0;
|
||||
// while (!GetBlockCount.isEOF())
|
||||
// {
|
||||
// %line = GetBlockCount.readLine();
|
||||
// %lineTest = strLwr(%line);
|
||||
// %Search = strStr(%lineTest,%blockSearch);
|
||||
//if (%search != -1)
|
||||
// %count++;
|
||||
// else if (%search != -1 && %count == %num) //We found our wanted block, count it.
|
||||
//{
|
||||
// if (strStr(%lineTest,%blockSearch) == -1)
|
||||
// %len++;
|
||||
// else
|
||||
// break;
|
||||
// }
|
||||
//}
|
||||
//GetBlockCount.detach();
|
||||
//return %len;
|
||||
//}
|
||||
|
||||
// -----------------------------------------------------
|
||||
// Array Processing
|
||||
// -----------------------------------------------------
|
||||
function getArrayCount(%file,%array)
|
||||
{
|
||||
if (!IsFile(%file))
|
||||
return false;
|
||||
|
||||
%arraySearch = strLwr("\x22" @ %array @ "\x22");
|
||||
|
||||
%fileP = new FileObject();
|
||||
%fileP.openForRead(%file);
|
||||
|
||||
%count = 0;
|
||||
while (!%fileP.isEOF())
|
||||
{
|
||||
%line = %fileP.readLine();
|
||||
%lineTest = strLwr(%line);
|
||||
%Search = strStr(%lineTest,%typeSearch);
|
||||
if (%search != -1)
|
||||
%count++;
|
||||
}
|
||||
%fileP.detach();
|
||||
return %count;
|
||||
}
|
||||
|
||||
function getArrayData(%file,%arrayName,%num)
|
||||
{
|
||||
if (!IsFile(%file))
|
||||
return false;
|
||||
|
||||
%arrayCount = getArrayCount(%file,%arrayName);
|
||||
|
||||
if (!%arrayCount)
|
||||
return false;
|
||||
|
||||
%arraySearch = strLwr("\x22" @ %arrayName @ "\x22");
|
||||
|
||||
%fileP = new FileObject();
|
||||
%fileP.openForRead(%file);
|
||||
|
||||
%lineCount = 0;
|
||||
while (!%fileP.isEOF())
|
||||
{
|
||||
%line = stripSpaces(%fileP.readline());
|
||||
%lineCount++;
|
||||
|
||||
if (getSubStr(%line,0,1) !$= ";") //Is this line a comment?
|
||||
{
|
||||
%search = strStr(strLwr(%line),%arraySearch);
|
||||
|
||||
if (%search !$= -1) //Found it.
|
||||
break; //Break the loop, we know the array exists
|
||||
if (%fileP.IsEOF() && %search == -1) //Didn't find it, return the error.
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
//Check where the array actually starts..
|
||||
%line = %fileP.readLine();
|
||||
if (%line $= "{") //Data starts on next line..
|
||||
{
|
||||
%line = %fileP.readLine(); //Drop it down one
|
||||
for (%i = 0; %i < %num; %i++) //Keep going untill we hit the wanted data
|
||||
%line = %fileP.readLine();
|
||||
}
|
||||
else //The line we just grabbed is part of the data
|
||||
{
|
||||
if (%num == 0) //The wanted data was on line zero..
|
||||
return %line;
|
||||
|
||||
for (%i = 0; %i < %num; %i++) //Keep going untill we hit the wanted data
|
||||
%line = %fileP.readLine();
|
||||
}
|
||||
|
||||
%fileP.detach();
|
||||
return %line;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue