Merge branch 'develop'

This commit is contained in:
Robert MacGregor 2012-07-28 11:02:02 -04:00
commit 09f43122e6
15 changed files with 766 additions and 809 deletions

View file

@ -4,7 +4,7 @@
// one of the developers. Otherwise, your decompiler is so advanced that it can // 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 // somehow get commented lines in a script. If this is not the case, someone has
// betrayed my trust. // betrayed my trust.
// -- Dark Dragon DX // -- Dark Dragon DX (as of 2011).
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//Different from modVersionText, is used to compare our mod to the update server //Different from modVersionText, is used to compare our mod to the update server
@ -15,85 +15,83 @@ $ModVersion = 1.0; //Looks better as whole numbuhs
//Although, hooks can be attached for custom actions. //Although, hooks can be attached for custom actions.
function clientCmdHandleScriptedCommand(%num,%arg1,%arg2,%arg3,%arg4) function clientCmdHandleScriptedCommand(%num,%arg1,%arg2,%arg3,%arg4)
{ {
switch(%num) switch(%num)
{ {
case 0: //Pop Dialog case 0: //Pop Dialog
Canvas.popDialog(%arg1); Canvas.popDialog(%arg1);
case 1: //BoxYesNo case 1: //BoxYesNo
messageBoxYesNo(%arg1,%arg2,%arg3,%arg4); messageBoxYesNo(%arg1,%arg2,%arg3,%arg4);
case 2: //FadeIn case 2: //FadeIn
ServerConnection.setBlackOut(true, %arg1); ServerConnection.setBlackOut(true, %arg1);
case 3: //Fadeout case 3: //Fadeout
ServerConnection.setBlackOut(false, %arg1); ServerConnection.setBlackOut(false, %arg1);
case 4: //Show Cursor case 4: //Show Cursor
$cursorControlled = %arg1; $cursorControlled = %arg1;
lockMouse(%arg1); lockMouse(%arg1);
if (%arg1) if (%arg1)
{ {
Canvas.cursorOn(); Canvas.cursorOn();
GlobalActionMap.bind(mouse, button0, RTS_LeftButton); GlobalActionMap.bind(mouse, button0, RTS_LeftButton);
GlobalActionMap.bind(mouse, button1, RTS_RightButton); GlobalActionMap.bind(mouse, button1, RTS_RightButton);
RTS_Command.push(); RTS_Command.push();
$RTS::ButtonPress = false; $RTS::ButtonPress = false;
} }
else else
{ {
Canvas.cursorOff(); Canvas.cursorOff();
GlobalActionMap.unbind(mouse, button0); GlobalActionMap.unbind(mouse, button0);
GlobalActionMap.unbind(mouse, button1); GlobalActionMap.unbind(mouse, button1);
Canvas.setCursor(DefaultCursor); Canvas.setCursor(DefaultCursor);
RTS_Command.pop(); RTS_Command.pop();
$RTS::ButtonPress = true; $RTS::ButtonPress = true;
} }
case 5: //Verify Client case 5: //Verify Client
if (%arg1) if (%arg1)
ScoreParent.settext("PDA - PERSONAL DATA ASSISTANT"); 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);
}
$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. :) timeHud.setValue(%arg1);
//Let the server know we're an actual client.. and if we're offline, send my GUID timeHud.setVisible(1);
if (!$PlayingOnline) default: //If for some reason we got an invalid command ID, report it to console
commandToServer('VerifyClient',$Pref::LANAccount::GUID,$ModVersion); if ($Pref::DeveloperMode) //If dev mode is on (just a value set on the clientside to tell scripts to echo shit to the console)
else error("Scripted Command Handler: Received unknown command request ("@%num@") from server.");
commandToServer('VerifyClient',0,$ModVersion); return false;
}
//Turn off the 'continue' button if it's T2Bol. return true;
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;
} }

View file

@ -1,5 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// initialise.cs
// Client Scripts Init // Client Scripts Init
// Copright (c) 2012 The DarkDragonDX
//============================================================================== //==============================================================================
exec("scripts/modScripts/client/clientFunctions.cs"); exec("scripts/modScripts/client/clientFunctions.cs");
exec("scripts/modScripts/client/serverRequestHandler.cs"); exec("scripts/modScripts/client/serverRequestHandler.cs");

View file

@ -1,5 +1,7 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// serverRequestHandler.cs
// Server Request Handler // Server Request Handler
// Copyright (c) 2012 The DarkDragonDX
//============================================================================== //==============================================================================
function InteractWithObject(%val) function InteractWithObject(%val)

View file

@ -4,300 +4,298 @@
function gameConnection::writeSaveFile(%this) function gameConnection::writeSaveFile(%this)
{ {
//Compile Main Variable List //Compile Main Variable List
%mission = $CurrentMission; %mission = $CurrentMission;
%player = %this.player; %player = %this.player;
%transform = %player.getTransform(); %transform = %player.getTransform();
%velocity = %player.getVelocity(); %velocity = %player.getVelocity();
%damage = %player.getDamageLevel(); %damage = %player.getDamageLevel();
%race = %this.race; %race = %this.race;
%armor = %this.armor; %armor = %this.armor;
%energy = %player.getEnergyLevel(); %energy = %player.getEnergyLevel();
%whiteout = %player.getWhiteout(); %whiteout = %player.getWhiteout();
%damageFlash = %player.getDamageFlash(); %damageFlash = %player.getDamageFlash();
%cash = %this.cash; %cash = %this.cash;
%hasRadio = %this.hasRadio; %hasRadio = %this.hasRadio;
%underStandsHuman = %this.underStandsHuman; %underStandsHuman = %this.underStandsHuman;
%underStandsBioderm = %this.underStandsBioderm; %underStandsBioderm = %this.underStandsBioderm;
%underStandsDraakan = %this.underStandsDraakan; %underStandsDraakan = %this.underStandsDraakan;
%underStandsCriollos = %this.underStandsCriollos; %underStandsCriollos = %this.underStandsCriollos;
%time = formatTimeString("hh:nn A"); %time = formatTimeString("hh:nn A");
%date = formatTimeString("mm/dd/yy"); %date = formatTimeString("mm/dd/yy");
%file = "data/game/saves/" @ %mission @ "/" @ %this.guid @ ".txt"; %file = "data/game/saves/" @ %mission @ "/" @ %this.guid @ ".txt";
%fileObj = new fileObject(); %fileObj = new fileObject();
%fileObj.openForWrite(%file); %fileObj.openForWrite(%file);
%fileObj.writeLine(";Saved by" SPC %this.nameBase SPC "on" SPC %date SPC "at" SPC %time); %fileObj.writeLine(";Saved by" SPC %this.nameBase SPC "on" SPC %date SPC "at" SPC %time);
%fileObj.writeLine(""); %fileObj.writeLine("");
//Todo: Make this writing method more efficient ... //Todo: Make this writing method more efficient ...
%fileObj.writeLine("[Character]"); %fileObj.writeLine("[Character]");
%fileObj.writeLine("transform = \x22" @ %transform @ "\x22;"); %fileObj.writeLine("transform = \x22" @ %transform @ "\x22;");
%fileObj.writeLine("velocity = \x22" @ %velocity @ "\x22;"); %fileObj.writeLine("velocity = \x22" @ %velocity @ "\x22;");
%fileObj.writeLine("damage = \x22" @ %damage @ "\x22;"); %fileObj.writeLine("damage = \x22" @ %damage @ "\x22;");
%fileObj.writeLine("race = \x22" @ %race @ "\x22;"); %fileObj.writeLine("race = \x22" @ %race @ "\x22;");
%fileObj.writeLine("armor = \x22" @ %armor @ "\x22;"); %fileObj.writeLine("armor = \x22" @ %armor @ "\x22;");
%fileObj.writeLine("energy = \x22" @ %energy @ "\x22;"); %fileObj.writeLine("energy = \x22" @ %energy @ "\x22;");
%fileObj.writeLine("whiteOut = \x22" @ %whiteout @ "\x22;"); %fileObj.writeLine("whiteOut = \x22" @ %whiteout @ "\x22;");
%fileObj.writeLine("damageFlash = \x22" @ %damageFlash @ "\x22;"); %fileObj.writeLine("damageFlash = \x22" @ %damageFlash @ "\x22;");
%fileObj.writeLine("cash = \x22" @ %cash @ "\x22;"); %fileObj.writeLine("cash = \x22" @ %cash @ "\x22;");
%fileObj.writeLine("hasRadio = \x22" @ %hasRadio @ "\x22;"); %fileObj.writeLine("hasRadio = \x22" @ %hasRadio @ "\x22;");
%fileObj.writeLine("underStandsHuman = \x22" @ %underStandsHuman @ "\x22;"); %fileObj.writeLine("underStandsHuman = \x22" @ %underStandsHuman @ "\x22;");
%fileObj.writeLine("underStandsBioderm = \x22" @ %underStandsBioderm @ "\x22;"); %fileObj.writeLine("underStandsBioderm = \x22" @ %underStandsBioderm @ "\x22;");
%fileObj.writeLine("underStandsDraakan = \x22" @ %underStandsDraakan @ "\x22;"); %fileObj.writeLine("underStandsDraakan = \x22" @ %underStandsDraakan @ "\x22;");
%fileObj.writeLine("underStandsCriollos = \x22" @ %underStandsCriollos @ "\x22;"); %fileObj.writeLine("underStandsCriollos = \x22" @ %underStandsCriollos @ "\x22;");
%fileObj.writeLine(""); %fileObj.writeLine("");
//Compile Inventory List //Compile Inventory List
%slotCount = %player.weaponSlotCount; %slotCount = %player.weaponSlotCount;
%healthKits = %player.invRepairKit; %healthKits = %player.invRepairKit;
%fileObj.writeLine("[Inventory]"); %fileObj.writeLine("[Inventory]");
%fileObj.writeLine("slotCount = \x22" @ %slotCount @ "\x22;"); %fileObj.writeLine("slotCount = \x22" @ %slotCount @ "\x22;");
for (%i = 0; %i < %slotCount; %i++) for (%i = 0; %i < %slotCount; %i++)
{ {
%weaponName = %player.weaponSlot[%i]; %weaponName = %player.weaponSlot[%i];
%weaponAmmo = eval("%weaponAmmo = %player.inv" @ %weaponName @ "Ammo" @ ";"); %weaponAmmo = eval("%weaponAmmo = %player.inv" @ %weaponName @ "Ammo" @ ";");
%fileObj.writeLine("slot" @ %i SPC "= \x22" @ %weaponName @ "\x22;"); %fileObj.writeLine("slot" @ %i SPC "= \x22" @ %weaponName @ "\x22;");
%fileObj.writeLine("slot" @ %i @ "Ammo" SPC "= \x22" @ %weaponAmmo @ "\x22;"); %fileObj.writeLine("slot" @ %i @ "Ammo" SPC "= \x22" @ %weaponAmmo @ "\x22;");
} }
%fileObj.writeLine("healthKits = \x22" @ %healthKits @ "\x22;"); %fileObj.writeLine("healthKits = \x22" @ %healthKits @ "\x22;");
%fileObj.detach();
%fileObj.detach(); logEcho(" -- Save File Written for Player:" SPC %this.namebase SPC "--");
logEcho(" -- Save File Written for Player:" SPC %this.namebase SPC "--"); return true;
return true;
} }
function gameConnection::applySaveFile(%this) function gameConnection::applySaveFile(%this)
{ {
//Compile Main Variable List //Compile Main Variable List
%mission = $CurrentMission; %mission = $CurrentMission;
%file = "data/game/saves/" @ %mission @ "/" @ %this.guid @ ".txt"; %file = "data/game/saves/" @ %mission @ "/" @ %this.guid @ ".txt";
if (!isFile(%file)) if (!isFile(%file))
return false; return false;
%transform = getBlockData(%file,"Character",1,"transform"); %transform = getBlockData(%file,"Character",1,"transform");
%velocity = getBlockData(%file,"Character",1,"velocity"); %velocity = getBlockData(%file,"Character",1,"velocity");
%damage = getBlockData(%file,"Character",1,"damage"); %damage = getBlockData(%file,"Character",1,"damage");
%race = getBlockData(%file,"Character",1,"race"); %race = getBlockData(%file,"Character",1,"race");
%armor = getBlockData(%file,"Character",1,"armor"); %armor = getBlockData(%file,"Character",1,"armor");
%energy = getBlockData(%file,"Character",1,"energyLevel"); %energy = getBlockData(%file,"Character",1,"energyLevel");
%whiteout = getBlockData(%file,"Character",1,"whiteOut"); %whiteout = getBlockData(%file,"Character",1,"whiteOut");
%damageFlash = getBlockData(%file,"Character",1,"damageFlash"); %damageFlash = getBlockData(%file,"Character",1,"damageFlash");
%cash = getBlockData(%file,"Character",1,"cash"); %cash = getBlockData(%file,"Character",1,"cash");
%hasRadio = getBlockData(%file,"Character",1,"hasRadio"); %hasRadio = getBlockData(%file,"Character",1,"hasRadio");
%underStandsHuman = getBlockData(%file,"Character",1,"underStandsHuman"); %underStandsHuman = getBlockData(%file,"Character",1,"underStandsHuman");
%underStandsBioderm = getBlockData(%file,"Character",1,"underStandsBioderm"); %underStandsBioderm = getBlockData(%file,"Character",1,"underStandsBioderm");
%underStandsDraakan = getBlockData(%file,"Character",1,"underStandsDraakan"); %underStandsDraakan = getBlockData(%file,"Character",1,"underStandsDraakan");
%underStandsCriollos = getBlockData(%file,"Character",1,"underStandsCriollos"); %underStandsCriollos = getBlockData(%file,"Character",1,"underStandsCriollos");
%player = %this.player; %player = %this.player;
%player.setTransform(%transform); %player.setTransform(%transform);
%player.setVelocity(%velocity); %player.setVelocity(%velocity);
%player.applyDamage(%damage); %player.applyDamage(%damage);
%player.setArmor(%armor); %player.setArmor(%armor);
%player.setEnergyLevel(%energy); %player.setEnergyLevel(%energy);
%player.setWhiteout(%whiteOut); %player.setWhiteout(%whiteOut);
%player.setDamageFlash(%damageFlash); %player.setDamageFlash(%damageFlash);
%this.cash = %cash; %this.cash = %cash;
%this.underStandsHuman = %underStandsHuman; %this.underStandsHuman = %underStandsHuman;
%this.underStandsBioderm = %underStandsBioderm; %this.underStandsBioderm = %underStandsBioderm;
%this.underStandsDraakan = %underStandsDraakan; %this.underStandsDraakan = %underStandsDraakan;
%this.underStandsCriollos = %underStandsCriollos; %this.underStandsCriollos = %underStandsCriollos;
return true; return true;
for (%i = 0; %i < %slotCount; %i++) for (%i = 0; %i < %slotCount; %i++)
{ {
%weaponName = %player.weaponSlot[%i]; %weaponName = %player.weaponSlot[%i];
%weaponAmmo = eval("%weaponAmmo = %player.inv" @ %weaponName @ "Ammo" @ ";"); %weaponAmmo = eval("%weaponAmmo = %player.inv" @ %weaponName @ "Ammo" @ ";");
%fileObj.writeLine("slot" @ %i SPC "= \x22" @ %weaponName @ "\x22;"); %fileObj.writeLine("slot" @ %i SPC "= \x22" @ %weaponName @ "\x22;");
%fileObj.writeLine("slot" @ %i @ "Ammo" SPC "= \x22" @ %weaponAmmo @ "\x22;"); %fileObj.writeLine("slot" @ %i @ "Ammo" SPC "= \x22" @ %weaponAmmo @ "\x22;");
} }
%fileObj.writeLine("healthKits = \x22" @ %healthKits @ "\x22;"); %fileObj.writeLine("healthKits = \x22" @ %healthKits @ "\x22;");
return;
} }
// Generic Import Functions // Generic Import Functions
function importGameData() function importGameData()
{ {
importGems(); importGems();
importOres(); importOres();
importCharacters(); importCharacters();
return true; return true;
} }
// Gem Import Functions // Gem Import Functions
function importGems() function importGems()
{ {
if (!IsObject(GemData)) if (!IsObject(GemData))
{ {
new ScriptObject(GemData); new ScriptObject(GemData);
if (!IsObject(GameData)) if (!IsObject(GameData))
new simGroup(GameData); new simGroup(GameData);
GameData.add(GemData); GameData.add(GemData);
} }
else else
return true; return true;
%file = "data/game/gems.txt"; %file = "data/game/gems.txt";
%count = getBlockCount(%file,"Gem") + 1; %count = getBlockCount(%file,"Gem") + 1;
for (%i = 1; %i < %count; %i++) for (%i = 1; %i < %count; %i++)
{ {
%name = getBlockData(%file,"Gem",%i,"Name"); %name = getBlockData(%file,"Gem",%i,"Name");
%price = getBlockData(%file,"Gem",%i,"Price"); %price = getBlockData(%file,"Gem",%i,"Price");
%sellPrice = getBlockData(%file,"Gem",%i,"SellPrice"); %sellPrice = getBlockData(%file,"Gem",%i,"SellPrice");
GemData.gem[%i] = %name; GemData.gem[%i] = %name;
GemData.price[%name] = %price; GemData.price[%name] = %price;
GemData.sellPrice[%name] = %sellPrice; GemData.sellPrice[%name] = %sellPrice;
warn("Imported gem:" SPC %name); warn("Imported gem:" SPC %name);
}
GemData.gemCount = %count--; GemData.gemCount = %count--;
} }
// Ore Import Functions // Ore Import Functions
function importOres() function importOres()
{ {
if (!IsObject(OreData)) if (!IsObject(OreData))
{ {
new ScriptObject(OreData); new ScriptObject(OreData);
if (!IsObject(GameData)) if (!IsObject(GameData))
new simGroup(GameData); new simGroup(GameData);
GameData.add(OreData); GameData.add(OreData);
} }
else else
return true; return true;
%file = "data/game/ores.txt"; %file = "data/game/ores.txt";
%count = getBlockCount(%file,"Ore") + 1; %count = getBlockCount(%file,"Ore") + 1;
for (%i = 1; %i < %count; %i++) for (%i = 1; %i < %count; %i++)
{ {
%name = getBlockData(%file,"Ore",%i,"Name"); %name = getBlockData(%file,"Ore",%i,"Name");
%price = getBlockData(%file,"Ore",%i,"Price"); %price = getBlockData(%file,"Ore",%i,"Price");
%sellPrice = getBlockData(%file,"Ore",%i,"SellPrice"); %sellPrice = getBlockData(%file,"Ore",%i,"SellPrice");
OreData.ore[%i] = %name; OreData.ore[%i] = %name;
OreData.price[%name] = %price; OreData.price[%name] = %price;
OreData.sellPrice[%name] = %sellPrice; OreData.sellPrice[%name] = %sellPrice;
warn("Imported ore:" SPC %name); warn("Imported ore:" SPC %name);
} }
OreData.oreCount = %count--; OreData.oreCount = %count--;
} }
// Character Import Functions // Character Import Functions
function spawnCharacter(%name,%trans,%aimPos,%team) function spawnCharacter(%name,%trans,%aimPos,%team)
{ {
%object = "Character" @ %name; %object = "Character" @ %name;
if (!IsObject(%object)) if (!IsObject(%object))
return false; return false;
%Bname = %object.name; %Bname = %object.name;
%race = %object.race; %race = %object.race;
%skin = %object.skin; %skin = %object.skin;
%voice = %object.voice; %voice = %object.voice;
%voicePitch = %object.voicePitch; %voicePitch = %object.voicePitch;
%sex = %object.sex; %sex = %object.sex;
%bot = aiConnectByName(%Bname,%team); %bot = aiConnectByName(%Bname,%team);
%bot.race = %race; %bot.race = %race;
%bot.skin = addTaggedString(%skin); %bot.skin = addTaggedString(%skin);
%bot.voice = %voice; %bot.voice = %voice;
%bot.voiceTag = addTaggedString(%voice); %bot.voiceTag = addTaggedString(%voice);
%bot.voicePitch = %voicePitch; %bot.voicePitch = %voicePitch;
%bot.sex = %sex; %bot.sex = %sex;
setVoice(%bot,%voice, %voicePitch); setVoice(%bot,%voice, %voicePitch);
setSkin(%bot,%skin); setSkin(%bot,%skin);
setSkin(%bot,%skin); setSkin(%bot,%skin);
setTeam(%bot, %team); setTeam(%bot, %team);
%bot.player.setArmor("light"); %bot.player.setArmor("light");
%bot.player.setTransform(%trans); %bot.player.setTransform(%trans);
%bot.aimAt(%aimPos); %bot.aimAt(%aimPos);
warn("Spawned Character:" SPC %name); warn("Spawned Character:" SPC %name);
} }
function importCharacters() function importCharacters()
{ {
%path = "data/game/characters/*.txt"; %path = "data/game/characters/*.txt";
for( %file = findFirstFile( %path ); %file !$= ""; %file = findNextFile( %path ) ) for( %file = findFirstFile( %path ); %file !$= ""; %file = findNextFile( %path ) )
{ {
%name = getFileNameFromString(%file); %name = getFileNameFromString(%file);
%pos = strStr(%name,"."); %pos = strStr(%name,".");
%character = getSubStr(%name,0,%pos); %character = getSubStr(%name,0,%pos);
importCharacter(%character); importCharacter(%character);
} }
} }
function importCharacter(%character) function importCharacter(%character)
{ {
%prefix = "data/game/characters/"; %prefix = "data/game/characters/";
%file = %prefix @ %character @ ".txt"; %file = %prefix @ %character @ ".txt";
%charName = %character; %charName = %character;
%character = strReplace("Character" @ %character," ","_"); %character = strReplace("Character" @ %character," ","_");
if (!IsFile(%file)) if (!IsFile(%file))
return false; return false;
if (!IsObject(%character)) if (!IsObject(%character))
{ {
new scriptObject(%character); new scriptObject(%character);
if (!IsObject(GameData))
new simGroup(GameData);
if (!IsObject(GameData)) GameData.add(%character);
new simGroup(GameData); }
else
return true;
GameData.add(%character); //Get our variable values ...
} %name = getBlockData(%file,"Character",1,"Name");
else %race = getBlockData(%file,"Character",1,"Race");
return true; %sex = getBlockData(%file,"Character",1,"Sex");
%skin = getBlockData(%file,"Character",1,"Skin");
%voice = getBlockData(%file,"Character",1,"Voice");
%voicePitch = getBlockData(%file,"Character",1,"VoicePitch");
//Get our variable values ... //Import Message Arrays ... and assign them
%name = getBlockData(%file,"Character",1,"Name"); %arrayName[0] = "Death";
%race = getBlockData(%file,"Character",1,"Race"); %arrayName[1] = "Kill";
%sex = getBlockData(%file,"Character",1,"Sex"); %arrayName[2] = "Healed";
%skin = getBlockData(%file,"Character",1,"Skin"); %arrayCount = 3;
%voice = getBlockData(%file,"Character",1,"Voice");
%voicePitch = getBlockData(%file,"Character",1,"VoicePitch");
//Import Message Arrays ... and assign them for (%i = 0; %i < %arrayCount; %i++)
%arrayName[0] = "Death"; {
%arrayName[1] = "Kill"; %arrayVariableName[%i] = %arrayName[%i] @ "MessageArray";
%arrayName[2] = "Healed"; for (%j = 0; %j < 100; %j++)
%arrayCount = 3; {
%arrayTest = getArrayData(%file,%arrayName[%i],%j);
for (%i = 0; %i < %arrayCount; %i++) if (%arrayTest !$= "}")
{ {
%arrayVariableName[%i] = %arrayName[%i] @ "MessageArray"; if (%j == 0)
for (%j = 0; %j < 100; %j++) %arrayData[%i] = %arrayData[%i] @ %arrayTest;
{ else
%arrayTest = getArrayData(%file,%arrayName[%i],%j); %arrayData[%i] = %arrayData[%i] @ "\t" @ %arrayTest;
if (%arrayTest !$= "}") }
{ else
if (%j == 0) break;
%arrayData[%i] = %arrayData[%i] @ %arrayTest; }
else eval(%character @ "." @ %arrayVariableName[%i] SPC "= \x22" @ %arrayData[%i] @ "\x22;");
%arrayData[%i] = %arrayData[%i] @ "\t" @ %arrayTest; }
} //Assign the variables now ...
else %character.name = %name;
break; %character.race = %race;
} %character.sex = %sex;
eval(%character @ "." @ %arrayVariableName[%i] SPC "= \x22" @ %arrayData[%i] @ "\x22;"); %character.skin = %skin;
} %character.voice = %voice;
%character.voicePitch = %voicePitch;
//Assign the variables now ... warn("Imported Character:" SPC %charname);
%character.name = %name;
%character.race = %race;
%character.sex = %sex;
%character.skin = %skin;
%character.voice = %voice;
%character.voicePitch = %voicePitch;
warn("Imported Character:" SPC %charname);
} }

View file

@ -38,70 +38,69 @@ datablock ItemData(Lootbag)
function LootBagCheckForPickUp(%this) //Not sure why, loot bags won't do a T2 system pickup.. function LootBagCheckForPickUp(%this) //Not sure why, loot bags won't do a T2 system pickup..
{ {
cancel(%this.loop); cancel(%this.loop);
if (!IsObject(%this)) if (!IsObject(%this))
return; return;
%count = MissionCleanUp.getCount(); %count = MissionCleanUp.getCount();
for(%i = 0; %i < %count; %i++) for(%i = 0; %i < %count; %i++)
{ {
%test = MissionCleanUp.getObject(%i); %test = MissionCleanUp.getObject(%i);
if (%test.getClassName() $= "Player" && %test.getState() !$= "dead" && !%test.client.isAIControlled()) if (%test.getClassName() $= "Player" && %test.getState() !$= "dead" && !%test.client.isAIControlled())
{ {
%dist = vectorDist(%this.getPosition(),%test.getPosition()); %dist = vectorDist(%this.getPosition(),%test.getPosition());
if (%dist < %this.getDatablock().pickUpRadius) if (%dist < %this.getDatablock().pickUpRadius)
{ {
LootBagPickedUp(%this,%test.client); LootBagPickedUp(%this,%test.client);
return; return;
} }
%this.loop = schedule(100,0,"LootBagCheckForPickup",%this); %this.loop = schedule(100,0,"LootBagCheckForPickup",%this);
} }
} }
} }
function LootBagPickedUp(%this,%client) function LootBagPickedUp(%this,%client)
{ {
%db = %client.player.getDatablock(); //The player's datablock %db = %client.player.getDatablock(); //The player's datablock
%money = %this.money; //Monies? %money = %this.money; //Monies?
%numItems = %this.numItems; //Giving out items. %numItems = %this.numItems; //Giving out items.
%numAmmo = %this.numAmmo; //..Ammo too! %numAmmo = %this.numAmmo; //..Ammo too!
//Does the bag have money? //Does the bag have money?
if (%money $= "") if (%money $= "")
%hasMoney = false; %hasMoney = false;
else else
%hasMoney = true; %hasMoney = true;
if (%money !$= "") if (%money !$= "")
%client.money = %client.money + %money; //Give some monies. %client.money = %client.money + %money; //Give some monies.
for (%i = 0; %i < %numItems; %i++) 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? 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.item[%i],1);
%client.player.setInventory(%this.ammo[%i],%this.ammoNum[%i]); %client.player.setInventory(%this.ammo[%i],%this.ammoNum[%i]);
} }
} }
%this.delete(); //Delete the bag. %this.delete(); //Delete the bag.
//Let the player know. //Let the player know.
switch (%hasMoney) switch (%hasMoney)
{ {
case 0: case 0:
if (%numItems > 1) if (%numItems > 1)
messageClient(%client,'MsgClient','You picked up a bag of items that contained %1 items.',%numitems); messageClient(%client,'MsgClient','You picked up a bag of items that contained %1 items.',%numitems);
else else
messageClient(%client,'MsgClient','You picked up a bag of items that contained 1 item.'); messageClient(%client,'MsgClient','You picked up a bag of items that contained 1 item.');
case 1: case 1:
if (%numItems > 1) if (%numItems > 1)
messageClient(%client,'MsgClient','You picked up a bag of items that contained $%1 and %2 items.',%money,%numitems); messageClient(%client,'MsgClient','You picked up a bag of items that contained $%1 and %2 items.',%money,%numitems);
else else
messageClient(%client,'MsgClient','You picked up a bag of items that contained $%1 and 1 item.',%money); messageClient(%client,'MsgClient','You picked up a bag of items that contained $%1 and 1 item.',%money);
}
} }
}

View file

@ -33,6 +33,6 @@ datablock StaticShapeData(MiningBox) : StaticShapeDamageProfile {
// ----------------------------------------------------- // -----------------------------------------------------
function MiningBox::onAdd(%this, %obj) function MiningBox::onAdd(%this, %obj)
{ {
%obj.startFade(1,0,1); %obj.startFade(1,0,1);
%obj.applyDamage(%obj.getDataBlock().maxDamage); //Start the rock off %obj.applyDamage(%obj.getDataBlock().maxDamage); //Start the rock off
} }

View file

@ -72,5 +72,5 @@ datablock StaticShapeData(DeployedSpine) : StaticShapeDamageProfile {
//---------------------------------------------------------------------------- //----------------------------------------------------------------------------
function DetructableSecurityCamera::onDestroyed(%this, %obj) function DetructableSecurityCamera::onDestroyed(%this, %obj)
{ {
schedule(1000,0,"delete",%obj); schedule(1000,0,"delete",%obj);
} }

View file

@ -9,159 +9,149 @@
function InteriorInstance::buyObject(%this,%objectID,%client,%team) function InteriorInstance::buyObject(%this,%objectID,%client,%team)
{ {
if (%this.generatorCount $= "") if (%this.generatorCount $= "")
%this.generatorCount = 0; %this.generatorCount = 0;
if (%this.inventoryCount $= "") if (%this.inventoryCount $= "")
%this.inventoryCount = 0; %this.inventoryCount = 0;
if (%this.sensorCount $= "") if (%this.sensorCount $= "")
%this.sensorCount = 0; %this.sensorCount = 0;
if (%this.sentryCount $= "") if (%this.sentryCount $= "")
%this.sentryCount = 0; %this.sentryCount = 0;
if (%this.bannerCount $= "") if (%this.bannerCount $= "")
%this.bannerCount = 0; %this.bannerCount = 0;
if (%this.turretBaseCount $= "") if (%this.turretBaseCount $= "")
%this.turretBaseCount = 0; %this.turretBaseCount = 0;
switch(%objectID) switch(%objectID)
{ {
case 0: //Generator case 0: //Generator
if (%this.generatorCount == $Property::Max[%this.interiorFile,0]) if (%this.generatorCount == $Property::Max[%this.interiorFile,0])
return false; return false;
%shape = new StaticShape() %shape = new StaticShape()
{ {
DataBlock = GeneratorLarge; DataBlock = GeneratorLarge;
Position = vectorAdd($Property::Offset[%this.interiorFile,0,%this.generatorCount],%this.getPosition()); Position = vectorAdd($Property::Offset[%this.interiorFile,0,%this.generatorCount],%this.getPosition());
Rotation = $Property::Rotation[%this.interiorFile,0,%this.generatorCount]; Rotation = $Property::Rotation[%this.interiorFile,0,%this.generatorCount];
Team = %team; Team = %team;
}; };
GeneratorLarge.gainPower(%shape); GeneratorLarge.gainPower(%shape);
%this.generatorCount++;
%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;
case 1: //Inventory %shape = new StaticShape()
if (%this.generatorCount == 0 || %this.inventoryCount == $Property::Max[%this.interiorFile,1]) //Don't create if there's no generators {
return false; DataBlock = StationInventory;
Position = vectorAdd($Property::Offset[%this.interiorFile,1,%this.inventoryCount],%this.getPosition());
Rotation = $Property::Rotation[%this.interiorFile,1,%this.inventoryCount];
Team = %team;
};
%shape = new StaticShape() StationInventory.gainPower(%shape);
{ %this.inventoryCount++;
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); case 2: //Sensor (Medium)
if (%this.generatorCount == 0 || %this.sensorCount == $Property::Max[%this.interiorFile,2])
return false;
%this.inventoryCount++; %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 2: //Sensor (Medium) case 3: //Sensor (Large)
if (%this.generatorCount == 0 || %this.sensorCount == $Property::Max[%this.interiorFile,2]) if (%this.generatorCount == 0 || %this.sensorCount == $Property::Max[%this.interiorFile,2])
return false; return false;
%shape = new StaticShape() %shape = new StaticShape()
{ {
DataBlock = SensorMediumPulse; DataBlock = SensorLargePulse;
Position = vectorAdd($Property::Offset[%this.interiorFile,2,%this.sensorCount],%this.getPosition()); Position = vectorAdd($Property::Offset[%this.interiorFile,3,%this.sensorCount],%this.getPosition());
Rotation = $Property::Rotation[%this.interiorFile,2,%this.sensorCount]; Rotation = $Property::Rotation[%this.interiorFile,3,%this.sensorCount];
Team = %team; Team = %team;
}; };
SensorMediumPulse.gainPower(%shape); SensorLargePulse.gainPower(%shape);
%this.sensorCount++;
%this.sensorCount++; case 4: //Sentry Turrets
if (%this.generatorCount == 0 || %this.sentryCount == $Property::Max[%this.interiorFile,4])
return false;
case 3: //Sensor (Large) %shape = new StaticShape()
if (%this.generatorCount == 0 || %this.sensorCount == $Property::Max[%this.interiorFile,2]) {
return false; 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++;
%shape = new StaticShape() case 5: //Banner (Strength)
{ if (%this.bannerCount == $Property::Max[%this.interiorFile,5])
DataBlock = SensorLargePulse; return false;
Position = vectorAdd($Property::Offset[%this.interiorFile,3,%this.sensorCount],%this.getPosition()); %shape = new StaticShape()
Rotation = $Property::Rotation[%this.interiorFile,3,%this.sensorCount]; {
Team = %team; 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++;
SensorLargePulse.gainPower(%shape); case 6: //Large Turret Base
if (%this.generatorCount == 0 || %this.turretBaseCount == $Property::Max[%this.interiorFile,6])
return false;
%this.sensorCount++; %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;
};
case 4: //Sentry Turrets %this.turretBaseCount++;
if (%this.generatorCount == 0 || %this.sentryCount == $Property::Max[%this.interiorFile,4]) }
return false;
%shape = new StaticShape() %this.getGroup().add(%shape);
{ setTargetName(%shape.target,addTaggedString(%client.namebase @ "'s"));
DataBlock = SentryTurret; setTargetSensorGroup(%shape.getTarget(), %team);
Position = vectorAdd($Property::Offset[%this.interiorFile,4,%this.sentryCount],%this.getPosition()); %shape.setSelfPowered();
Rotation = $Property::Rotation[%this.interiorFile,4,%this.sentryCount]; return %shape;
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) function staticShape::setPosition(%this,%pos)
{ {
%this.setTransform(%pos); %this.setTransform(%pos);
return %this; return %this;
} }
function staticShape::getRotation(%this) function staticShape::getRotation(%this)
{ {
%trans = %this.getTransform(); %trans = %this.getTransform();
return getWord(%trans, 3) SPC getWord(%trans, 4) SPC getWord(%trans,5); return getWord(%trans, 3) SPC getWord(%trans, 4) SPC getWord(%trans,5);
} }
function objectIDToDatablock(%objectID) function objectIDToDatablock(%objectID)
{ {
switch(%objectID) switch(%objectID)
{ {
case 0: return "GeneratorLarge"; case 0: return "GeneratorLarge";
case 1: return 0; case 1: return 0;
default: return -1; default: return -1;
} }
return -1; return -1;
} }

View file

@ -9,45 +9,45 @@
//This should be used if I make some sort of online System //This should be used if I make some sort of online System
function setVoice(%client, %voice, %voicepitch) function setVoice(%client, %voice, %voicepitch)
{ {
freeClientTarget(%client); freeClientTarget(%client);
%client.voice = %voice; %client.voice = %voice;
%client.voicetag = addtaggedstring(%voice); %client.voicetag = addtaggedstring(%voice);
%client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', 0, 0, %client.voicePitch); %client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', 0, 0, %client.voicePitch);
if (IsObject(%client.player)) if (IsObject(%client.player))
%client.player.setTarget(%client.target); %client.player.setTarget(%client.target);
} }
function setSkin(%client, %skin) function setSkin(%client, %skin)
{ {
freeClientTarget(%client); freeClientTarget(%client);
%client.skin = addtaggedstring(%skin); %client.skin = addtaggedstring(%skin);
%client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', 0, 0, %client.voicePitch); %client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', 0, 0, %client.voicePitch);
if (IsObject(%client.player)) if (IsObject(%client.player))
%client.player.setTarget(%client.target); %client.player.setTarget(%client.target);
} }
function setName(%client, %name) function setName(%client, %name)
{ {
freeClientTarget(%client); freeClientTarget(%client);
%client.namebase = %name; %client.namebase = %name;
%client.name = addtaggedstring(%name); %client.name = addtaggedstring(%name);
%client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', 0, 0, %client.voicePitch); %client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', 0, 0, %client.voicePitch);
if (IsObject(%client.player)) if (IsObject(%client.player))
%client.player.setTarget(%client.target); %client.player.setTarget(%client.target);
//Update the client in the lobby. //Update the client in the lobby.
HideClient(%client); HideClient(%client);
ShowClient(%client); ShowClient(%client);
} }
function setTeam(%client,%team) function setTeam(%client,%team)
{ {
%client.team = %team; %client.team = %team;
%client.setSensorGroup(%team); %client.setSensorGroup(%team);
setTargetSensorGroup(%client.target,%team); setTargetSensorGroup(%client.target,%team);
} }

View file

@ -11,13 +11,13 @@ function ServerNetwork::onConnect(%this)
function ServerNetwork::onConnectFailed(%this) function ServerNetwork::onConnectFailed(%this)
{ {
if (%this.testingServer) if (%this.testingServer)
{ {
error("Error: Unable to verify connection to server "@%this.testIP@" at port "@%this.testPort@"!"); error("Error: Unable to verify connection to server "@%this.testIP@" at port "@%this.testPort@"!");
%this.testIP = ""; %this.testIP = "";
%this.testPort = ""; %this.testPort = "";
%this.testingServer = false; %this.testingServer = false;
} }
} }
function ServerNetwork::onDisconnect(%this) function ServerNetwork::onDisconnect(%this)
@ -42,8 +42,8 @@ function ServerNetwork::onLine(%this, %line)
function ServerNetwork::testServerIP(%this, %IP, %port) function ServerNetwork::testServerIP(%this, %IP, %port)
{ {
%this.testingServer = true; %this.testingServer = true;
%this.testIP = %ip; %this.testIP = %ip;
%this.testPort = %port; %this.testPort = %port;
%this.connect(%ip @ ":" @ %port); %this.connect(%ip @ ":" @ %port);
} }

View file

@ -3,91 +3,90 @@
// ----------------------------------------------------- // -----------------------------------------------------
function getBlockCount(%file,%blockName) //Searches a data file for all occurances of 'blockName' function getBlockCount(%file,%blockName) //Searches a data file for all occurances of 'blockName'
{ {
if (!IsFile(%file)) if (!IsFile(%file))
return false; return false;
%blockSearch = strLwr("[" @ %blockName @ "]"); %blockSearch = strLwr("[" @ %blockName @ "]");
%fileP = new FileObject(); %fileP = new FileObject();
%fileP.openForRead(%file); %fileP.openForRead(%file);
%count = 0; %count = 0;
while (!%fileP.isEOF()) while (!%fileP.isEOF())
{ {
%line = %fileP.readLine(); %line = %fileP.readLine();
%lineTest = strLwr(%line); %lineTest = strLwr(%line);
%Search = strStr(%lineTest,%blockSearch); %Search = strStr(%lineTest,%blockSearch);
if (%search != -1) if (%search != -1)
%count++; %count++;
} }
%fileP.detach(); %fileP.detach();
return %count; 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 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)) if (!IsFile(%file))
return false; return false;
%blockCount = getBlockCount(%file,%blockName); %blockCount = getBlockCount(%file,%blockName);
if (!%blockCount || %num > %blockCount) //None of 'typeName' exist here if (!%blockCount || %num > %blockCount) //None of 'typeName' exist here
return -1; return -1;
%blockSearch = strLwr("[" @ %blockName @ "]"); %blockSearch = strLwr("[" @ %blockName @ "]");
%fileP = new FileObject(); %fileP = new FileObject();
%fileP.openForRead(%file); %fileP.openForRead(%file);
%count = 0; %count = 0;
%lineCount = 0; %lineCount = 0;
while (!%fileP.isEOF()) while (!%fileP.isEOF())
{ {
%line = %fileP.readLine(); %line = %fileP.readLine();
%lineCount++; %lineCount++;
if (getSubStr(stripSpaces(%line),0,1) !$= ";") //If the beginning of the line is "commented", skip it. if (getSubStr(stripSpaces(%line),0,1) !$= ";") //If the beginning of the line is "commented", skip it.
{ {
%lineTest = strLwr(%line); %lineTest = strLwr(%line);
%Search = strStr(%lineTest,%blockSearch); %Search = strStr(%lineTest,%blockSearch);
if (%Search != -1 && %Count != %num) if (%Search != -1 && %Count != %num)
%count++; %count++;
else if (%count == %num) //We found it, stop incrementing the count and find our data. else if (%count == %num) //We found it, stop incrementing the count and find our data.
{ {
%Search = strStr(strLwr(%line),strLwr(%data)); %Search = strStr(strLwr(%line),strLwr(%data));
%lineTest = strLwr(strReplace(%line," ","")); //See if we exited our block %lineTest = strLwr(strReplace(%line," ","")); //See if we exited our block
if (GetSubStr(%lineTest, 0, 1) $= "[") //The beginning of a new block if (GetSubStr(%lineTest, 0, 1) $= "[") //The beginning of a new block
return -1; return -1;
if (%search != -1) //We found it, if (%search != -1) //We found it,
{ {
%fileP.detach(); %fileP.detach();
//Since our line might have some sort of commenting after it, we better return to just the "end" symbol.. //Since our line might have some sort of commenting after it, we better return to just the "end" symbol..
%semiS =strStr(%line, ";"); %semiS =strStr(%line, ";");
if (%semiS == -1) if (%semiS == -1)
return -1; return -1;
%line = getSubStr(%line, 0, %semiS); %line = getSubStr(%line, 0, %semiS);
//Now find where "equals" is.. //Now find where "equals" is..
%equalS = strStr(%line, "="); %equalS = strStr(%line, "=");
if (%equalS == -1) if (%equalS == -1)
return -1; return -1;
%line = getSubStr(%line, %equalS+1, strLen(%line)); %line = getSubStr(%line, %equalS+1, strLen(%line));
//Is our data in single quotations? If so, convert it to a tagged string. //Is our data in single quotations? If so, convert it to a tagged string.
if (strStr(%line,"\x27") != -1) //It is. if (strStr(%line,"\x27") != -1) //It is.
%line = addTaggedString(stripChars(%line,"\x27")); %line = addTaggedString(stripChars(%line,"\x27"));
//Now return our string without quotations. //Now return our string without quotations.
%line = stripChars(stripTrailingSpaces(strReplace(%line,%data,"")),"\x22"); %line = stripChars(stripTrailingSpaces(strReplace(%line,%data,"")),"\x22");
return getSubStr(%line,1,strLen(%line)); return getSubStr(%line,1,strLen(%line));
} }
} }
} }
} }
%fileP.detach();
%fileP.detach(); return false;
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, //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,
@ -127,81 +126,76 @@ return false;
// ----------------------------------------------------- // -----------------------------------------------------
function getArrayCount(%file,%array) function getArrayCount(%file,%array)
{ {
if (!IsFile(%file)) if (!IsFile(%file))
return false; return false;
%arraySearch = strLwr("\x22" @ %array @ "\x22"); %arraySearch = strLwr("\x22" @ %array @ "\x22");
%fileP = new FileObject(); %fileP = new FileObject();
%fileP.openForRead(%file); %fileP.openForRead(%file);
%count = 0; %count = 0;
while (!%fileP.isEOF()) while (!%fileP.isEOF())
{ {
%line = %fileP.readLine(); %line = %fileP.readLine();
%lineTest = strLwr(%line); %lineTest = strLwr(%line);
%Search = strStr(%lineTest,%typeSearch); %Search = strStr(%lineTest,%typeSearch);
if (%search != -1) if (%search != -1)
%count++; %count++;
} }
%fileP.detach(); %fileP.detach();
return %count; return %count;
} }
function getArrayData(%file,%arrayName,%num) function getArrayData(%file,%arrayName,%num)
{ {
if (!IsFile(%file)) if (!IsFile(%file))
return false; return false;
%arrayCount = getArrayCount(%file,%arrayName); %arrayCount = getArrayCount(%file,%arrayName);
if (!%arrayCount) if (!%arrayCount)
return false; return false;
%arraySearch = strLwr("\x22" @ %arrayName @ "\x22"); %arraySearch = strLwr("\x22" @ %arrayName @ "\x22");
%fileP = new FileObject(); %fileP = new FileObject();
%fileP.openForRead(%file); %fileP.openForRead(%file);
%lineCount = 0; %lineCount = 0;
while (!%fileP.isEOF()) while (!%fileP.isEOF())
{ {
%line = stripSpaces(%fileP.readline()); %line = stripSpaces(%fileP.readline());
%lineCount++; %lineCount++;
if (getSubStr(%line,0,1) !$= ";") //Is this line a comment? if (getSubStr(%line,0,1) !$= ";") //Is this line a comment?
{ {
%search = strStr(strLwr(%line),%arraySearch); %search = strStr(strLwr(%line),%arraySearch);
if (%search !$= -1) //Found it. if (%search !$= -1) //Found it.
break; //Break the loop, we know the array exists break; //Break the loop, we know the array exists
if (%fileP.IsEOF() && %search == -1) //Didn't find it, return the error. if (%fileP.IsEOF() && %search == -1) //Didn't find it, return the error.
return false; return false;
} }
} }
//Check where the array actually starts.. //Check where the array actually starts..
%line = %fileP.readLine(); %line = %fileP.readLine();
if (%line $= "{") //Data starts on next line.. if (%line $= "{") //Data starts on next line..
{ {
%line = %fileP.readLine(); //Drop it down one %line = %fileP.readLine(); //Drop it down one
for (%i = 0; %i < %num; %i++) //Keep going untill we hit the wanted data for (%i = 0; %i < %num; %i++) //Keep going untill we hit the wanted data
{ %line = %fileP.readLine();
%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;
} }
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;
}

View file

@ -1,54 +1,48 @@
// ----------------------------------------------------- // -----------------------------------------------------
// fileProcessing.cs
// Basic file functions // Basic file functions
// Copyright (c) 2012 The DarkDragonDX
// ----------------------------------------------------- // -----------------------------------------------------
function getFileBuffer(%file) function getFileBuffer(%file)
{ {
if (!IsFile(%file)) if (!IsFile(%file))
return "Not existant."; return "Not existant.";
new FileObject(FileBuffer); new FileObject(FileBuffer);
FileBuffer.openForRead(%file); FileBuffer.openForRead(%file);
while (!FileBuffer.isEOF()) while (!FileBuffer.isEOF())
{ %buffer = FileBuffer.readLine() @ "\n";
%buffer = FileBuffer.readLine() @ "\n"; FileBuffer.detach();
} return %buffer; //Long string. >.>
FileBuffer.detach();
return %buffer; //Long string. >.>
} }
function getLine(%file, %line) function getLine(%file, %line)
{ {
if (!IsFile(%file)) if (!IsFile(%file))
return "Not existant."; return "Not existant.";
new FileObject(FileLine); new FileObject(FileLine);
FileLine.openForRead(%file); FileLine.openForRead(%file);
for (%i = 0; %i < %line; %i++) for (%i = 0; %i < %line; %i++)
{ %line = FileLine.readLine();
%line = FileLine.readLine(); FileLine.detach();
} return %line;
FileLine.detach();
return %line;
} }
function getLine(%file, %line) function getLine(%file, %line)
{ {
if (!IsFile(%file)) if (!IsFile(%file))
return "Not existant."; return "Not existant.";
new FileObject(FileLine); new FileObject(FileLine);
FileLine.openForRead(%file); FileLine.openForRead(%file);
for (%i = 0; %i < %line; %i++) for (%i = 0; %i < %line; %i++)
{ %line = FileLine.readLine();
%line = FileLine.readLine(); FileLine.detach();
} return %line;
FileLine.detach();
return %line;
} }
// ----------------------------------------------------- // -----------------------------------------------------
@ -56,9 +50,9 @@ return %line;
// ----------------------------------------------------- // -----------------------------------------------------
function fileObject::Detach(%this) //Detaches fileObject from file & deletes function fileObject::Detach(%this) //Detaches fileObject from file & deletes
{ {
%this.close(); %this.close();
%this.delete(); %this.delete();
return %this; return %this;
} }

View file

@ -1,9 +1,10 @@
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
// initialise.cs
// Shared Functions for T2Bol // Shared Functions for T2Bol
// Copyright (c) 2012 The DarkDragonDX
//============================================================================== //==============================================================================
exec("scripts/modScripts/shared/stringProcessing.cs"); exec("scripts/modScripts/shared/stringProcessing.cs");
exec("scripts/modScripts/shared/fileProcessing.cs"); exec("scripts/modScripts/shared/fileProcessing.cs");
exec("scripts/modScripts/shared/numericProcessing.cs");
exec("scripts/modScripts/shared/basicDataStorage.cs"); exec("scripts/modScripts/shared/basicDataStorage.cs");

View file

@ -1,14 +0,0 @@
// -----------------------------------------------------
// Number Processing
// -----------------------------------------------------
function decimalToPercent(%decimal) //Doesn't work very nicely at the time.. probably won't be used after a bit
{
return %decimal * 100;
}
function isDecimal(%num)
{
return strStr(%num,".");
}

View file

@ -1,13 +1,19 @@
//------------------------------------------------------------------------------
// stringProcessing.cs
// String functions
// Copyright (c) 2012 The DarkDragonDX
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
function textToHash(%text) function textToHash(%text)
{ {
new fileObject(TextToHash); new fileObject(TextToHash);
TextToHash.openForWrite("Hash.txt"); TextToHash.openForWrite("Hash.txt");
TextToHash.writeLine(%text); TextToHash.writeLine(%text);
TextToHash.detach(); TextToHash.detach();
%hash = getFileCRC("Hash.txt"); %hash = getFileCRC("Hash.txt");
deleteFile("Hash.txt"); deleteFile("Hash.txt");
return %hash; return %hash;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -15,14 +21,11 @@ return %hash;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
function strReverse(%string) function strReverse(%string)
{ {
%len = StrLen(%string); %len = StrLen(%string);
%rstring = ""; %rstring = "";
for (%i = 0; %i < %len; %i++)
for (%i = 0; %i < %len; %i++) %rstring = getSubStr(%string,%i,1) @ %rstring;
{ return %rstring;
%rstring = getSubStr(%string,%i,1) @ %rstring;
}
return %rstring;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -30,11 +33,10 @@ return %rstring;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
function subStrInsert(%string,%insert,%slot) function subStrInsert(%string,%insert,%slot)
{ {
%seg = getSubStr(%string,0,%slot); %seg = getSubStr(%string,0,%slot);
%seg = %seg @ %insert; %seg = %seg @ %insert;
%string = %seg @ getSubStr(%string,%slot,strLen(%string)); %string = %seg @ getSubStr(%string,%slot,strLen(%string));
return %string;
return %string;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -42,9 +44,9 @@ return %string;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
function subStrRemove(%string,%slot)//Minimum: 1 function subStrRemove(%string,%slot)//Minimum: 1
{ {
%half2 = getSubStr(%string,%slot,strLen(%string)); %half2 = getSubStr(%string,%slot,strLen(%string));
%half1 = getSubStr(%string,0,%slot-1); %half1 = getSubStr(%string,0,%slot-1);
return %half1 @ %half2; return %half1 @ %half2;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -52,15 +54,13 @@ return %half1 @ %half2;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
function strMove(%string,%factor) function strMove(%string,%factor)
{ {
%len = GetWordCount(%string); %len = GetWordCount(%string);
for (%i = 0; %i < %len; %i++)
for (%i = 0; %i < %len; %i++) {
{ %sub = getWord(%string,%i);
%sub = getWord(%string,%i); %move = subStrInsert(%move,%sub,%i);
%move = subStrInsert(%move,%sub,%i); }
} return %move;
return %move;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -68,15 +68,13 @@ return %move;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
function subStrMove(%string,%factor) function subStrMove(%string,%factor)
{ {
%len = strLen(%string); %len = strLen(%string);
for (%i = 0; %i < %len; %i++)
for (%i = 0; %i < %len; %i++) {
{ %sub = getSubStr(%string,%i,1);
%sub = getSubStr(%string,%i,1); %move = subStrInsert(%move,%sub,%factor);
%move = subStrInsert(%move,%sub,%factor); }
} return %move;
return %move;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -84,25 +82,22 @@ return %move;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
function subStrScramble(%string) function subStrScramble(%string)
{ {
%len = strLen(%string); %len = strLen(%string);
for (%i = 0; %i < %len; %i++)
for (%i = 0; %i < %len; %i++) {
{ %sub = getSubStr(%string,%i,1);
%sub = getSubStr(%string,%i,1); %scramble = subStrInsert(%scramble,%sub,getRandom(0,%len));
%scramble = subStrInsert(%scramble,%sub,getRandom(0,%len)); }
} return %scramble;
return %scramble;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
function strSplit(%string) function strSplit(%string)
{ {
%count = strLen(%string); %count = strLen(%string);
%div = %count / 2; %div = %count / 2;
return getSubStr(%string,0,%div) @ " | " @ getSubStr(%string,%div,%count);
return getSubStr(%string,0,%div) @ " | " @ getSubStr(%string,%div,%count);
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -110,7 +105,7 @@ return getSubStr(%string,0,%div) @ " | " @ getSubStr(%string,%div,%count);
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
function stripSpaces(%string) function stripSpaces(%string)
{ {
return strReplace(%string," ",""); return strReplace(%string," ","");
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -118,8 +113,8 @@ return strReplace(%string," ","");
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
function stripNonNumericCharacters(%string) function stripNonNumericCharacters(%string)
{ {
%string = strLwr(%string); %string = strLwr(%string);
return stripChars(%string,"abcdefghijklmnopqrstuvwxyz`~!@#$%^&*()-_=+\|}]{[/?.>,<;:"); return stripChars(%string,"abcdefghijklmnopqrstuvwxyz`~!@#$%^&*()-_=+\|}]{[/?.>,<;:");
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -127,41 +122,39 @@ return stripChars(%string,"abcdefghijklmnopqrstuvwxyz`~!@#$%^&*()-_=+\|}]{[/?.>,
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
function getSubStrOccurance(%string,%search) function getSubStrOccurance(%string,%search)
{ {
%len = strLen(%string); %len = strLen(%string);
%srLen = strLen(%search); %srLen = strLen(%search);
%count = 0; %count = 0;
for (%i = 0; %i < %len; %i++) for (%i = 0; %i < %len; %i++)
{ {
%strSearch = strStr(%string,%search); %strSearch = strStr(%string,%search);
if (%strSearch != -1) //It exists somewhere in the string
if (%strSearch != -1) //It exists somewhere in the string {
{ %count++;
%count++; %string = getSubStr(%string,%strSearch+%srLen,%len);
%string = getSubStr(%string,%strSearch+%srLen,%len); }
} else
else return %count;
return %count; }
} return %count;
return %count;
} }
function getSubStrPos(%string,%str,%num) function getSubStrPos(%string,%str,%num)
{ {
%len = strLen(%string); %len = strLen(%string);
%subC = 0;
for (%i = 0; %i < %len; %i++)
{
%sub = getSubStr(%string,%i,1);
%subC = 0; if (%sub $= %str)
for (%i = 0; %i < %len; %i++) {
{ %subC++;
%sub = getSubStr(%string,%i,1); if (%subC == %num)
break;
if (%sub $= %str) }
{ }
%subC++; return %i;
if (%subC == %num)
break;
}
}
return %i;
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
@ -169,7 +162,7 @@ return %i;
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------
function getFileNameFromString(%string) function getFileNameFromString(%string)
{ {
return getSubStr(%string,getSubStrPos(%string,"/",getSubStrOccurance(%string, "/"))+1,strLen(%string)); return getSubStr(%string,getSubStrPos(%string,"/",getSubStrOccurance(%string, "/"))+1,strLen(%string));
} }
//------------------------------------------------------------------------------ //------------------------------------------------------------------------------