mirror of
https://github.com/Ragora/T2-BoL.git
synced 2026-03-09 07:20:27 +00:00
Did stuff.
This commit is contained in:
parent
09f43122e6
commit
8c96cba3e1
132 changed files with 56515 additions and 1448 deletions
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);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue