mirror of
https://github.com/Ragora/T2-BoL.git
synced 2026-04-29 16:55:03 +00:00
Did stuff.
This commit is contained in:
parent
09f43122e6
commit
8c96cba3e1
132 changed files with 56515 additions and 1448 deletions
627
scripts/NSGame.cs
Normal file
627
scripts/NSGame.cs
Normal file
|
|
@ -0,0 +1,627 @@
|
|||
// DisplayName = Natural Selection
|
||||
|
||||
//--- GAME RULES BEGIN ---
|
||||
// Destroy the other team.
|
||||
//--- GAME RULES END ---
|
||||
|
||||
//exec the AI scripts
|
||||
exec("scripts/aiNS.cs");
|
||||
|
||||
$RequiresClient[NS] = false;
|
||||
$InvBanList[NS, "C4Charge"] = 1;
|
||||
|
||||
//-- tracking ---
|
||||
function NSGame::initGameVars(%game)
|
||||
{
|
||||
//%game. = ""; //I guess I'll eventually set some, but most are loaded via BASIC files
|
||||
}
|
||||
|
||||
package NSGame
|
||||
{
|
||||
function blah(){} //Eh..
|
||||
};
|
||||
|
||||
function NSGame::setUpTeams(%game)
|
||||
{
|
||||
defaultGame::setUpTeams(%game);
|
||||
%game.numTeams = 1;
|
||||
setSensorGroupCount(4);
|
||||
$TeamDamage = true; //Allow team Damage
|
||||
}
|
||||
|
||||
function NSGame::getTeamSkin(%game, %team)
|
||||
{
|
||||
if($host::tournamentMode) // z0dd - ZOD, 9/29/02. Removed T2 demo code from here
|
||||
{
|
||||
return $teamSkin[%team];
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
//error("CTFGame::getTeamSkin");
|
||||
if(!$host::useCustomSkins)
|
||||
{
|
||||
%terrain = MissionGroup.musicTrack;
|
||||
//error("Terrain type is: " SPC %terrain);
|
||||
switch$(%terrain)
|
||||
{
|
||||
case "lush":
|
||||
if(%team == 1)
|
||||
%skin = 'beagle';
|
||||
else if(%team == 2)
|
||||
%skin = 'dsword';
|
||||
else %skin = 'base';
|
||||
|
||||
case "badlands":
|
||||
if(%team == 1)
|
||||
%skin = 'swolf';
|
||||
else if(%team == 2)
|
||||
%skin = 'dsword';
|
||||
else %skin = 'base';
|
||||
|
||||
case "ice":
|
||||
if(%team == 1)
|
||||
%skin = 'swolf';
|
||||
else if(%team == 2)
|
||||
%skin = 'beagle';
|
||||
else %skin = 'base';
|
||||
|
||||
case "desert":
|
||||
if(%team == 1)
|
||||
%skin = 'cotp';
|
||||
else if(%team == 2)
|
||||
%skin = 'beagle';
|
||||
else %skin = 'base';
|
||||
|
||||
case "Volcanic":
|
||||
if(%team == 1)
|
||||
%skin = 'dsword';
|
||||
else if(%team == 2)
|
||||
%skin = 'cotp';
|
||||
else %skin = 'base';
|
||||
|
||||
default:
|
||||
if(%team == 2)
|
||||
%skin = 'baseb';
|
||||
else %skin = 'base';
|
||||
}
|
||||
}
|
||||
else %skin = $teamSkin[%team];
|
||||
|
||||
//error("%skin = " SPC getTaggedString(%skin));
|
||||
return %skin;
|
||||
}
|
||||
}
|
||||
|
||||
function NSGame::getTeamName(%game, %team)
|
||||
{
|
||||
// ---------------------------------------------------
|
||||
// z0dd - ZOD 3/30/02. Only display default team names
|
||||
//if ( isDemo() || $host::tournamentMode)
|
||||
return $TeamName[%team];
|
||||
// ---------------------------------------------------
|
||||
}
|
||||
|
||||
//--------------------------------------------------------------------------
|
||||
function NSGame::missionLoadDone(%game)
|
||||
{
|
||||
//default version sets up teams - must be called first...
|
||||
DefaultGame::missionLoadDone(%game);
|
||||
}
|
||||
|
||||
function NSGame::showStalemateTargets(%game)
|
||||
{
|
||||
cancel(%game.stalemateSchedule);
|
||||
|
||||
//show the targets
|
||||
for (%i = 1; %i <= 2; %i++)
|
||||
{
|
||||
%flag = $TeamFlag[%i];
|
||||
|
||||
//find the object to scope/waypoint....
|
||||
//render the target hud icon for slot 1 (a centermass flag)
|
||||
//if we just set him as always sensor vis, it'll work fine.
|
||||
if (isObject(%flag.carrier))
|
||||
setTargetAlwaysVisMask(%flag.carrier.getTarget(), 0x7);
|
||||
}
|
||||
//schedule the targets to hide
|
||||
%game.stalemateObjsVisible = true;
|
||||
%game.stalemateSchedule = %game.schedule(%game.stalemateDurationMS, hideStalemateTargets);
|
||||
}
|
||||
|
||||
function NSGame::timeLimitReached(%game)
|
||||
{
|
||||
logEcho("game over (timelimit)");
|
||||
%game.gameOver();
|
||||
cycleMissions();
|
||||
}
|
||||
|
||||
function NSGame::scoreLimitReached(%game)
|
||||
{
|
||||
logEcho("game over (scorelimit)");
|
||||
%game.gameOver();
|
||||
cycleMissions();
|
||||
}
|
||||
|
||||
function NSGame::gameOver(%game)
|
||||
{
|
||||
//call the default
|
||||
DefaultGame::gameOver(%game);
|
||||
messageAll('MsgClearObjHud', "");
|
||||
}
|
||||
|
||||
function NSGame::onClientDamaged(%game, %clVictim, %clAttacker, %damageType, %implement, %damageLoc)
|
||||
{
|
||||
if(%clVictim.headshot && %damageType == $DamageType::Laser && %clVictim.team != %clAttacker.team)
|
||||
{
|
||||
%clAttacker.scoreHeadshot++;
|
||||
if (%game.SCORE_PER_HEADSHOT != 0)
|
||||
{
|
||||
messageClient(%clAttacker, 'msgHeadshot', '\c0You received a %1 point bonus for a successful headshot.', %game.SCORE_PER_HEADSHOT);
|
||||
messageTeamExcept(%clAttacker, 'msgHeadshot', '\c5%1 hit a sniper rifle headshot.', %clAttacker.name); // z0dd - ZOD, 8/15/02. Tell team
|
||||
}
|
||||
%game.recalcScore(%clAttacker);
|
||||
}
|
||||
|
||||
// -----------------------------------------------
|
||||
// z0dd - ZOD, 8/25/02. Rear Lance hits
|
||||
if(%clVictim.rearshot && %damageType == $DamageType::ShockLance && %clVictim.team != %clAttacker.team)
|
||||
{
|
||||
%clAttacker.scoreRearshot++;
|
||||
if (%game.SCORE_PER_REARSHOT != 0)
|
||||
{
|
||||
messageClient(%clAttacker, 'msgRearshot', '\c0You received a %1 point bonus for a successful rearshot.', %game.SCORE_PER_REARSHOT);
|
||||
messageTeamExcept(%clAttacker, 'msgRearshot', '\c5%1 hit a shocklance rearshot.', %clAttacker.name);
|
||||
}
|
||||
%game.recalcScore(%clAttacker);
|
||||
}
|
||||
// -----------------------------------------------
|
||||
|
||||
//the DefaultGame will set some vars
|
||||
DefaultGame::onClientDamaged(%game, %clVictim, %clAttacker, %damageType, %implement, %damageLoc);
|
||||
|
||||
//if victim is carrying a flag and is not on the attackers team, mark the attacker as a threat for x seconds(for scoring purposes)
|
||||
if ((%clVictim.holdingFlag !$= "") && (%clVictim.team != %clAttacker.team))
|
||||
{
|
||||
%clAttacker.dmgdFlagCarrier = true;
|
||||
cancel(%clAttacker.threatTimer); //restart timer
|
||||
%clAttacker.threatTimer = schedule(%game.TIME_CONSIDERED_FLAGCARRIER_THREAT, %clAttacker.dmgdFlagCarrier = false);
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////
|
||||
function NSGame::clientMissionDropReady(%game, %client)
|
||||
{
|
||||
messageClient(%client, 'MsgClientReady',"", "SinglePlayerGame"); //Force the SP game objective hud to setup
|
||||
%game.resetScore(%client);
|
||||
|
||||
messageClient(%client, 'MsgMissionDropInfo', '\c0You are in mission %1 (%2).', $MissionDisplayName, $MissionTypeDisplayName, $ServerName );
|
||||
|
||||
DefaultGame::clientMissionDropReady(%game, %client);
|
||||
|
||||
//Force client Spawn since we're ready now
|
||||
schedule(1000,0,"forceClientSpawn",%client,true);
|
||||
|
||||
%client.setControlObject(%client.player);
|
||||
commandToClient(%client,'bottomPrint',"Try not to die.",3);
|
||||
|
||||
//Since this is an RPG gamemode, be sure some things are correct. (May have been a mission switch from CTF or some other gamemode)
|
||||
commandToClient(%client,'SetScoreText',"PDA - Personal Data Assistant");
|
||||
//Make sure the data hud is working.
|
||||
messageClient(%client,'MsgSPCurrentObjective1',"",'Location: Unknown.');
|
||||
messageClient(%client,'MsgSPCurrentObjective2',"",'Money: $%1.',%client.money);
|
||||
}
|
||||
|
||||
function NSGame::assignClientTeam(%game, %client, %respawn)
|
||||
{
|
||||
DefaultGame::assignClientTeam(%game, %client, %respawn);
|
||||
// if player's team is not on top of objective hud, switch lines
|
||||
messageClient(%client, 'MsgCheckTeamLines', "", %client.team);
|
||||
}
|
||||
|
||||
function NSGame::applyConcussion(%game, %player)
|
||||
{
|
||||
}
|
||||
|
||||
function NSGame::vehicleDestroyed(%game, %vehicle, %destroyer)
|
||||
{
|
||||
}
|
||||
|
||||
function NSGame::onClientKilled(%game, %clVictim, %clKiller, %damageType, %implement, %damageLocation)
|
||||
{
|
||||
defaultGame::onClientKilled(%game, %clVictim, %clKiller, %damageType, %implement, %damageLocation);
|
||||
commandToClient(%clVictim,'HandleScriptedCommand',2);
|
||||
//commandToClient(%clVictim,'alxPlayMusic',"T2BOL/Music/TribesHymn.mp3"); //Add a little music that becomes audible if the player idles in death for a bit..
|
||||
//No, play this epic audio:
|
||||
schedule(2000,0,"messageClient",%clVictim,'MsgDeath',"~wfx/Lose.wav");
|
||||
forceScoreScreenOpen(%clVictim,"DEATH");
|
||||
$Data::ShouldApply[%clVictim.GUID] = false;
|
||||
|
||||
if (%clVictim.isAIControlled())
|
||||
%clVictim.drop();
|
||||
}
|
||||
|
||||
//...very very messy PDA code below!!
|
||||
|
||||
function NSGame::updateScoreHud(%game, %client, %tag) //This is just here for when the PDA is first opened.
|
||||
{
|
||||
if (%client.PDAPage $= "")
|
||||
{
|
||||
messageClient( %client, 'ClearHud', "", 'scoreScreen', 0 );
|
||||
|
||||
messageClient( %client, 'SetScoreHudHeader', "", '<just:center>Main Page');
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", "<just:center>Please select a command.");
|
||||
|
||||
%index = 0;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>Command List:");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\tSLFSTS\t1>-Self Statistics</a>");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\tEMAIL\t1>-Electronic Mail</a>");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\tINVENTORY\t1>-View Inventory</a>");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\tCLNMG\t1>-Clan Management</a>");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\tSAVE\t1>-Save Game</a>");
|
||||
|
||||
%client.PDAPage = "MAIN";
|
||||
}
|
||||
}
|
||||
function NSGame::createPlayer(%game, %client, %spawnLoc, %respawn)
|
||||
{
|
||||
DefaultGame::createPlayer(%game, %client, %spawnLoc, %respawn);
|
||||
commandToClient(%client,'HandleScriptedCommand',9,formatTimeString("HHnn") SPC "Hrs.");
|
||||
}
|
||||
|
||||
function NSGame::processGameLink(%game, %client, %arg1, %arg2, %arg3, %arg4, %arg5)
|
||||
{
|
||||
messageClient( %client, 'ClearHud', "", 'scoreScreen', 0 );
|
||||
|
||||
//Special handles here..
|
||||
if (getSubStr(%arg1,0,5) $= "EMAIL" && getSubStr(%arg1,5,1) !$= "" && isNumber(getSubStr(%arg1,5,1)))
|
||||
{
|
||||
%id = getSubStr(%arg1,5,strLen(%arg1));
|
||||
%client.email = %id;
|
||||
messageClient( %client, 'SetScoreHudHeader', "", '<just:center>Electronic Mail<just:right><a:gamelink\tCLOSE\t1>Close</a>');
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", "<just:left><a:gamelink\tDELETE\t1>Delete E-Mail</a> "@$Data::EMail::Date[%client.GUID,%i]@"<just:right><a:gamelink\tREPLY\t1>Reply</a>");
|
||||
%index = 0;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>From %1:',$Data::EMail::Sender[%client.GUID,%i]);
|
||||
%index++;
|
||||
%count = getSubStrOccurance($Data::EMail::Content[%client.GUID,%id],"\t");
|
||||
echo(%count);
|
||||
|
||||
if (%count != 0)
|
||||
for (%i = 0; %i < %count; %i++)
|
||||
{
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>%1',getField($Data::EMail::Contents[%client.GUID,%id],%i));
|
||||
%index++;
|
||||
}
|
||||
else
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>%1',$Data::EMail::Contents[%client.GUID,%id]);
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\tEMAIL\t1>Back To Listing</a>");
|
||||
return;
|
||||
}
|
||||
else if (getSubStr(%arg1,0,7) $= "EMAILID" && isNumber(getSubStr(%arg1,7,strLen(%arg1))))
|
||||
{
|
||||
%id = getSubStr(%arg1,7,strLen(%arg1));
|
||||
%guid = $Data::Client[%id];
|
||||
%count = $Data::EMail::Count[%guid];
|
||||
%name = $Data::ClientName[%id];
|
||||
%clid = plNameToCid(%name);
|
||||
if (checkEmails(%guid,%client.emailTitle))
|
||||
return;
|
||||
messageClient( %client, 'SetScoreHudHeader', "", '<just:center>Electronic Mail<just:right><a:gamelink\tCLOSE\t1>Close</a>');
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", '<just:center>E-Mail sent to %1.',%name);
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', 1, '<just:center><a:gamelink\tEMAIL\t1>Back to Listing</a>');
|
||||
$Data::EMail::Title[%guid,%count] = %client.emailTitle;
|
||||
$Data::EMail::Sender[%guid,%count] = %client.namebase;
|
||||
$Data::EMail::Contents[%guid,%count] = %client.emailCont;
|
||||
$Data::EMail::Date[%guid,%count] = formatTimeString("DD, MM dd, yy @ hh:nn A");
|
||||
$Data::EMail::Count[%guid]++;
|
||||
if (IsObject(%clid))
|
||||
messageClient(%clid,'msgClient','\c3Received an E-Mail from %1. ~wfx/misc/warning_beep.wav',%client.namebase);
|
||||
return;
|
||||
}
|
||||
|
||||
switch$ (%arg1)
|
||||
{
|
||||
case "CLOSE":
|
||||
closeScoreScreen(%client);
|
||||
case "BACK": //Resets you to the main menu
|
||||
messageClient( %client, 'SetScoreHudHeader', "", '<just:center>Main Page<just:right><a:gamelink\tCLOSE\t1>Close</a>');
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", "<just:center>Please select a command.");
|
||||
|
||||
%index = 0;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>Command List:");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\tSLFSTS\t1>-Self Statistics</a>");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\tEMAIL\t1>-Electronic Mail</a>");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\tINVENTORY\t1>-View Inventory</a>");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\tCLNMG\t1>-Clan Management</a>");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\tSAVE\t1>-Save Game</a>");
|
||||
|
||||
%client.PDAPage = "MAIN";
|
||||
|
||||
case "CLNSTP":
|
||||
messageClient( %client, 'SetScoreHudHeader', "", '<just:center>Clan Management<just:right><a:gamelink\tCLOSE\t1>Close</a>');
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", "<just:center>Showing clan setup.");
|
||||
%index = 0;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>Clan Name: %1 <a:input\tClanN\tClan Name\tClan Name>[Change]</a>',%client.clanN);
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>Clan Tag: %1 <a:input\tClanT\tClan Tag\tClan Tag>[Change]</a>',%client.clanT);
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>Short Description: %1 <a:input\tDesc\tShort Description\tDescription>[Change]</a>',%client.description);
|
||||
%index++;
|
||||
|
||||
if (%client.clanN !$= "" && %client.clanT !$= "")
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center><a:gamelink\tCLNFN>Done</a>');
|
||||
%index++;
|
||||
|
||||
%client.PDAPage = "CLNSTP";
|
||||
|
||||
case "EMAIL":
|
||||
messageClient( %client, 'SetScoreHudHeader', "", '<just:center>Electronic Mail<just:right><a:gamelink\tCLOSE\t1>Close</a>');
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", "<just:center>Showing E-Mails in sequential order.");
|
||||
|
||||
%index = 0;
|
||||
%count = $Data::EMail::Count[%client.GUID];
|
||||
for (%i = 0; %i <= %count; %i++)
|
||||
{
|
||||
if ($Data::EMail::Title[%client.GUID,%i] !$= "")
|
||||
{
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center><a:gamelink\tEMAIL%1\t1>%2 - %3</a>',%i,$Data::EMail::Sender[%client.GUID,%i],$Data::EMail::Title[%client.GUID,%i]);
|
||||
%index++;
|
||||
}
|
||||
}
|
||||
|
||||
if (%index == 0)
|
||||
{
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center>There are no E-Mails to show.");
|
||||
%index++;
|
||||
}
|
||||
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\tEMAILSEND\t1>[Compose an E-Mail]</a>");
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\tBACK\t1>Back To Main Menu</a>");
|
||||
%index++;
|
||||
|
||||
case "EMAILSEND":
|
||||
messageClient( %client, 'SetScoreHudHeader', "", '<just:center>Electronic Mail<just:right><a:gamelink\tCLOSE\t1>Close</a>');
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", "<just:center>New E-Mail");
|
||||
|
||||
%index = 0;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>Title: %1 <a:input\temailTitle\tTitle\tE-Mail Title>[Change]</a>',%client.emailTitle);
|
||||
%index++;
|
||||
|
||||
%count = getSubStrOccurance(%client.emailCont,"\t");
|
||||
|
||||
if (%count != 0)
|
||||
for (%i = 0; %i < %count; %i++)
|
||||
{
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>Contents: %1 <a:input\temailCont\tContents\tContents>[Change]</a>',%client.emailCont);
|
||||
}
|
||||
else
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>Contents: %1 <a:input\temailCont\tContents\tContents>[Change]</a>',%client.emailCont);
|
||||
%index++;
|
||||
if (%client.emailTitle !$= "" && %client.emailcont !$= "")
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center><a:gamelink\tRECPT>Select Receptiant</a>');
|
||||
|
||||
case "RECPT":
|
||||
messageClient( %client, 'SetScoreHudHeader', "", '<just:center>Electronic Mail<just:right><a:gamelink\tCLOSE\t1>Close</a>');
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", "<just:center>Select Receptiant");
|
||||
|
||||
%count = $Data::ClientCount;
|
||||
%index = 0;
|
||||
for (%i = 0; %i < %count; %i++)
|
||||
{
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center><a:gamelink\tEMAILID%1\t1>%2</a>',%i,$Data::ClientName[%i]);
|
||||
%index++;
|
||||
}
|
||||
|
||||
case "CLNFN":
|
||||
if ($Data::IsInClan[%client.GUID])
|
||||
{
|
||||
%ID = $Data::ClanID[%client.GUID];
|
||||
if ($Data::ClanLeaderGUID[%ID] == %client.GUID)
|
||||
{
|
||||
$Data::ClanName[%ID] = %client.clanN;
|
||||
$Data::ClanTag[%ID] = %client.clanT;
|
||||
$Data::ClanDesc[%ID] = %client.description;
|
||||
forceScoreScreenOpen(%client,"CLNMG");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
$Data::IsInCLan[%client.GUID] = true;
|
||||
|
||||
if ($Data::ClanCount $= "")
|
||||
$Data::ClanCount = 0;
|
||||
|
||||
$Data::ClanName[$Data::ClanCount] = %client.clanN;
|
||||
$Data::ClanTag[$Data::ClanCount] = %client.clanT;
|
||||
$Data::ClanDesc[$Data::ClanCount] = %client.desc;
|
||||
$Data::ClanLeader[$Data::ClanCount] = %client.namebase;
|
||||
$Data::ClanLeaderGUID[$Data::ClanCount] = %client.GUID;
|
||||
$Data::ClanMember[$Data::ClanCount, 0] = %client.GUID;
|
||||
$Data::ClanID[%client.GUID] = $Data::ClanCount;
|
||||
$Data::ClanCount++;
|
||||
setName(%client,"\cp\c7" @ %client.clanT @ "\c6" @ %client.namebase @ "\co");
|
||||
saveGame();
|
||||
forceScoreScreenOpen(%client,"CLNMG");
|
||||
}
|
||||
|
||||
%client.PDAPage = "MAIN";
|
||||
|
||||
case "CLNMG":
|
||||
messageClient( %client, 'SetScoreHudHeader', "", '<just:center>Clan Management<just:right><a:gamelink\tCLOSE\t1>Close</a>');
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", "<just:center>Showing clan management.");
|
||||
%index = 0;
|
||||
|
||||
if (!$Data::IsInClan[%client.GUID])
|
||||
{
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>You are not in a clan. Try creating a <a:gamelink\tCLNSTP>[New Clan]</a>.');
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>Or view the <a:gamelink\tCLNLST>[List]</a> of clans.');
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\tBACK\t1>Back To Main Menu</a>");
|
||||
}
|
||||
else
|
||||
{
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>Clan Name: %1',$Data::ClanName[$Data::ClanID[%client.GUID]]);
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>Clan Tag: %1', $Data::ClanTag[$Data::ClanID[%client.GUID]]);
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>Short Description: %1',%client.description);
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '');
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center><a:gamelink\tCLNMBR>[View]</a> member list.');
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center><a:gamelink\tCLNLST>[View]</a> other clans.');
|
||||
if ($Data::IsInClan[%client.GUID] && $Data::ClanLeaderGUID[$Data::ClanID[%client.GUID]] == %client.GUID)
|
||||
{
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center><a:gamelink\tCLNSTP>[Edit]</a> Clan.');
|
||||
}
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\tBACK\t1>Back To Main Menu</a>");
|
||||
}
|
||||
|
||||
%client.PDAPage = "CLNMG";
|
||||
|
||||
case "CLNMBR":
|
||||
%client.PDAPage = "CLNMBR";
|
||||
|
||||
messageClient( %client, 'SetScoreHudHeader', "", '<just:center>Clan Management<just:right><a:gamelink\tCLOSE\t1>Close</a>');
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", "<just:center>Showing member list.");
|
||||
%index = 0;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>Name: %1',%client.namebase);
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center><a:gamelink\tBACK\t1>Back To Previous Page</a>');
|
||||
%index++;
|
||||
|
||||
|
||||
case "SLFSTS": //Self Statistics
|
||||
messageClient( %client, 'SetScoreHudHeader', "", '<just:center>Self Statistics<just:right><a:gamelink\tCLOSE\t1>Close</a>');
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", "<just:center>Showing your stats.");
|
||||
%index = 0;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>Name: %1',%client.namebase);
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>Race: %1',%client.race);
|
||||
%index++;
|
||||
|
||||
if (%client.money $= "")
|
||||
%client.money = 0; //You got zilch.
|
||||
|
||||
%trans = %client.player.getTransform();
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>Cash: $%1',%client.money);
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>GPS Coordinates: %1 %2 %3',getWord(%trans,0),getWord(%trans,1),getWord(%trans,2));
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '');
|
||||
%index++;
|
||||
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center><a:gamelink\tSLFSTS\t1>Refresh</a>');
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\tBACK\t1>Back To Main Menu</a>");
|
||||
%client.PDAPage = "SLFSTS";
|
||||
|
||||
case "INVENTORY": //View Inventory
|
||||
messageClient( %client, 'SetScoreHudHeader', "", '<just:center>Show Inventory<just:right><a:gamelink\tCLOSE\t1>Close</a>');
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", "<just:center>Showing your inventory.");
|
||||
%index = 0;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, 'Minerals--');
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, 'Steel: %1 units.', %client.units["Steel"]);
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\tBACK\t1>Back To Main Menu</a>");
|
||||
%client.PDAPage = "INVENTORY";
|
||||
|
||||
case "DEATH":
|
||||
if (isObject(%client.player) && %client.player.getState() $= "Move")
|
||||
return;
|
||||
|
||||
messageClient( %client, 'SetScoreHudHeader', "", '<just:center>Death<just:right>');
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", "<just:center>You have died.");
|
||||
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', 0, "<just:center><a:gamelink\tRESPAWN\t1>Respawn</a>");
|
||||
%client.PDAPage = "DEATH";
|
||||
|
||||
case "DELETE":
|
||||
messageClient( %client, 'SetScoreHudHeader', "", '<just:center>Electronic Mail<just:right><a:gamelink\tCLOSE\t1>Close</a>');
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", "<just:center>E-Mail deleted.");
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', 0, '<just:center><a:gamelink\tEMAIL\t1>Back to Listing</a>');
|
||||
$Data::EMail::Title[%client.GUID,%client.email] = "";
|
||||
|
||||
case "SAVE":
|
||||
saveGame();
|
||||
closeScoreScreen(%client);
|
||||
messageClient(%client,'msgSaveSuccess',"\c3Game successfully saved.");
|
||||
|
||||
case "RESPAWN":
|
||||
if (isObject(%client.player) && %client.player.getState() $= "Move")
|
||||
return;
|
||||
|
||||
%client.PDAPage = "MAIN";
|
||||
forceClientSpawn(%client);
|
||||
|
||||
case "SLFSTS": //Self Statistics
|
||||
messageClient( %client, 'SetScoreHudHeader', "", '<just:center>Self Statistics<just:right><a:gamelink\tCLOSE\t1>Close</a>');
|
||||
messageClient( %client, 'SetScoreHudSubheader', "", "<just:center>Showing your stats.");
|
||||
%index = 0;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>Name: %1',%client.namebase);
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>Race: %1',%client.race);
|
||||
%index++;
|
||||
|
||||
if (%client.race $= "Draakan")
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>Type: %1',%client.sex);
|
||||
else
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>Sex: %1',%client.sex);
|
||||
%index++;
|
||||
|
||||
if (%client.money $= "")
|
||||
%client.money = 0; //You got zilch.
|
||||
|
||||
%trans = %client.player.getTransform();
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>Cash: $%1',%client.money);
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center>GPS Coordinates: %1 %2 %3',getWord(%trans,0),getWord(%trans,1),getWord(%trans,2));
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '');
|
||||
%index++;
|
||||
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, '<just:center><a:gamelink\tSLFSTS\t1>Refresh</a>');
|
||||
%index++;
|
||||
messageClient( %client, 'SetLineHud', "", 'scoreScreen', %index, "<just:center><a:gamelink\tBACK\t1>Back To Main Menu</a>");
|
||||
%client.PDAPage = "SLFSTS";
|
||||
|
||||
default: //If something fails, return to the main menu.
|
||||
serverCmdProcessGameLink(%client,"BACK");
|
||||
}
|
||||
}
|
||||
|
||||
function serverCmdShowHud(%client, %tag)
|
||||
{
|
||||
%tagName = getWord(%tag, 1);
|
||||
%tag = getWord(%tag, 0);
|
||||
|
||||
if (%tag $= 'scoreScreen')
|
||||
serverCmdProcessGameLink(%client,%client.PDAPage);
|
||||
|
||||
messageClient(%client, 'OpenHud', "", %tag);
|
||||
switch$ (%tagname)
|
||||
{
|
||||
case "vehicleHud":
|
||||
vehicleHud::updateHud(1,%client,%tag);
|
||||
case "scoreScreen":
|
||||
updateScoreHudThread(%client, %tag);
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load diff
|
|
@ -20,9 +20,9 @@ function TrainingGui::onWake( %this )
|
|||
TrainingMissionList.clear();
|
||||
|
||||
if ($Pref::Campaign !$= "")
|
||||
TrainingSelectMenu.onSelect(TrainingSelectMenu.findText($Pref::Campaign),$Pref::Campaign);
|
||||
TrainingSelectMenu.onSelect(TrainingSelectMenu.findText($Pref::Campaign),$Pref::Campaign);
|
||||
else
|
||||
TrainingSelectMenu.onSelect(0,TrainingSelectMenu.getText(0));
|
||||
TrainingSelectMenu.onSelect(0,TrainingSelectMenu.getText());
|
||||
TrainingMissionList.sort( 1 );
|
||||
TrainingMissionList.setSelectedRow( 0 );
|
||||
if ( $pref::TrainingDifficulty > 0 && $pref::TrainingDifficulty < 4 )
|
||||
|
|
@ -42,64 +42,53 @@ function TrainingGui::onSleep( %this )
|
|||
//------------------------------------------------------------------------------
|
||||
function TrainingGui::updateList( %this )
|
||||
{
|
||||
%cam = $Pref::Campaign;
|
||||
%dir = "Data/Campaigns/";
|
||||
%file = %dir @ %cam @ ".txt";
|
||||
%cam = $Pref::Campaign;
|
||||
%dir = "Data/Campaigns/";
|
||||
%file = %dir @ %cam @ ".txt";
|
||||
|
||||
if (!IsFile(%file))
|
||||
return false;
|
||||
if (!IsFile(%file))
|
||||
return false;
|
||||
|
||||
TrainingMissionList.clear();
|
||||
TrainingBriefingText.setValue( "" );
|
||||
TrainingPic.setBitmap( "" );
|
||||
TrainingPicFrame.setVisible( false );
|
||||
%count = getBlockData(%file,"Campaign",1,"MissionCount");
|
||||
TrainingMissionList.clear();
|
||||
TrainingBriefingText.setValue( "" );
|
||||
TrainingPic.setBitmap( "" );
|
||||
TrainingPicFrame.setVisible( false );
|
||||
|
||||
if (!IsObject(CampaignLoader))
|
||||
new ScriptObject(CampaignLoader) { class = "BasicDataParser"; };
|
||||
CampaignLoader.empty();
|
||||
CampaignLoader.load(%file);
|
||||
|
||||
%campaign = CampainLoader.get("Campaign",0);
|
||||
%count = %campaign.element("MissionCount");
|
||||
|
||||
//Before we do the loopy stuff, we should check if there's a specific training mission first
|
||||
%mission = getBlockData(%file,"Campaign",1,"Practice");
|
||||
%text = getBlockData(%file,"Campaign",1,"PracticeText");
|
||||
//Before we do the loopy stuff, we should check if there's a specific training mission first
|
||||
%mission = %campaign.element("Practice");
|
||||
%text = %campaign.element("PracticeText");
|
||||
|
||||
if (%text != -1 && %mission != -1)
|
||||
TrainingMissionList.addRow( 0, %text TAB %mission );
|
||||
if (%text != -1 && %mission != -1)
|
||||
TrainingMissionList.addRow( 0, %text TAB %mission );
|
||||
|
||||
for (%i = 1; %i <= %count; %i++)
|
||||
{
|
||||
%mission = getBlockData(%file,"Campaign",1,"Mission" @ %i);
|
||||
%text = getBlockData(%file,"Campaign",1,"MissionText" @ %i);
|
||||
TrainingMissionList.addRow( %i, %text TAB %mission );
|
||||
|
||||
//Now the mission list is where we need it, find the player settings..
|
||||
if (getBlockCount(%file,%mission) != 0)
|
||||
{
|
||||
$Training::Name[%Mission] = getBlockData(%file,%mission,1,"Name");
|
||||
$Training::Race[%Mission] = getBlockData(%file,%mission,1,"Race");
|
||||
$Training::Sex[%Mission] = getBlockData(%file,%mission,1,"Sex");
|
||||
$Training::Voice[%Mission] = getBlockData(%file,%mission,1,"Voice");
|
||||
$Training::VoicePitch[%Mission] = getBlockData(%file,%mission,1,"VoicePitch");
|
||||
$Training::Skin[%Mission] = getBlockData(%file,%mission,1,"Skin");
|
||||
$Training::EnemySkin[%Mission] = getBlockData(%file,%mission,1,"EnemySkin");
|
||||
$Training::EnemyName[%Mission] = getBlockData(%file,%mission,1,"EnemyName");
|
||||
$Training::EnemyTeam[%Mission] = getBlockData(%file,%mission,1,"EnemyTeam");
|
||||
$Training::PlayerTeam[%Mission] = getBlockData(%file,%mission,1,"PlayerTeam");
|
||||
$Training::StartLives[%Mission] = getBlockData(%file,%mission,1,"StartLives");
|
||||
$Training::EnemyRace[%Mission] = getBlockData(%file,%mission,1,"EnemyRace");
|
||||
}
|
||||
else
|
||||
{
|
||||
$Training::Name[%Mission] = getBlockData(%file,"Settings",1,"Name");
|
||||
$Training::Race[%Mission] = getBlockData(%file,"Settings",1,"Race");
|
||||
$Training::Sex[%Mission] = getBlockData(%file,"Settings",1,"Sex");
|
||||
$Training::Voice[%Mission] = getBlockData(%file,"Settings",1,"Voice");
|
||||
$Training::VoicePitch[%Mission] = getBlockData(%file,"Settings",1,"VoicePitch");
|
||||
$Training::Skin[%Mission] = getBlockData(%file,"Settings",1,"Skin");
|
||||
$Training::EnemySkin[%Mission] = getBlockData(%file,"Settings",1,"EnemySkin");
|
||||
$Training::EnemyName[%Mission] = getBlockData(%file,"Settings",1,"EnemyName");
|
||||
$Training::EnemyTeam[%Mission] = getBlockData(%file,"Settings",1,"EnemyTeam");
|
||||
$Training::PlayerTeam[%Mission] = getBlockData(%file,"Settings",1,"PlayerTeam");
|
||||
$Training::StartLives[%Mission] = getBlockData(%file,"Settings",1,"StartLives");
|
||||
$Training::EnemyRace[%Mission] = getBlockData(%file,"Settings",1,"EnemyRace");
|
||||
}
|
||||
}
|
||||
%settings = CampainLoader.get("Settings",0);
|
||||
for (%i = 1; %i <= %count; %i++)
|
||||
{
|
||||
%mission = %campain.element("Mission" @ %i);
|
||||
%text = %campaign.element("MissionText" @ %i);
|
||||
TrainingMissionList.addRow( %i, %text TAB %mission );
|
||||
//Now the mission list is where we need it, find the player settings..
|
||||
$Training::Name[%Mission] = %settings.element("Name");
|
||||
$Training::Race[%Mission] = %settings.element("Race");
|
||||
$Training::Sex[%Mission] = %settings.element("Sex");
|
||||
$Training::Voice[%Mission] = %settings.element("Voice");
|
||||
$Training::VoicePitch[%Mission] = %settings.element("VoicePitch");
|
||||
$Training::Skin[%Mission] = %settings.element("Skin");
|
||||
$Training::EnemySkin[%Mission] = %settings.element("EnemySkin");
|
||||
$Training::EnemyName[%Mission] = %settings.element("EnemyName");
|
||||
$Training::EnemyTeam[%Mission] = %settings.element("EnemyTeam");
|
||||
$Training::PlayerTeam[%Mission] = %settings.element("PlayerTeam");
|
||||
$Training::StartLives[%Mission] = %settings.element("StartLives");
|
||||
$Training::EnemyRace[%Mission] = %settings.element("EnemyRace");
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
@ -115,9 +104,9 @@ function TrainingGui::onClose( %this )
|
|||
//------------------------------------------------------------------------------
|
||||
function TrainingDifficultyMenu::onAdd( %this )
|
||||
{
|
||||
%this.add( "Easy", 1 );
|
||||
%this.add( "Medium", 2 );
|
||||
%this.add( "Hard", 3 );
|
||||
%this.add( "Easy", 1 );
|
||||
%this.add( "Medium", 2 );
|
||||
%this.add( "Hard", 3 );
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
@ -130,83 +119,88 @@ function TrainingDifficultyMenu::onSelect( %this, %id, %text )
|
|||
function TrainingSelectMenu::onAdd( %this )
|
||||
{
|
||||
|
||||
//Uber Dynamic Campaign Listing :)
|
||||
%path = "Data/Campaigns/*.txt";
|
||||
%count = 0;
|
||||
for( %file = findFirstFile( %path ); %file !$= ""; %file = findNextFile( %path ) )
|
||||
{
|
||||
%this.add( getBlockData(%file,"Campaign",1,"Name"), %count);
|
||||
%count++;
|
||||
}
|
||||
//Uber Dynamic Campaign Listing :)
|
||||
%path = "Data/Campaigns/*.dat";
|
||||
%count = 0;
|
||||
|
||||
if (!IsObject(CampaignLoader))
|
||||
new ScriptObject(CampaignLoader) { class = "BasicDataParser"; };
|
||||
CampaignLoader.empty();
|
||||
CampaignLoader.load(%file);
|
||||
|
||||
for( %file = findFirstFile( %path ); %file !$= ""; %file = findNextFile( %path ) )
|
||||
{
|
||||
CampaignLoader.load(%file);
|
||||
%this.add( CampaignLoader.get("Campaign",%count).element("Name"), %count);
|
||||
%count++;
|
||||
}
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function TrainingSelectMenu::onSelect( %this, %id, %text )
|
||||
{
|
||||
$Pref::Campaign = %text;
|
||||
$Pref::Campaign = %text;
|
||||
|
||||
%row = TrainingMissionList.getSelectedID() - 1;
|
||||
TrainingGui.updateList();
|
||||
TrainingGui.stopBriefing();
|
||||
TrainingSelectMenu.setText(%text); //Make sure our text is assigned..
|
||||
%row = TrainingMissionList.getSelectedID() - 1;
|
||||
TrainingGui.updateList();
|
||||
TrainingGui.stopBriefing();
|
||||
TrainingSelectMenu.setText(%text); //Make sure our text is assigned..
|
||||
|
||||
if ($Pref::Campaign $= %text)
|
||||
TrainingMissionList.setSelectedRow(%row);
|
||||
else
|
||||
TrainingMissionList.setSelectedRow(0);
|
||||
|
||||
if ($Pref::Campaign $= %text)
|
||||
TrainingMissionList.setSelectedRow(%row);
|
||||
else
|
||||
TrainingMissionList.setSelectedRow(0);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function TrainingMissionList::onSelect( %this, %id, %text )
|
||||
{
|
||||
TrainingGui.stopBriefing();
|
||||
%fileName = "missions/" @ getField( %text, 1 ) @ ".mis";
|
||||
%file = new FileObject();
|
||||
%state = 0;
|
||||
if ( %file.openForRead( %fileName ) )
|
||||
{
|
||||
%fileName = "missions/" @ getField( %text, 1 ) @ ".mis";
|
||||
%file = new FileObject();
|
||||
%state = 0;
|
||||
if ( %file.openForRead( %fileName ) )
|
||||
{
|
||||
// Get the mission briefing text:
|
||||
while ( !%file.isEOF() )
|
||||
{
|
||||
%line = %file.readLine();
|
||||
if ( %state == 0 && %line $= "//--- MISSION BRIEFING BEGIN ---" )
|
||||
%state = 1;
|
||||
else if ( %state > 0 && %line $= "//--- MISSION BRIEFING END ---" )
|
||||
break;
|
||||
else if ( %state == 1 )
|
||||
while ( !%file.isEOF() )
|
||||
{
|
||||
%line = %file.readLine();
|
||||
if ( %state == 0 && %line $= "//--- MISSION BRIEFING BEGIN ---" )
|
||||
%state = 1;
|
||||
else if ( %state > 0 && %line $= "//--- MISSION BRIEFING END ---" )
|
||||
break;
|
||||
else if ( %state == 1 )
|
||||
{
|
||||
%briefText = %briefText @ getSubStr( %line, 2, 1000 );
|
||||
%briefText = %briefText @ getSubStr( %line, 2, 1000 );
|
||||
%state = 2;
|
||||
}
|
||||
else if ( %state == 2 )
|
||||
%briefText = %briefText NL getSubStr( %line, 2, 1000 );
|
||||
}
|
||||
else if ( %state == 2 )
|
||||
%briefText = %briefText NL getSubStr( %line, 2, 1000 );
|
||||
}
|
||||
|
||||
// Get the mission briefing WAV file:
|
||||
while ( !%file.isEOF() )
|
||||
{
|
||||
%line = %file.readLine();
|
||||
%line = %file.readLine();
|
||||
if ( getSubStr( %line, 0, 17 ) $= "// BriefingWAV = " )
|
||||
{
|
||||
{
|
||||
%briefWAV = getSubStr( %line, 17, 1000 );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the bitmap name:
|
||||
while ( !%file.isEOF() )
|
||||
{
|
||||
%line = %file.readLine();
|
||||
%line = %file.readLine();
|
||||
if ( getSubStr( %line, 0, 12 ) $= "// Bitmap = " )
|
||||
{
|
||||
{
|
||||
%briefPic = getSubStr( %line, 12, 1000 );
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
%file.close();
|
||||
}
|
||||
}
|
||||
else
|
||||
error( "Failed to open Single Player mission file " @ %fileName @ "!" );
|
||||
|
||||
|
|
@ -227,14 +221,12 @@ function TrainingMissionList::onSelect( %this, %id, %text )
|
|||
}
|
||||
|
||||
TrainingPlayBtn.setActive( %briefWAV !$= "" );
|
||||
TrainingBriefingText.setValue( %briefText );
|
||||
TrainingBriefingText.setValue( %briefText );
|
||||
TrainingBriefingScroll.scrollToTop();
|
||||
TrainingGui.WAVBase = firstWord( %briefWAV );
|
||||
TrainingGui.WAVCount = restWords( %briefWAV );
|
||||
%file.delete();
|
||||
|
||||
//if ( TrainingPlayTgl.getValue() )
|
||||
// TrainingGui.startBriefing();
|
||||
%file.delete();
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -472,8 +472,10 @@ function AIConnection::onAIConnect(%client, %name, %team, %skill, %offense, %voi
|
|||
|
||||
echo(%client.name);
|
||||
echo("CADD: " @ %client @ " " @ %client.getAddress());
|
||||
if ($CurrentMissionType !$= "RPG") //If it's RPG, don't increment the count
|
||||
$HostGamePlayerCount++;
|
||||
|
||||
// DDDX: Don't increment player count in RPG/Survival Games
|
||||
if ($CurrentMissionType !$= "RPG" && $CurrentMissionType !$= "SV")
|
||||
$HostGamePlayerCount++;
|
||||
|
||||
//set the initial team - Game.assignClientTeam() should be called later on...
|
||||
%client.team = %team;
|
||||
|
|
@ -908,5 +910,3 @@ function AIPilotVehicle(%client)
|
|||
{
|
||||
//this is not very well supported, but someone will find a use for this function...
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -16,11 +16,13 @@ function aiConnectByIndex(%index, %team)
|
|||
if ($BotProfile[%index, Voice] $= "")
|
||||
$BotProfile[%index, Voice] = "Bot1";
|
||||
|
||||
%skin[0] = 'BaseBot';
|
||||
%skin[1] = 'BaseBBot';
|
||||
%skin[0] = "BaseBot";
|
||||
%skin[1] = "BaseBBot";
|
||||
|
||||
if ($BotProfile[%index, Skin] $= '')
|
||||
$BotProfile[%index, Skin] = %skin[getRandom(0,1)];
|
||||
$BotProfile[%index, Skin] = addTaggedString($BotProfile[%index, Skin]);
|
||||
//$BotProfile[%index, Voice] = addTaggedString($BotProfile[%index, Voice]);
|
||||
|
||||
%client = aiConnect($BotProfile[%index, name], %team, $BotProfile[%index, skill], $BotProfile[%index, offense], $BotProfile[%index, voice], $BotProfile[%index, voicePitch]);
|
||||
%client.skin = $BotProfile[%index, skin];
|
||||
|
|
@ -251,304 +253,27 @@ function aiConnectMultiple(%numToConnect, %minSkill, %maxSkill, %team)
|
|||
}
|
||||
}
|
||||
|
||||
//Notes:
|
||||
//Ai Bot profiles: Balance out difficulties and settings.
|
||||
//Draakans and Derms make up most of the AI list
|
||||
//Human
|
||||
$BotProfile[0, name] = "Dalaila Hayes";
|
||||
$BotProfile[0, skill] = 0.95;
|
||||
$BotProfile[0, offense] = true;
|
||||
$BotProfile[0, voicePitch] = 0.875;
|
||||
$BotProfile[0, race] = "Human";
|
||||
$BotProfile[0, skin] = 'Swolf';
|
||||
$BotProfile[0, voice] = "Fem3";
|
||||
$BotProfile[0, sex] = "Female";
|
||||
|
||||
$BotProfile[1, name] = "Cynthia Fisher";
|
||||
$BotProfile[1, skill] = 0.95;
|
||||
$BotProfile[1, offense] = true;
|
||||
$BotProfile[1, voicePitch] = 0.875;
|
||||
$BotProfile[1, race] = "Human";
|
||||
$BotProfile[1, skin] = "Swolf";
|
||||
$BotProfile[1, voice] = "Fem3";
|
||||
$BotProfile[1, sex] = "Female";
|
||||
|
||||
$BotProfile[2, name] = "Commander Jackson";
|
||||
$BotProfile[2, skill] = 0.95;
|
||||
$BotProfile[2, offense] = true;
|
||||
$BotProfile[2, voicePitch] = 0.875;
|
||||
$BotProfile[2, race] = "Human";
|
||||
$BotProfile[2, skin] = 'Beagle';
|
||||
$BotProfile[2, voice] = "Male5";
|
||||
$BotProfile[2, sex] = "Male";
|
||||
|
||||
$BotProfile[3, name] = "Corperal Jones";
|
||||
$BotProfile[3, skill] = 0.95;
|
||||
$BotProfile[3, offense] = true;
|
||||
$BotProfile[3, voicePitch] = 0.875;
|
||||
$BotProfile[3, race] = "Human";
|
||||
$BotProfile[3, skin] = 'Beagle';
|
||||
$BotProfile[3, voice] = "Male5";
|
||||
$BotProfile[3, sex] = "Male";
|
||||
|
||||
//BioDerm
|
||||
$BotProfile[4, name] = "Beast";
|
||||
$BotProfile[4, skill] = 0.95;
|
||||
$BotProfile[4, offense] = true;
|
||||
$BotProfile[4, voicePitch] = 0.875;
|
||||
$BotProfile[4, race] = "Bioderm";
|
||||
$BotProfile[4, skin] = 'Horde';
|
||||
$BotProfile[4, voice] = "Derm3";
|
||||
$BotProfile[4, sex] = "Male";
|
||||
|
||||
$BotProfile[5, name] = "Retch";
|
||||
$BotProfile[5, skill] = 0.78;
|
||||
$BotProfile[5, offense] = false;
|
||||
$BotProfile[5, voicePitch] = 0.789;
|
||||
$BotProfile[5, race] = "Bioderm";
|
||||
$BotProfile[5, skin] = 'Horde';
|
||||
$BotProfile[5, voice] = "Derm2";
|
||||
|
||||
$BotProfile[6, name] = "Hagstomper";
|
||||
$BotProfile[6, skill] = 0.78;
|
||||
$BotProfile[6, offense] = false;
|
||||
$BotProfile[6, voicePitch] = 0.789;
|
||||
$BotProfile[6, race] = "Bioderm";
|
||||
$BotProfile[6, skin] = 'Horde';
|
||||
$BotProfile[6, voice] = "Derm2";
|
||||
|
||||
$BotProfile[6, name] = "Doormat";
|
||||
$BotProfile[6, skill] = 0.78;
|
||||
$BotProfile[6, offense] = false;
|
||||
$BotProfile[6, voicePitch] = 0.789;
|
||||
$BotProfile[6, race] = "Bioderm";
|
||||
$BotProfile[6, skin] = 'Horde';
|
||||
$BotProfile[6, voice] = "Derm2";
|
||||
|
||||
$BotProfile[7, name] = "Evenkill";
|
||||
$BotProfile[7, skill] = 0.78;
|
||||
$BotProfile[7, offense] = false;
|
||||
$BotProfile[7, voicePitch] = 0.789;
|
||||
$BotProfile[7, race] = "Bioderm";
|
||||
$BotProfile[7, skin] = 'Horde';
|
||||
$BotProfile[7, voice] = "Derm2";
|
||||
|
||||
$BotProfile[8, name] = "Heart Eater";
|
||||
$BotProfile[8, skill] = 0.78;
|
||||
$BotProfile[8, offense] = false;
|
||||
$BotProfile[8, voicePitch] = 0.789;
|
||||
$BotProfile[8, race] = "Bioderm";
|
||||
$BotProfile[8, skin] = 'Horde';
|
||||
$BotProfile[8, voice] = "Derm2";
|
||||
|
||||
$BotProfile[9, name] = "Torox the Backbreaker";
|
||||
$BotProfile[9, skill] = 0.78;
|
||||
$BotProfile[9, offense] = false;
|
||||
$BotProfile[9, voicePitch] = 0.789;
|
||||
$BotProfile[9, race] = "Bioderm";
|
||||
$BotProfile[9, skin] = 'Horde';
|
||||
$BotProfile[9, voice] = "Derm2";
|
||||
|
||||
$BotProfile[10, name] = "Face Breaker";
|
||||
$BotProfile[10, skill] = 0.78;
|
||||
$BotProfile[10, offense] = false;
|
||||
$BotProfile[10, voicePitch] = 0.789;
|
||||
$BotProfile[10, race] = "Bioderm";
|
||||
$BotProfile[10, skin] = 'Horde';
|
||||
$BotProfile[10, voice] = "Derm2";
|
||||
|
||||
$BotProfile[11, name] = "Monkey Bones";
|
||||
$BotProfile[11, skill] = 0.78;
|
||||
$BotProfile[11, offense] = false;
|
||||
$BotProfile[11, voicePitch] = 0.789;
|
||||
$BotProfile[11, race] = "Bioderm";
|
||||
$BotProfile[11, skin] = 'Horde';
|
||||
$BotProfile[11, voice] = "Derm2";
|
||||
|
||||
$BotProfile[12, name] = "Breath of Fear";
|
||||
$BotProfile[12, skill] = 0.78;
|
||||
$BotProfile[12, offense] = false;
|
||||
$BotProfile[12, voicePitch] = 0.789;
|
||||
$BotProfile[12, race] = "Bioderm";
|
||||
$BotProfile[12, skin] = 'Horde';
|
||||
$BotProfile[12, voice] = "Derm2";
|
||||
|
||||
$BotProfile[13, name] = "Devours-All";
|
||||
$BotProfile[13, skill] = 0.78;
|
||||
$BotProfile[13, offense] = false;
|
||||
$BotProfile[13, voicePitch] = 0.789;
|
||||
$BotProfile[13, race] = "Bioderm";
|
||||
$BotProfile[13, skin] = 'Horde';
|
||||
$BotProfile[13, voice] = "Derm2";
|
||||
|
||||
$BotProfile[14, name] = "Skullcrusher";
|
||||
$BotProfile[14, skill] = 0.78;
|
||||
$BotProfile[14, offense] = false;
|
||||
$BotProfile[15, voicePitch] = 0.789;
|
||||
$BotProfile[16, race] = "Bioderm";
|
||||
$BotProfile[17, skin] = 'Horde';
|
||||
$BotProfile[18, voice] = "Derm2";
|
||||
|
||||
//Draakan (Eh.. their real names use the derms' from SPDialog.cs) -- Most have their own backStory, but some are just here to take up room
|
||||
//My personal picks: Dolosus (duh?), Sharp Tooth, and Iguana
|
||||
$BotProfile[19, name] = "Dolosus"; //Dolosus Irokhirr Zhor
|
||||
$BotProfile[19, skill] = 0.95;
|
||||
$BotProfile[19, offense] = true;
|
||||
$BotProfile[19, voicePitch] = 0.875;
|
||||
$BotProfile[19, race] = "Draakan";
|
||||
$BotProfile[19, skin] = 'Gecko';
|
||||
$BotProfile[19, voice] = "Derm3";
|
||||
$BotProfile[19, sex] = "A";
|
||||
|
||||
$BotProfile[20, name] = "Rex"; //#367378 (Genetic failure)
|
||||
$BotProfile[20, skill] = 0.89;
|
||||
$BotProfile[20, offense] = true;
|
||||
$BotProfile[20, voicePitch] = 0.781;
|
||||
$BotProfile[20, race] = "Draakan";
|
||||
$BotProfile[20, skin] = 'Gecko';
|
||||
$BotProfile[20, voice] = "Derm2";
|
||||
$BotProfile[20, sex] = "A";
|
||||
|
||||
$BotProfile[21, name] = "Raptor"; //Hrreshig "Raptor" Kolkhris
|
||||
$BotProfile[21, skill] = 0.88;
|
||||
$BotProfile[21, offense] = true;
|
||||
$BotProfile[21, voicePitch] = 0.972;
|
||||
$BotProfile[21, race] = "Draakan";
|
||||
$BotProfile[21, skin] = 'Gecko';
|
||||
$BotProfile[21, voice] = "Derm2";
|
||||
$BotProfile[21, sex] = "A";
|
||||
|
||||
$BotProfile[22, name] = "Iguana"; //Marakh "Iguana" Azarok
|
||||
$BotProfile[22, skill] = 0.45;
|
||||
$BotProfile[22, offense] = false;
|
||||
$BotProfile[22, voicePitch] = 0.673;
|
||||
$BotProfile[22, race] = "Draakan";
|
||||
$BotProfile[22, skin] = 'Gecko';
|
||||
$BotProfile[22, voice] = "Derm1";
|
||||
$BotProfile[22, sex] = "A";
|
||||
|
||||
$BotProfile[23, name] = "Sharp Tooth"; //Murkhofud "Sharp Tooth" Khel
|
||||
$BotProfile[23, skill] = 0.89;
|
||||
$BotProfile[23, offense] = true;
|
||||
$BotProfile[23, voicePitch] = 0.875;
|
||||
$BotProfile[23, race] = "Draakan";
|
||||
$BotProfile[23, skin] = 'Gecko';
|
||||
$BotProfile[23, voice] = "Derm1";
|
||||
$BotProfile[23, sex] = "A";
|
||||
|
||||
$BotProfile[24, name] = "Snake"; //Morax "Snake" Serexhar
|
||||
$BotProfile[24, skill] = 0.78;
|
||||
$BotProfile[24, offense] = false;
|
||||
$BotProfile[24, voicePitch] = 1;
|
||||
$BotProfile[24, race] = "Draakan";
|
||||
$BotProfile[24, skin] = 'Gecko';
|
||||
$BotProfile[24, voice] = "Derm2";
|
||||
$BotProfile[24, sex] = "A";
|
||||
|
||||
$BotProfile[25, name] = "Gila"; //Gorog "Gila" Jok
|
||||
$BotProfile[25, skill] = 0.80;
|
||||
$BotProfile[25, offense] = true;
|
||||
$BotProfile[25, voicePitch] = 0.578;
|
||||
$BotProfile[25, race] = "Draakan";
|
||||
$BotProfile[25, skin] = 'Gecko';
|
||||
$BotProfile[25, voice] = "Derm1";
|
||||
$BotProfile[25, sex] = "B";
|
||||
|
||||
$BotProfile[26, name] = "Cobra"; //Karghaz "Cobra" Tumoz
|
||||
$BotProfile[26, skill] = 0.80;
|
||||
$BotProfile[26, offense] = true;
|
||||
$BotProfile[26, voicePitch] = 0.578;
|
||||
$BotProfile[26, race] = "Draakan";
|
||||
$BotProfile[26, skin] = 'Gecko';
|
||||
$BotProfile[26, voice] = "Derm1";
|
||||
$BotProfile[26, sex] = "C";
|
||||
|
||||
$BotProfile[27, name] = "Viper"; //Malevolox "Viper" Zon
|
||||
$BotProfile[27, skill] = 0.80;
|
||||
$BotProfile[27, offense] = true;
|
||||
$BotProfile[27, voicePitch] = 0.578;
|
||||
$BotProfile[27, race] = "Draakan";
|
||||
$BotProfile[27, skin] = 'Gecko';
|
||||
$BotProfile[27, voice] = "Derm1";
|
||||
$BotProfile[27, sex] = "A";
|
||||
|
||||
$BotProfile[27, name] = "Komodo Dragon";
|
||||
$BotProfile[27, skill] = 0.80;
|
||||
$BotProfile[27, offense] = true;
|
||||
$BotProfile[27, voicePitch] = 0.578;
|
||||
$BotProfile[27, race] = "Draakan";
|
||||
$BotProfile[27, skin] = 'Gecko';
|
||||
$BotProfile[27, voice] = "Derm1";
|
||||
$BotProfile[27, sex] = "C";
|
||||
|
||||
$BotProfile[27, name] = "Red Dragon";
|
||||
$BotProfile[27, skill] = 0.78;
|
||||
$BotProfile[27, offense] = false;
|
||||
$BotProfile[27, voicePitch] = 0.789;
|
||||
$BotProfile[27, race] = "Draakan";
|
||||
$BotProfile[27, skin] = 'Gecko';
|
||||
$BotProfile[27, voice] = "Derm2";
|
||||
$BotProfile[27, sex] = "A";
|
||||
|
||||
$BotProfile[29, name] = "Torus";
|
||||
$BotProfile[29, skill] = 0.78;
|
||||
$BotProfile[29, offense] = false;
|
||||
$BotProfile[29, voicePitch] = 0.789;
|
||||
$BotProfile[29, race] = "Draakan";
|
||||
$BotProfile[29, skin] = 'Gecko';
|
||||
$BotProfile[29, voice] = "Derm2";
|
||||
$BotProfile[29, sex] = "A";
|
||||
|
||||
$BotProfile[30, name] = "Slicer";
|
||||
$BotProfile[30, skill] = 0.78;
|
||||
$BotProfile[30, offense] = false;
|
||||
$BotProfile[30, voicePitch] = 0.789;
|
||||
$BotProfile[30, race] = "Draakan";
|
||||
$BotProfile[30, skin] = 'Gecko';
|
||||
$BotProfile[30, voice] = "Derm3";
|
||||
$BotProfile[30, sex] = "C";
|
||||
|
||||
$BotProfile[31, name] = "Achilles";
|
||||
$BotProfile[31, skill] = 0.78;
|
||||
$BotProfile[31, offense] = false;
|
||||
$BotProfile[31, voicePitch] = 0.789;
|
||||
$BotProfile[31, race] = "Criollos";
|
||||
$BotProfile[31, skin] = 'HALO_SKIN';
|
||||
$BotProfile[31, voice] = "Derm2";
|
||||
|
||||
$BotProfile[32, name] = "King Snake";
|
||||
$BotProfile[32, skill] = 0.78;
|
||||
$BotProfile[32, offense] = false;
|
||||
$BotProfile[32, voicePitch] = 0.789;
|
||||
$BotProfile[32, race] = "Draakan";
|
||||
$BotProfile[32, skin] = 'Gecko';
|
||||
$BotProfile[32, voice] = "Derm2";
|
||||
$BotProfile[32, sex] = "A";
|
||||
|
||||
$BotProfile[33, name] = "Troglodyte";
|
||||
$BotProfile[33, skill] = 0.78;
|
||||
$BotProfile[33, offense] = false;
|
||||
$BotProfile[33, voicePitch] = 0.789;
|
||||
$BotProfile[33, race] = "Draakan";
|
||||
$BotProfile[33, skin] = 'Gecko';
|
||||
$BotProfile[33, voice] = "Derm2";
|
||||
$BotProfile[33, sex] = "A";
|
||||
|
||||
//Criollos (Wow.. only two of them)
|
||||
$BotProfile[34, name] = "Alchaldes";
|
||||
$BotProfile[34, skill] = 0.78;
|
||||
$BotProfile[34, offense] = false;
|
||||
$BotProfile[34, voicePitch] = 0.789;
|
||||
$BotProfile[34, race] = "Criollos";
|
||||
$BotProfile[34, skin] = 'HALO_SKIN';
|
||||
$BotProfile[34, voice] = "Derm2";
|
||||
|
||||
$BotProfile[35, name] = "Hammurabi";
|
||||
$BotProfile[35, skill] = 0.78;
|
||||
$BotProfile[35, offense] = false;
|
||||
$BotProfile[35, voicePitch] = 0.789;
|
||||
$BotProfile[35, race] = "Criollos";
|
||||
$BotProfile[35, skin] = 'HALO_SKIN';
|
||||
$BotProfile[35, voice] = "Derm2";
|
||||
|
||||
$BotProfile::Count = 35;
|
||||
function aiReloadProfiles()
|
||||
{
|
||||
if (!IsObject(BotProfiles))
|
||||
new ScriptObject(BotProfiles) { class = "BasicDataParser"; };
|
||||
BotProfiles.empty();
|
||||
BotProfiles.load("prefs/Bot Profiles.conf");
|
||||
%count = BotProfiles.count("Bot");
|
||||
for (%i = 0; %i < %count; %i++)
|
||||
{
|
||||
%Entry = BotProfiles.get("Bot",%i);
|
||||
$BotProfile[%i, name] = %Entry.element("Name");
|
||||
$BotProfile[%i, skill] = %Entry.element("skill");
|
||||
$BotProfile[%i, offense] = %Entry.element("offense");
|
||||
$BotProfile[%i, voicePitch] = %Entry.element("voicePitch");
|
||||
$BotProfile[%i, race] = %Entry.element("race");
|
||||
$BotProfile[%i, skin] = %Entry.element("skin");
|
||||
$BotProfile[%i, voice] = %Entry.element("voice");
|
||||
$BotProfile[%i, sex] = %Entry.element("sex");
|
||||
}
|
||||
$BotProfile::Count = %count;
|
||||
warn("scripts/aiBotProfiles.cs: Loaded" SPC %count SPC "bot profiles.");
|
||||
return true;
|
||||
}
|
||||
aiReloadProfiles();
|
||||
26
scripts/aiNS.cs
Normal file
26
scripts/aiNS.cs
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
function BOLGame::AIInit(%game)
|
||||
{
|
||||
//call the default AIInit() function
|
||||
AIInit();
|
||||
}
|
||||
|
||||
function BOLGame::onAIRespawn(%game, %client)
|
||||
{
|
||||
//add the default task
|
||||
if (! %client.defaultTasksAdded)
|
||||
{
|
||||
%client.defaultTasksAdded = true;
|
||||
%client.addTask(AIEngageTask);
|
||||
%client.addTask(AIPickupItemTask);
|
||||
// %client.addTask(AIUseInventoryTask); They spawn with the stuff they need
|
||||
%client.addTask(AITauntCorpseTask);
|
||||
%client.addTask(AIEngageTurretTask);
|
||||
%client.addtask(AIDetectMineTask);
|
||||
// %client.addTask(AIPatrolTask); They don't move unless told to
|
||||
}
|
||||
|
||||
//set the inv flag
|
||||
%client.spawnUseInv = true;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -338,9 +338,11 @@ function AIUnassignClient(%client)
|
|||
%client.objective.clientLevel[%client.objectiveLevel] = "";
|
||||
}
|
||||
}
|
||||
%client.objective.unassignClient(%client);
|
||||
%client.objective = "";
|
||||
%client.objectiveWeight = 0;
|
||||
// DDDX: Fixes some console spamming is all
|
||||
if (isObject(%client.objective))
|
||||
%client.objective.unassignClient(%client);
|
||||
%client.objective = "";
|
||||
%client.objectiveWeight = 0;
|
||||
}
|
||||
|
||||
//debuging - refresh aidebugq() if required
|
||||
|
|
|
|||
|
|
@ -1,50 +1,44 @@
|
|||
// --------------------------------------------------------
|
||||
// aiSurvival.cs
|
||||
// AI scripts for bots in the Survival gamemode
|
||||
// Copyright (c) 2012 The DarkDragonDX
|
||||
// ========================================================
|
||||
|
||||
function SVGame::AIInit(%game)
|
||||
{
|
||||
//call the default AIInit() function
|
||||
AIInit();
|
||||
//call the default AIInit() function
|
||||
AIInit();
|
||||
return true;
|
||||
}
|
||||
|
||||
function SVGame::onAIRespawn(%game, %client)
|
||||
{
|
||||
//add the default task
|
||||
//add the default task
|
||||
if (! %client.defaultTasksAdded)
|
||||
{
|
||||
%client.defaultTasksAdded = true;
|
||||
%client.addTask(AIEngageTask);
|
||||
%client.addTask(AIPickupItemTask);
|
||||
%client.addTask(AITauntCorpseTask);
|
||||
%client.addTask(AIEngageTask);
|
||||
%client.addTask(AIPickupItemTask);
|
||||
// %client.addTask(AITauntCorpseTask);
|
||||
%client.addTask(AIEngageTurretTask);
|
||||
%client.addtask(AIDetectMineTask);
|
||||
%client.addTask(AIPatrolTask);
|
||||
// %client.addtask(AIDetectMineTask);
|
||||
%client.addTask(AIPatrolTask);
|
||||
}
|
||||
%client.setSkillLevel(99);
|
||||
%client.hide();
|
||||
%client.hideClientInList();
|
||||
|
||||
//Now, force the bot to choose a player
|
||||
%count = clientGroup.getCount();
|
||||
%rnd = getRandom(0,%count);
|
||||
%rndcl = clientGroup.getObject(%rnd);
|
||||
|
||||
%newObjective = new AIObjective(AIOAttackPlayer)
|
||||
{
|
||||
dataBlock = "AIObjectiveMarker";
|
||||
weightLevel1 = 10000;
|
||||
description = "Attack Player";
|
||||
targetClient = %rndcl;
|
||||
offense = true;
|
||||
};
|
||||
//echo(%newObjective);
|
||||
MissionCleanup.add(%newObjective);
|
||||
$ObjectiveQ[%client.team].add(%newObjective);
|
||||
%client.objectiveTask = %newObjective;
|
||||
|
||||
%client.addTask(AIAttackPlayer);
|
||||
%client.bountyTask = %client.addTask(AIBountyEngageTask);
|
||||
|
||||
Game.aiCount++;
|
||||
//set the inv flag
|
||||
%client.spawnUseInv = true;
|
||||
}
|
||||
|
||||
|
||||
//Now, force the bot to choose a player
|
||||
%count = clientGroup.getCount();
|
||||
%rnd = getRandom(0,%count);
|
||||
%rndcl = clientGroup.getObject(%rnd);
|
||||
|
||||
%client.stepEngage(%rndcl);
|
||||
|
||||
Game.aiCount++;
|
||||
//set the inv flag
|
||||
%client.spawnUseInv = true;
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
30
scripts/autoexec/GUIMLWorkaround.cs
Normal file
30
scripts/autoexec/GUIMLWorkaround.cs
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// #autoload
|
||||
// #name = GUIML Workaround
|
||||
// #version = 2.0
|
||||
// #date = March 1st, 2010
|
||||
// #category = Fix
|
||||
// #author = Dark Dragon DX
|
||||
// #warrior = DarkDragonDX
|
||||
// #email = DarkDragonDX@Hotmail.com
|
||||
// #description = Adds a failSafe for the <a:command> tag. Mainly for players that use mods with interactive GUIML elements.
|
||||
|
||||
package GUIMLPackage
|
||||
{
|
||||
function toggleEditor(%make)
|
||||
{
|
||||
parent::toggleEditor(%make); //Call parent function
|
||||
if (!isActivePackage(GUIMLWorkaround))
|
||||
activatePackage(GUIMLWorkaround);
|
||||
}
|
||||
};
|
||||
activatePackage(GUIMLPackage);
|
||||
|
||||
//Seperate package to activate our new code
|
||||
package GUIMLWorkaround
|
||||
{
|
||||
function GuiMLTextCtrl::onURL(%this, %url)
|
||||
{
|
||||
//parent::onURL(%this, %url);
|
||||
commandToServer('ProcessGameLink',getField(%url,1));
|
||||
}
|
||||
};
|
||||
1052
scripts/autoexec/TCmini-client.cs
Normal file
1052
scripts/autoexec/TCmini-client.cs
Normal file
File diff suppressed because it is too large
Load diff
33
scripts/autoexec/TerrainUEPrevent.cs
Normal file
33
scripts/autoexec/TerrainUEPrevent.cs
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// #autoload
|
||||
// #name = Terrain UE Prevent
|
||||
// #version = 1.0
|
||||
// #date = Saturday, July 25, 2009
|
||||
// #category = Fix
|
||||
// #author = Dark Dragon DX
|
||||
// #warrior = DarkDragonDX
|
||||
// #email = DarkDragonDX@Hotmail.com
|
||||
// #description = A "prevention" for when you open the command Circuit on a map without terrain and UE. (Like ANTS)
|
||||
|
||||
package TerrainFix
|
||||
{
|
||||
function toggleCommanderMap(%val)
|
||||
{
|
||||
%count = ServerConnection.getCount();
|
||||
|
||||
for (%i = 0; %i < %count; %i++) //Search for my terrain..
|
||||
{
|
||||
%obj = ServerConnection.getObject(%i); //Get the object
|
||||
|
||||
if (%obj != -1) //No console spam
|
||||
if (%obj.getClassName() $= "TerrainBlock") //Is it terrain?
|
||||
{
|
||||
parent::toggleCommanderMap(%val); //Win
|
||||
return true;
|
||||
}
|
||||
}
|
||||
messageBoxOk("Error","Unable to open command circuit, no terrain exists."); //Tell me
|
||||
return false;
|
||||
}
|
||||
};
|
||||
activatePackage(TerrainFix);
|
||||
|
||||
67
scripts/autoexec/debugLog.cs
Normal file
67
scripts/autoexec/debugLog.cs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
// #autoload
|
||||
// #name = Debug Log
|
||||
// #version = 1.0
|
||||
// #category = Utility
|
||||
// #warrior = DarkDragonDX
|
||||
// #description = Adds a debug log.
|
||||
|
||||
package debugLog
|
||||
{
|
||||
function echo(%arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10)
|
||||
{
|
||||
if (!IsObject(DebugLogger))
|
||||
{
|
||||
new FileObject(DebugLogger);
|
||||
DebugLogger.lineCount = 0;
|
||||
DebugLogger.openForWrite("debugLog.txt");
|
||||
}
|
||||
if (DebugLogger.lineCount >= 10)
|
||||
{
|
||||
DebugLogger.close();
|
||||
DebugLogger.openForAppend("debugLog.txt");
|
||||
}
|
||||
DebugLogger.writeLine(%arg1 @ %arg2 @ %arg3 @ %arg4 @ %arg5 @ %arg6 @ %arg7 @ %arg8 @ %arg9 @ %arg10);
|
||||
DebugLogger.lineCount++;
|
||||
parent::echo(%arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10);
|
||||
return true;
|
||||
}
|
||||
|
||||
function error(%arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10)
|
||||
{
|
||||
if (!IsObject(DebugLogger))
|
||||
{
|
||||
new FileObject(DebugLogger);
|
||||
DebugLogger.lineCount = 0;
|
||||
DebugLogger.openForWrite("debugLog.txt");
|
||||
}
|
||||
if (DebugLogger.lineCount >= 10)
|
||||
{
|
||||
DebugLogger.close();
|
||||
DebugLogger.openForAppend("debugLog.txt");
|
||||
}
|
||||
DebugLogger.writeLine("Error: " @ %arg1 @ %arg2 @ %arg3 @ %arg4 @ %arg5 @ %arg6 @ %arg7 @ %arg8 @ %arg9 @ %arg10);
|
||||
DebugLogger.lineCount++;
|
||||
parent::error(%arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10);
|
||||
return true;
|
||||
}
|
||||
|
||||
function warning(%arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10)
|
||||
{
|
||||
if (!IsObject(DebugLogger))
|
||||
{
|
||||
new FileObject(DebugLogger);
|
||||
DebugLogger.lineCount = 0;
|
||||
DebugLogger.openForWrite("debugLog.txt");
|
||||
}
|
||||
if (DebugLogger.lineCount >= 10)
|
||||
{
|
||||
DebugLogger.close();
|
||||
DebugLogger.openForAppend("debugLog.txt");
|
||||
}
|
||||
DebugLogger.writeLine("Warning: " @ %arg1 @ %arg2 @ %arg3 @ %arg4 @ %arg5 @ %arg6 @ %arg7 @ %arg8 @ %arg9 @ %arg10);
|
||||
DebugLogger.lineCount++;
|
||||
parent::warning(%arg1, %arg2, %arg3, %arg4, %arg5, %arg6, %arg7, %arg8, %arg9, %arg10);
|
||||
return true;
|
||||
}
|
||||
};
|
||||
activatePackage(debugLog);
|
||||
|
|
@ -9,24 +9,45 @@
|
|||
// #description = Adds a new command-line to Tribes 2 for shortcuts: -safeMode
|
||||
// #status = Release
|
||||
|
||||
package SafeMode{
|
||||
function DispatchLaunchMode()
|
||||
package SafeModeOverrides
|
||||
{
|
||||
parent::DispatchLaunchMode();
|
||||
function TCPObject::onLine(){ return true;}
|
||||
function TCPObject::connect(){ return true; }
|
||||
function TCPObject::disconnect(){ return true; }
|
||||
function TCPObject::listen(){ return true; }
|
||||
function TCPObject::send(){ return true; }
|
||||
|
||||
// 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;
|
||||
function HTTPObject::onLine(){ return true; }
|
||||
function HTTPObject::connect(){ return true; }
|
||||
function HTTPObject::disconnect(){ return true; }
|
||||
function HTTPObject::listen(){ return true; }
|
||||
function HTTPObject::send(){ return true;}
|
||||
function HTTPObject::post(){ return true; }
|
||||
|
||||
if( !stricmp(%arg, "-Safemode")) //If enabled, cuts off all TCP & HTTP object connections, preventing UE's when running T2 without internet
|
||||
{
|
||||
exec("scripts/Safemode.cs");
|
||||
}
|
||||
}
|
||||
}
|
||||
function SecureHTTPObject::onLine(){ return true; }
|
||||
function SecureHTTPObject::connect(){ return true; }
|
||||
function SecureHTTPObject::disconnect(){ return true; }
|
||||
function SecureHTTPObject::listen(){ return true; }
|
||||
function SecureHTTPObject::send(){ return true; }
|
||||
function SecureHTTPObject::post(){ return true; }
|
||||
};
|
||||
activatePackage(SafeMode);
|
||||
|
||||
package SafeMode
|
||||
{
|
||||
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, "-Safemode")) //If enabled, cuts off all TCP & HTTP object connections, preventing UE's when running T2 without internet
|
||||
activatePackage(SafeModeOverrides);
|
||||
}
|
||||
}
|
||||
};
|
||||
activatePackage(SafeMode);
|
||||
|
|
@ -2178,5 +2178,5 @@ function SiegeHalftimeHeaderText::onResize( %this, %width, %height )
|
|||
|
||||
//Was moved to client.cs from console_end.cs because alxPlayMusic didn't want to work from console_end.cs for some odd reason ...
|
||||
if ($pref::Audio::musicEnabled)
|
||||
alxPlayMusic("T2BOL/Music/Menu.mp3");
|
||||
alxPlayMusic("T2BOL/Music/Menu.mp3");
|
||||
|
||||
|
|
|
|||
|
|
@ -1,17 +1,15 @@
|
|||
//Parse our file blahha!
|
||||
// Replacement code for the original T2 credits?
|
||||
if (!isFile("data/creditsText.txt"))
|
||||
{
|
||||
exec("scripts/creditsText_default.cs");
|
||||
}
|
||||
exec("scripts/creditsText_default.cs");
|
||||
else
|
||||
{
|
||||
%read = new fileObject();
|
||||
%read.openForRead("data/creditsText.txt");
|
||||
%read = new fileObject();
|
||||
%read.openForRead("data/creditsText.txt");
|
||||
|
||||
while (!%read.isEOF())
|
||||
{
|
||||
%line = %read.readline();
|
||||
addCreditsLine(%line);
|
||||
}
|
||||
%read.detach();
|
||||
}
|
||||
while (!%read.isEOF())
|
||||
{
|
||||
%line = %read.readline();
|
||||
addCreditsLine(%line);
|
||||
}
|
||||
%read.detach();
|
||||
}
|
||||
|
|
@ -14,8 +14,9 @@ $DeathMessageCampingCount = 1;
|
|||
$DeathMessageCamping[0] = '\c0%1 was killed for camping near the Nexus.';
|
||||
|
||||
//Out of Bounds deaths
|
||||
$DeathMessageOOBCount = 1;
|
||||
$DeathMessageOOBCount = 2;
|
||||
$DeathMessageOOB[0] = '\c0%1 was killed for loitering outside the mission area.';
|
||||
$DeathMessageOOB[1] = '\c0%1 was eaten by a Grue.';
|
||||
|
||||
$DeathMessageLavaCount = 4;
|
||||
$DeathMessageLava[0] = '\c0%1\'s last thought before falling into the lava : \'Oops\'.';
|
||||
|
|
|
|||
|
|
@ -1118,6 +1118,9 @@ function DefaultGame::forceObserver( %game, %client, %reason )
|
|||
}
|
||||
|
||||
case "spawnTimeout":
|
||||
// DDDX: Fix for AI's derping this up
|
||||
if (!IsObject(%client))
|
||||
return;
|
||||
%client.camera.getDataBlock().setMode( %client.camera, "observerTimeout" );
|
||||
messageClient(%client, 'MsgClientJoinTeam', '\c2You have been placed in observer mode due to delay in respawning.', %client.name, %game.getTeamName(0), %client, 0 );
|
||||
logEcho(%client.nameBase@" (cl "@%client@") was placed in observer mode due to spawn delay");
|
||||
|
|
@ -1158,8 +1161,13 @@ function DefaultGame::displayDeathMessages(%game, %clVictim, %clKiller, %damageT
|
|||
// z0dd - ZOD, 6/18/02. From Panama Jack, send the damageTypeText as the last varible
|
||||
// in each death message so client knows what weapon it was that killed them.
|
||||
|
||||
%victimGender = (%clVictim.sex $= "Male" ? 'him' : 'her');
|
||||
%victimPoss = (%clVictim.sex $= "Male" ? 'his' : 'her');
|
||||
// Handle Draakan genders
|
||||
%victimSex = %clVictim.sex;
|
||||
if (%victimSex $= "A" || %victimSex $= "B" || %victimSex $= "C")
|
||||
%victimSex = "Male";
|
||||
%victimGender = (%victimSex $= "Male" ? 'him' : 'her');
|
||||
%victimPoss = (%victimSex $= "Male" ? 'his' : 'her');
|
||||
|
||||
%killerGender = (%clKiller.sex $= "Male" ? 'him' : 'her');
|
||||
%killerPoss = (%clKiller.sex $= "Male" ? 'his' : 'her');
|
||||
%victimGenderPoss = (%clVictim.sex $= "Male" ? 'he' : 'she');
|
||||
|
|
@ -3429,7 +3437,8 @@ function DefaultGame::processGameLink(%game, %client, %arg1, %arg2, %arg3, %arg4
|
|||
{
|
||||
messageClient( %client, 'ClearHud', "", 'scoreScreen', 0 );
|
||||
%client.isViewingStatistics = false;
|
||||
CTFGame::updateScoreHud(%game,%client,'scoreHud');
|
||||
//CTFGame:updateScoreHud:(%game,%client,'scoreHud');
|
||||
Game.updateScoreHud(%game,%client,'scoreHud');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
2
scripts/modScripts/Note.txt
Normal file
2
scripts/modScripts/Note.txt
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
These scripts are the internal functioning of the T2BoL mod. It is recommended you don't touch these and just use the BASIC API
|
||||
to make your changes to the game.
|
||||
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
|
||||
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");
|
||||
349
scripts/modScripts/server/HTTPServer.cs
Normal file
349
scripts/modScripts/server/HTTPServer.cs
Normal file
|
|
@ -0,0 +1,349 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// HTTPServer.cs
|
||||
// An experimental HTTP Server written in Torque!
|
||||
// Copyright (c) 2012 The DarkDragonDX
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// --
|
||||
// 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"));
|
||||
}
|
||||
// --
|
||||
|
||||
|
||||
// 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" @
|
||||
"echo(%packet.headers[%packet.headerName[%i]]);\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);
|
||||
//%socket.disconnect();
|
||||
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)
|
||||
{
|
||||
logEcho(%socket SPC "says: " @ %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
|
||||
{
|
||||
%packet.setStatusCode(200);
|
||||
%file = new FileObject();
|
||||
%file.openForRead(%socket.request);
|
||||
%data = "";
|
||||
while (!%file.isEOF())
|
||||
{
|
||||
%line = %file.readLine();
|
||||
echo(%line);
|
||||
|
||||
if (strStr(%socket.request,".html") == -1)
|
||||
{
|
||||
%line = strReplace(%line,">",">");
|
||||
%line = strReplace(%line,"<","<");
|
||||
%line = strReplace(%line," "," ");
|
||||
%line = strReplace(%line,"\t"," ");
|
||||
%data = %data @ %line @ "<br>\n";
|
||||
}
|
||||
else
|
||||
%data = %data @ %line @ "\n";
|
||||
}
|
||||
%file.close();
|
||||
%file.delete();
|
||||
}
|
||||
|
||||
// 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;
|
||||
}
|
||||
81
scripts/modScripts/server/RPG/GameTriggers.cs
Normal file
81
scripts/modScripts/server/RPG/GameTriggers.cs
Normal file
|
|
@ -0,0 +1,81 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// Application SDK for the PDA. (to make my life easier)
|
||||
// Trigger code for RPG Gamemode
|
||||
// Copyright (c) 2012 The DarkDragonDX
|
||||
//==============================================================================
|
||||
|
||||
function RPGGame::onEnterTrigger(%game, %name, %data, %obj, %colObj)
|
||||
{
|
||||
switch$(%obj.type)
|
||||
{
|
||||
case "Transport": if (%obj.targetTransform $= "") return;
|
||||
%Colobj.setTransform(%obj.targetTransform);
|
||||
if (%Colobj.Usewhiteout)
|
||||
%Obj.setWhiteout(0.8);
|
||||
break;
|
||||
case "Territory":
|
||||
if (%obj.race $= "")
|
||||
return;
|
||||
%obj.client.isOnTerritory[%Colobj.race] = true;
|
||||
setClientTeam(%Colobj.client,getRaceTeam(%Obj.race));
|
||||
if (%obj.location $= "")
|
||||
{
|
||||
messageClient(%Colobj.client,'MsgSPCurrentObjective1',"",'Location: %1.', %obj.race SPC "Territory");
|
||||
messageClient(%colObj.client,'msgEnteredRaceTerritory','\c3You have entered %1 territory.',%obj.race);
|
||||
}
|
||||
else
|
||||
{
|
||||
messageClient(%colObj.client,'msgEnteredRaceTerritory','\c3You have entered %1.',%obj.location);
|
||||
messageClient(%Colobj.client,'MsgSPCurrentObjective1',"",'Location: %1.', %obj.location);
|
||||
}
|
||||
break;
|
||||
case "Damage": //Will add lots o' vars onto it..
|
||||
%obj.damage[%colobj] = true;
|
||||
%colObj.isinLava = true;
|
||||
break;
|
||||
}
|
||||
if (%Colobj.message $= "" && %Colobj.type !$= "Territory")
|
||||
messageClient(%Colobj.client,'MsgTrigger',%obj.message);
|
||||
return true;
|
||||
}
|
||||
|
||||
function RPGGame::onLeaveTrigger(%game, %name, %data, %obj, %colObj)
|
||||
{
|
||||
switch$(%obj.type)
|
||||
{
|
||||
case "Territory":
|
||||
if (%obj.race $= "")
|
||||
return;
|
||||
|
||||
if (%obj.location $= "")
|
||||
messageClient(%Colobj.client,'MsgExitedRaceTerritory',"\c3You have exited "@%obj.race@" territory. Your sensor data is now undetectable.");
|
||||
else
|
||||
messageClient(%Colobj.client,'MsgExitedRaceTerritory',"\c3You have exited "@%obj.location@".");
|
||||
%Colobj.client.isOnTerritory[%obj.race] = false;
|
||||
messageClient(%colObj.client,'MsgSPCurrentObjective1',"",'Location: Unknown.');
|
||||
setClientTeam(%Colobj.client,0); //Not on the sensor, I think
|
||||
break;
|
||||
case "Damage":
|
||||
%obj.damage[%obj] = false;
|
||||
%colObj.isInLava = true;
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function RPGGame::onTickTrigger(%game, %name, %data, %obj)
|
||||
{
|
||||
switch(%obj.type)
|
||||
{
|
||||
case "Damage":
|
||||
for (%i = 0; %i < MissionCleanup.getCount(); %i++)
|
||||
{
|
||||
%objT = MissionCleanup.getObject(%i);
|
||||
if (%objt.getClassName() $= "Player" && %objt.getState() $= "move")
|
||||
if (%obj.damage[%objT] && %objT.isInLava)
|
||||
%objT.damage(0, %objT.getPosition(), %obj.damage, %obj,damageType);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
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 The DarkDragonDX
|
||||
//==============================================================================
|
||||
|
||||
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)
|
||||
{
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
38
scripts/modScripts/server/RPG/mining.cs
Normal file
38
scripts/modScripts/server/RPG/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
|
||||
}
|
||||
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
|
||||
49
scripts/modScripts/server/RPG/serverNetworking.cs
Normal file
49
scripts/modScripts/server/RPG/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);
|
||||
}
|
||||
175
scripts/modScripts/server/TCPServer.cs
Normal file
175
scripts/modScripts/server/TCPServer.cs
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// 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 The DarkDragonDX
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
// 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)
|
||||
{
|
||||
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)
|
||||
{
|
||||
echo(%socket SPC "says: " @ %line);
|
||||
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;
|
||||
}
|
||||
15
scripts/modScripts/server/initialise.cs
Normal file
15
scripts/modScripts/server/initialise.cs
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// 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");
|
||||
exec("scripts/modScripts/server/HTTPServer.cs");
|
||||
exec("scripts/modScripts/server/TorqueExServer.cs");
|
||||
|
||||
|
|
@ -4,37 +4,37 @@
|
|||
//----------------------------------------------------------------------------
|
||||
// DATABLOCKS
|
||||
//----------------------------------------------------------------------------
|
||||
datablock StaticShapeData(DetructableSecurityCamera) : StaticShapeDamageProfile
|
||||
{
|
||||
className = "SecurityCamera";
|
||||
shapeFile = "SecurityCamera.dts";
|
||||
maxDamage = 2.0;
|
||||
destroyedLevel = 2.0;
|
||||
disabledLevel = 2.0;
|
||||
mass = 1.2;
|
||||
elasticity = 0.1;
|
||||
friction = 0.9;
|
||||
collideable = 1;
|
||||
pickupRadius = 1;
|
||||
sticky = false;
|
||||
//datablock StaticShapeData(DetructableSecurityCamera) : StaticShapeDamageProfile
|
||||
//{
|
||||
// className = "SecurityCamera";
|
||||
// shapeFile = "SecurityCamera.dts";
|
||||
// maxDamage = 2.0;
|
||||
// destroyedLevel = 2.0;
|
||||
// disabledLevel = 2.0;
|
||||
// mass = 1.2;
|
||||
// elasticity = 0.1;
|
||||
// friction = 0.9;
|
||||
// collideable = 1;
|
||||
// pickupRadius = 1;
|
||||
// sticky = false;
|
||||
|
||||
explosion = CameraGrenadeExplosion;
|
||||
expDmgRadius = 1.0;
|
||||
expDamage = 0.1;
|
||||
expImpulse = 200.0;
|
||||
dynamicType = $TypeMasks::StaticShapeObjectType;
|
||||
deployedObject = true;
|
||||
cmdCategory = "Misc";
|
||||
cmdIcon = CMDSensorIcon;
|
||||
// explosion = CameraGrenadeExplosion;
|
||||
// expDmgRadius = 1.0;
|
||||
// expDamage = 0.1;
|
||||
// expImpulse = 200.0;
|
||||
// dynamicType = $TypeMasks::StaticShapeObjectType;
|
||||
// deployedObject = true;
|
||||
// cmdCategory = "Misc";
|
||||
// cmdIcon = CMDSensorIcon;
|
||||
|
||||
targetNameTag = 'Security';
|
||||
targetTypeTag = 'Camera';
|
||||
deployAmbientThread = true;
|
||||
debrisShapeName = "debris_generic_small.dts";
|
||||
debris = SmallShapeDebris;
|
||||
heatSignature = 0;
|
||||
needsPower = true;
|
||||
};
|
||||
// targetNameTag = 'Security';
|
||||
// targetTypeTag = 'Camera';
|
||||
// deployAmbientThread = true;
|
||||
// debrisShapeName = "debris_generic_small.dts";
|
||||
// debris = SmallShapeDebris;
|
||||
// heatSignature = 0;
|
||||
// needsPower = true;
|
||||
//};
|
||||
|
||||
datablock StaticShapeData(DeployedSpine) : StaticShapeDamageProfile {
|
||||
className = "spine";
|
||||
|
|
|
|||
222
scripts/modScripts/server/torqueExServer.cs
Normal file
222
scripts/modScripts/server/torqueExServer.cs
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// torqueExServer.cs
|
||||
// Torque Extensions for Servers
|
||||
// Copyright (c) 2012 The DarkDragonDX
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// 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.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)
|
||||
{
|
||||
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);
|
||||
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);
|
||||
}
|
||||
HiddenClientGroup.add(%client);
|
||||
return true;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
// Name: showClientInList
|
||||
// Argument %client: The client to show.
|
||||
// Description: Shows the client in the server list only.
|
||||
//==============================================================================
|
||||
function showClientInList(%client)
|
||||
{
|
||||
ClientGroup.add(%client);
|
||||
return true;
|
||||
}
|
||||
|
||||
function ServerCMDCheckHTilt(%client){ return %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::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)
|
||||
{
|
||||
if (!isObject(%this.Client))
|
||||
{
|
||||
%this.Client = new ScriptObject();
|
||||
%this.Client.Player = %this;
|
||||
}
|
||||
return setName(%this, %name);
|
||||
}
|
||||
|
||||
function Player::setTeam(%this, %team)
|
||||
{
|
||||
if (!isObject(%this.Client))
|
||||
{
|
||||
%this.Client = new ScriptObject();
|
||||
%this.Client.Player = %this;
|
||||
}
|
||||
return setTeam(%this, %team);
|
||||
}
|
||||
75
scripts/modScripts/shared/Array.cs
Normal file
75
scripts/modScripts/shared/Array.cs
Normal file
|
|
@ -0,0 +1,75 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// Array.cs
|
||||
// Array object you can pass around.
|
||||
// Copyright (c) 2012 The DarkDragonDX
|
||||
//==============================================================================
|
||||
|
||||
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::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"; };
|
||||
|
|
@ -1,201 +1,276 @@
|
|||
// -----------------------------------------------------
|
||||
// Block Processing
|
||||
// -----------------------------------------------------
|
||||
function getBlockCount(%file,%blockName) //Searches a data file for all occurances of 'blockName'
|
||||
//------------------------------------------------------------------------------
|
||||
// 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)
|
||||
{
|
||||
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++;
|
||||
// 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;
|
||||
|
||||
if (getSubStr(stripSpaces(%line),0,1) !$= ";") //If the beginning of the line is "commented", skip it.
|
||||
%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)
|
||||
{
|
||||
%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.
|
||||
%isProcessingBlock = true;
|
||||
%blockName = getSubStr(%currentLine,%openingBlock+1,%closingBlock-1);
|
||||
|
||||
if (%this.blockInstances[%blockName] == "")
|
||||
{
|
||||
%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,
|
||||
%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)
|
||||
{
|
||||
%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));
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
%fileP.detach();
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
//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)
|
||||
//------------------------------------------------------------------------------
|
||||
// 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)
|
||||
{
|
||||
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;
|
||||
}
|
||||
// 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;
|
||||
}
|
||||
|
|
@ -6,13 +6,13 @@
|
|||
function getFileBuffer(%file)
|
||||
{
|
||||
if (!IsFile(%file))
|
||||
return "Not existant.";
|
||||
return -1;
|
||||
|
||||
new FileObject(FileBuffer);
|
||||
FileBuffer.openForRead(%file);
|
||||
|
||||
while (!FileBuffer.isEOF())
|
||||
%buffer = FileBuffer.readLine() @ "\n";
|
||||
%buffer = %buffer @ FileBuffer.readLine() @ "\n";
|
||||
FileBuffer.detach();
|
||||
return %buffer; //Long string. >.>
|
||||
}
|
||||
|
|
@ -20,7 +20,7 @@ function getFileBuffer(%file)
|
|||
function getLine(%file, %line)
|
||||
{
|
||||
if (!IsFile(%file))
|
||||
return "Not existant.";
|
||||
return -1;
|
||||
|
||||
new FileObject(FileLine);
|
||||
FileLine.openForRead(%file);
|
||||
|
|
@ -34,7 +34,7 @@ function getLine(%file, %line)
|
|||
function getLine(%file, %line)
|
||||
{
|
||||
if (!IsFile(%file))
|
||||
return "Not existant.";
|
||||
return -1;
|
||||
|
||||
new FileObject(FileLine);
|
||||
FileLine.openForRead(%file);
|
||||
|
|
@ -45,6 +45,30 @@ function getLine(%file, %line)
|
|||
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
|
||||
// -----------------------------------------------------
|
||||
|
|
@ -54,7 +78,3 @@ function fileObject::Detach(%this) //Detaches fileObject from file & deletes
|
|||
%this.delete();
|
||||
return %this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
11
scripts/modScripts/shared/initialise.cs
Normal file
11
scripts/modScripts/shared/initialise.cs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
//------------------------------------------------------------------------------
|
||||
// initialise.cs
|
||||
// Shared Functions for T2Bol
|
||||
// Copyright (c) 2012 The DarkDragonDX
|
||||
//==============================================================================
|
||||
exec("scripts/modScripts/shared/Array.cs");
|
||||
exec("scripts/modScripts/shared/stringProcessing.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;
|
||||
}
|
||||
|
|
@ -145,6 +145,7 @@ function getSubStrPos(%string,%str,%num)
|
|||
%subC = 0;
|
||||
for (%i = 0; %i < %len; %i++)
|
||||
{
|
||||
%curPos = %i;
|
||||
%sub = getSubStr(%string,%i,1);
|
||||
|
||||
if (%sub $= %str)
|
||||
|
|
@ -154,15 +155,42 @@ function getSubStrPos(%string,%str,%num)
|
|||
break;
|
||||
}
|
||||
}
|
||||
return %i;
|
||||
return %pos;
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
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)
|
||||
{
|
||||
return getSubStr(%string,getSubStrPos(%string,"/",getSubStrOccurance(%string, "/"))+1,strLen(%string));
|
||||
if (strStr(%string, "/") == -1)
|
||||
return %string;
|
||||
else
|
||||
return getSubStr(%string,getSubStrPos(%string,"/",getSubStrOccurance(%string, "/"))+1,strLen(%string));
|
||||
}
|
||||
|
||||
//-------------------------------------------------------------------------------
|
||||
function getFileExtensionFromString(%string)
|
||||
{
|
||||
%file = getFileNameFromString(%string);
|
||||
%period = strStr(%file,".");
|
||||
if (%period == -1)
|
||||
return false;
|
||||
else
|
||||
return getSubStr(%string,getSubStrPos(%string,".",getSubStrOccurance(%string, "."))+1,strLen(%string));
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
|
|
|||
1528
scripts/objectiveHud.cs
Normal file
1528
scripts/objectiveHud.cs
Normal file
File diff suppressed because it is too large
Load diff
|
|
@ -27,20 +27,6 @@ function onTelnetConnect(%ip, %access)
|
|||
}
|
||||
}
|
||||
|
||||
function serverThink()
|
||||
{
|
||||
if ($CurrentMissionType $= "RPG")
|
||||
{
|
||||
%count = ClientGroup.getCount();
|
||||
for (%i = 0; %i < %count; %i++)
|
||||
{
|
||||
%cl = ClientGroup.getObject(%i);
|
||||
commandToClient(%cl,'HandleScriptedCommand',9,formatTimeString("HHnn") SPC "Hrs.");
|
||||
}
|
||||
}
|
||||
schedule(100,0,"ServerThink");
|
||||
}
|
||||
|
||||
function clearTelnetSpam()
|
||||
{
|
||||
$TelnetSpam = 0;
|
||||
|
|
@ -157,13 +143,10 @@ function CreateServer(%mission, %missionType)
|
|||
exec("scripts/serverTasks.cs");
|
||||
exec("scripts/admin.cs");
|
||||
exec("prefs/banlist.cs");
|
||||
exec("scripts/shared.cs");
|
||||
//T2Bol executes
|
||||
exec("scripts/propData.cs");
|
||||
exec("scripts/looting.cs");
|
||||
exec("scripts/mining.cs");
|
||||
exec("scripts/propertyOwning.cs");
|
||||
exec("scripts/Importer/Building.cs");
|
||||
|
||||
exec("scripts/modScripts/shared/initialise.cs");
|
||||
exec("scripts/modScripts/server/initialise.cs");
|
||||
|
||||
//Execute saved data, if possible
|
||||
if (IsFile("Data/SavedData.cs"))
|
||||
exec("Data/SavedData.cs");
|
||||
|
|
@ -454,11 +437,6 @@ if ($Data::IsInClan[%client.GUID])
|
|||
}
|
||||
}
|
||||
|
||||
function delete(%obj)
|
||||
{
|
||||
%obj.delete();
|
||||
}
|
||||
|
||||
function clientDisconnect(%client,%reason)
|
||||
{
|
||||
messageClient(%client, 'onClientKicked', "");
|
||||
|
|
@ -472,20 +450,6 @@ if( isObject( %client.player ) )
|
|||
return %client SPC %reason;
|
||||
}
|
||||
|
||||
function HideClient(%client)
|
||||
{
|
||||
messageAll('MsgClientDrop', "", Game.kickClientName, %client );
|
||||
|
||||
return %client;
|
||||
}
|
||||
|
||||
function ShowClient(%client)
|
||||
{
|
||||
messageAll('MsgClientJoin', "", %client.name, %client, %client.target, %client.isAIControlled(), %client.isAdmin, %client.isSuperAdmin, %client.isSmurf, %client.Guid);
|
||||
|
||||
return %client;
|
||||
}
|
||||
|
||||
function forceClientSpawn(%client,%setupBool)
|
||||
{
|
||||
%client.race = $Data::Race[%client.GUID];
|
||||
|
|
@ -514,77 +478,6 @@ if (%client.oldTeam $= "")
|
|||
setTargetSensorGroup(%client.target,%team);
|
||||
}
|
||||
|
||||
function forceScoreScreenOpen(%client,%page)
|
||||
{
|
||||
messageClient(%client, 'OpenHud', "", 'scoreScreen' SPC "scoreScreen");
|
||||
RPGGame::processGameLink(Game, %client, %page);
|
||||
}
|
||||
|
||||
function closeScoreScreen(%client)
|
||||
{
|
||||
%client.PDAPage = "MAIN";
|
||||
serverCmdProcessGameLink(%client,"BACK");
|
||||
serverCmdHideHud(%client, 'scoreScreen');
|
||||
commandToClient(%client, 'setHudMode', 'Standard', "", 0);
|
||||
}
|
||||
|
||||
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', %client.team, 0, %client.voicePitch);
|
||||
|
||||
if (IsObject(%client.player))
|
||||
%client.player.setTarget(%client.target);
|
||||
|
||||
return %client SPC %voice;
|
||||
}
|
||||
|
||||
function setSkin(%client, %skin)
|
||||
{
|
||||
freeClientTarget(%client);
|
||||
%client.skin = addtaggedstring(%skin);
|
||||
%client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', %client.team, 0, %client.voicePitch);
|
||||
|
||||
if (IsObject(%client.player))
|
||||
%client.player.setTarget(%client.target);
|
||||
|
||||
return %client SPC %voice;
|
||||
}
|
||||
|
||||
function setName(%client, %name)
|
||||
{
|
||||
freeClientTarget(%client);
|
||||
%client.namebase = %name;
|
||||
%client.name = addtaggedstring(%name);
|
||||
%client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', %client.team, 0, %client.voicePitch);
|
||||
|
||||
if (IsObject(%client.player))
|
||||
%client.player.setTarget(%client.target);
|
||||
|
||||
//Update the client in the lobby.
|
||||
HideClient(%client);
|
||||
ShowClient(%client);
|
||||
|
||||
return %client SPC %voice;
|
||||
}
|
||||
|
||||
function setTeam(%client, %team)
|
||||
{
|
||||
freeClientTarget(%client);
|
||||
%client.target = allocClientTarget(%client, %client.name, %client.skin, %client.voiceTag, '_ClientConnection', %team, 0, %client.voicePitch);
|
||||
|
||||
if (IsObject(%client.player))
|
||||
%client.player.setTarget(%client.target);
|
||||
|
||||
//Update the client in the lobby.
|
||||
HideClient(%client);
|
||||
ShowClient(%client);
|
||||
|
||||
return %client SPC %voice;
|
||||
}
|
||||
|
||||
function initGameBots( %mission, %mType )
|
||||
{
|
||||
echo( "adding bots..." );
|
||||
|
|
@ -777,7 +670,7 @@ function kick( %client, %admin, %guid )
|
|||
|
||||
if( %client.isAIControlled() )
|
||||
{
|
||||
$HostGameBotCount--;
|
||||
$HostGameBotCount--;
|
||||
%client.drop();
|
||||
}
|
||||
else
|
||||
|
|
@ -1201,7 +1094,7 @@ function GameConnection::onDrop(%client, %reason)
|
|||
Game.onClientLeaveGame(%client);
|
||||
|
||||
// make sure that tagged string of player name is not used
|
||||
if (%client.isAIControlled() && $CurrentMissionType !$= "RPG")
|
||||
if (!%client.isAIControlled())
|
||||
{
|
||||
if ( $CurrentMissionType $= "SinglePlayer" || $CurrentMissionType $= "SV")
|
||||
messageAllExcept(%client, -1, 'MsgClientDrop', "", getTaggedString(%client.name), %client);
|
||||
|
|
@ -1500,54 +1393,6 @@ function loadMissionStage2()
|
|||
|
||||
}
|
||||
|
||||
function spawnGeneralBot(%id)
|
||||
{
|
||||
%bot = aiConnectByName($Bot[%id,"Name"],$Bot[%id,"Team"]);
|
||||
%bot.race = $Bot[%id,"Race"];
|
||||
%bot.sex = $Bot[%id, "Sex"];
|
||||
%bot.skin = addTaggedString($Bot[%id,"Skin"]);
|
||||
%bot.voice = $Bot[%id,"Voice"];
|
||||
%bot.voiceTag = addTaggedString(%bot.voice);
|
||||
%bot.voicePitch = $Bot[%id,"VoicePitch"];
|
||||
%bot.player.clearInventory();
|
||||
%bot.player.setArmor($Bot[%id,"Armor"]);
|
||||
setClientTeam(%bot,0); //Anyone not within the range of some sensor group is on zero -- always.
|
||||
%bot.player.setTransform($Bot[%id,"Transform"]); //Now the transform is set, if it's within a territory, the trigger will handle the team
|
||||
%bot.player.setInventory($Bot[%id,"Pack"], 1);
|
||||
//Give the bot his weaponz
|
||||
%count = getWordCount($Bot[%id,"Weapons"]);
|
||||
for (%i = 0; %i < %count; %i++)
|
||||
{
|
||||
%weapon = getWord($Bot[%id,"Weapons"],%i);
|
||||
%bot.player.setInventory(%weapon, 1);
|
||||
%bot.player.setInventory(%weapon @ "Ammo",getWord($Bot[%id,"Ammo"],%i));
|
||||
if (%i == 0) //Use our first weapon
|
||||
%bot.player.use(%weapon);
|
||||
}
|
||||
%bot.id = %id;
|
||||
|
||||
if ($Bot[%id,"UsePack"])
|
||||
%bot.use(%bot.player.getMountedImage(2).item);
|
||||
|
||||
setSkin(%bot,getTaggedString(%bot.skin));
|
||||
setVoice(%bot,%bot.voice);
|
||||
|
||||
//We don't want our bot doing anything without being told
|
||||
if (!$Bot[%id,"Objectives"]) //Should stop the bot cold
|
||||
{
|
||||
AIUnassignClient(%bot);
|
||||
%bot.stop();
|
||||
%bot.clearTasks();
|
||||
%bot.clearStep();
|
||||
%bot.lastDamageClient = -1;
|
||||
%bot.lastDamageTurret = -1;
|
||||
%bot.shouldEngage = -1;
|
||||
%bot.setEngageTarget(-1);
|
||||
%bot.setTargetObject(-1);
|
||||
%bot.pilotVehicle = false;
|
||||
}
|
||||
}
|
||||
|
||||
function ShapeBase::cleanNonType(%this, %type)
|
||||
{
|
||||
if(%this.missionTypesList $= "")
|
||||
|
|
@ -1609,54 +1454,6 @@ function GameConnection::startMission(%this)
|
|||
commandToClient(%this, 'MissionStartPhase1', $missionSequence, $MissionName, MissionGroup.musicTrack);
|
||||
}
|
||||
|
||||
function serverCMDVerifyClient(%client,%GUID,%version)
|
||||
{
|
||||
if (%version < $ModVersion) //Hold your horses! Invalid version comin' through! Although version doesn't really matter..
|
||||
return clientDisconnect(%client,"Your T2BOL version is outdated. Server is running "@$ModVersion@", you are running "@%version@". Please update your client to play on this server.");
|
||||
%client.isValid = true;
|
||||
%GUID = stripNonNumericCharacters(%GUID);
|
||||
if (%client.GUID $= "") //If the GUID isn't already set, then we must be offline.
|
||||
%client.GUID = %GUID;
|
||||
%GUID = %client.GUID;
|
||||
|
||||
if (!$Data::IsRegistered[%GUID])
|
||||
{
|
||||
$Data::IsRegistered[%GUID] = true;
|
||||
$Data::Shots[%GUID] = 0;
|
||||
$Data::Hits[%GUID] = 0;
|
||||
$Data::Misses[%GUID] = 0;
|
||||
$Data::Kills[%GUID] = 0;
|
||||
$Data::Deaths[%GUID] = 0;
|
||||
$Data::Suicides[%GUID] = 0;
|
||||
$Data::Headshots[%GUID] = 0;
|
||||
$Data::Caps[%GUID] = 0;
|
||||
$Data::FlagReturns[%GUID] = 0;
|
||||
$Data::Won[%GUID] = 0;
|
||||
$Data::Lost[%GUID] = 0;
|
||||
}
|
||||
if (!$Data::IsRPGReady[%GUID] && $CurrentMissionType $= "RPG")
|
||||
{
|
||||
$Data::IsRPGReady[%GUID] = true;
|
||||
$Data::Sex[%GUID] = %client.sex;
|
||||
$Data::Race[%GUID] = %client.race;
|
||||
$Data::Steel[%GUID,$CurrentMission] = 0;
|
||||
$Data::Money[%GUID,$CurrentMission] = 0;
|
||||
$Data::EMail::Count[%GUID] = 1;
|
||||
$Data::EMail::Title[%GUID,1] = "Welcome";
|
||||
$Data::EMail::Sender[%GUID,1] = "The Comittee";
|
||||
$Data::EMail::Contents[%GUID,1] = "Welcome to T2Bol, try not to die.";
|
||||
$Data::EMail::Date[%GUID,1] = formatTimeString("DD, MM dd, yy @ hh:nn A");
|
||||
if ($Data::ClientCount $= "")
|
||||
$Data::ClientCount = 0;
|
||||
$Data::ClientGUID[$Data::ClientCount] = %GUID;
|
||||
$Data::ClientName[$Data::ClientCount] = %client.namebase;
|
||||
$Data::ClientCount++;
|
||||
}
|
||||
|
||||
%client.PDAPage = "MAIN";
|
||||
saveGame();
|
||||
}
|
||||
|
||||
function serverCmdInputDone(%client, %type, %value) //Used when creating/editing clans
|
||||
{
|
||||
switch$(%type)
|
||||
|
|
@ -1694,8 +1491,8 @@ function serverCmdMissionStartPhase1Done(%client, %seq)
|
|||
return;
|
||||
%client.currentPhase = 1;
|
||||
|
||||
if (!%client.isValid && $RequiresClient[$CurrentMissionType]) //Did this person say he's a client and the gamemode requires clientside stuff?
|
||||
return clientDisconnect(%client,"You do not have a Tribes 2: Birth of Legend mod client running.");
|
||||
// if (!%client.isValid && $RequiresClient[$CurrentMissionType]) //Did this person say he's a client and the gamemode requires //clientside stuff?
|
||||
/// return clientDisconnect(%client,"You do not have a Tribes 2: Birth of Legend mod client running.");
|
||||
|
||||
schedule(1000, 0, "debriefLoad", %client);
|
||||
|
||||
|
|
@ -2038,15 +1835,6 @@ function isNumber(%text)
|
|||
}
|
||||
//---------------------------------------------------------------
|
||||
|
||||
//----------------------------------------------------
|
||||
// z0dd - ZOD, 3/09/02. Replaced by function below.
|
||||
//function serverCmdSADSetPassword(%client, %password)
|
||||
//{
|
||||
// if(%client.isSuperAdmin)
|
||||
// $Host::AdminPassword = %password;
|
||||
//}
|
||||
//----------------------------------------------------
|
||||
|
||||
//---------------------------------------------------------
|
||||
// z0dd - ZOD, 3/10/02. New remote admin control function
|
||||
function serverCmdSet(%client, %type, %val)
|
||||
|
|
@ -3291,38 +3079,6 @@ function removeAllBots() //Wtf -- it crashes.
|
|||
%client.delete();
|
||||
}
|
||||
}
|
||||
|
||||
function disconnectAllBots()
|
||||
{
|
||||
%count = ClientGroup.getCount();
|
||||
for (%i = 0; %i < ClientGroup.getCount(); %i++)
|
||||
{
|
||||
%cl = ClientGroup.getObject(%i);
|
||||
|
||||
if (%cl.isAIControlled())
|
||||
schedule(100,0,"Drop",%cl); //Needs a bit of a delay; or else the bots won't disconnect
|
||||
}
|
||||
}
|
||||
|
||||
function drop(%cl)
|
||||
{
|
||||
%cl.drop();
|
||||
}
|
||||
|
||||
package ServerPackage
|
||||
{
|
||||
function AIConnection::Drop(%cl) //Fix the game crashing when .drop() is called on a bot more than once
|
||||
{
|
||||
if (%cl.dropped)
|
||||
return;
|
||||
%cl.dropped = true;
|
||||
Parent::Drop(%cl);
|
||||
}
|
||||
};
|
||||
activatePackage(ServerPackage);
|
||||
|
||||
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
function getServerGUIDList()
|
||||
{
|
||||
|
|
@ -3392,19 +3148,6 @@ function serverCmdProcessGameLink(%client, %arg1, %arg2, %arg3, %arg4, %arg5)
|
|||
Game.processGameLink(%client, %arg1, %arg2, %arg3, %arg4, %arg5);
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
// Dark Dragon DX - 1/26/10. I noticed certain objects are missing some functions.
|
||||
function InteriorInstance::GetClassName(%this)
|
||||
{
|
||||
return "InteriorInstance";
|
||||
}
|
||||
|
||||
function Terraformer::GetClassName(%this)
|
||||
{
|
||||
return "Terraformer";
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
|
||||
//-----------------------------------------------------------------------------------
|
||||
// z0dd - ZOD, 6/03/02. New function. Impact hit sounds settings from clientprefs.cs.
|
||||
function serverCmdSetHitSounds( %client, %playerHitsOn, %playerHitWav, %vehicleHitsOn, %vehicleHitWav )
|
||||
|
|
@ -3440,4 +3183,4 @@ function serverCMDaprint(%client, %msg, %bottom)
|
|||
centerprintAll(%message, 8, 3);
|
||||
}
|
||||
}
|
||||
//-----------------------------------------------------------------------------------
|
||||
//-----------------------------------------------------------------------------------
|
||||
Loading…
Add table
Add a link
Reference in a new issue