added everything

This commit is contained in:
Metario
2017-04-17 06:17:10 -06:00
commit 9c6ff74f19
6121 changed files with 1625704 additions and 0 deletions

0
example/demo/server/banlist.cs Executable file
View File

44
example/demo/server/defaults.cs Executable file
View File

@ -0,0 +1,44 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
// List of master servers to query, each one is tried in order
// until one responds
$Pref::Server::RegionMask = 2;
$pref::Master[0] = "2:master.garagegames.com:28002";
// Information about the server
$Pref::Server::Name = "Torque Demo Server";
$Pref::Server::Info = "This is a Torque Demo server.";
// The connection error message is transmitted to the client immediatly
// on connection, if any further error occures during the connection
// process, such as network traffic mismatch, or missing files, this error
// message is display. This message should be replaced with information
// usefull to the client, such as the url or ftp address of where the
// latest version of the game can be obtained.
$Pref::Server::ConnectionError =
"You do not have the correct version of Torque demo or "@
"the resources needed to play on this server, please contact "@
"the server operator or visit the <a:www.garagegames.com/mg/projects/torque1>Torque</a> "@
"project web site for more information.";
// The network port is also defined by the client, this value
// overrides pref::net::port for dedicated servers
$Pref::Server::Port = 28000;
// If the password is set, clients must provide it in order
// to connect to the server
$Pref::Server::Password = "";
// Password for admin clients
$Pref::Server::AdminPassword = "";
// Misc server settings.
$Pref::Server::MaxPlayers = 64;
$Pref::Server::TimeLimit = 20; // In minutes
$Pref::Server::KickBanTime = 300; // specified in seconds
$Pref::Server::BanTime = 1800; // specified in seconds
$Pref::Server::FloodProtectionEnabled = 1;
$Pref::Server::MaxChatLen = 120;

Binary file not shown.

80
example/demo/server/init.cs Executable file
View File

@ -0,0 +1,80 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Variables used by server scripts & code. The ones marked with (c)
// are accessed from code. Variables preceeded by Pref:: are server
// preferences and stored automatically in the ServerPrefs.cs file
// in between server sessions.
//
// (c) Server::ServerType {SinglePlayer, MultiPlayer}
// (c) Server::GameType Unique game name
// (c) Server::Dedicated Bool
// ( ) Server::MissionFile Mission .mis file name
// (c) Server::MissionName DisplayName from .mis file
// (c) Server::MissionType Not used
// (c) Server::PlayerCount Current player count
// (c) Server::GuidList Player GUID (record list?)
// (c) Server::Status Current server status
//
// (c) Pref::Server::Name Server Name
// (c) Pref::Server::Password Password for client connections
// ( ) Pref::Server::AdminPassword Password for client admins
// (c) Pref::Server::Info Server description
// (c) Pref::Server::MaxPlayers Max allowed players
// (c) Pref::Server::RegionMask Registers this mask with master server
// ( ) Pref::Server::BanTime Duration of a player ban
// ( ) Pref::Server::KickBanTime Duration of a player kick & ban
// ( ) Pref::Server::MaxChatLen Max chat message len
// ( ) Pref::Server::FloodProtectionEnabled Bool
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function initServer()
{
echo("\n--------- Initializing MOD: Torque Demo Server ---------");
// Server::Status is returned in the Game Info Query and represents the
// current status of the server. This string sould be very short.
$Server::Status = "Unknown";
// Turn on testing/debug script functions
$Server::TestCheats = false;
// Specify where the mission files are.
$Server::MissionFileSpec = "*/missions/*.mis";
// The common module provides the basic server functionality
initBaseServer();
// Load up game server support scripts
exec("./scripts/commands.cs");
exec("./scripts/centerPrint.cs");
exec("./scripts/game.cs");
}
//-----------------------------------------------------------------------------
function initDedicated()
{
enableWinConsole(true);
echo("\n--------- Starting Dedicated Server ---------");
// Make sure this variable reflects the correct state.
$Server::Dedicated = true;
// The server isn't started unless a mission has been specified.
if ($missionArg !$= "") {
createServer("MultiPlayer", $missionArg);
}
else
echo("No mission specified (use -mission filename)");
}

BIN
example/demo/server/init.cs.dso Executable file

Binary file not shown.

13
example/demo/server/prefs.cs Executable file
View File

@ -0,0 +1,13 @@
$Pref::Server::AdminPassword = "";
$Pref::Server::BanTime = 1800;
$Pref::Server::ConnectionError = "You do not have the correct version of Torque demo or the resources needed to play on this server, please contact the server operator or visit the <a:www.garagegames.com/mg/projects/torque1>Torque</a> project web site for more information.";
$Pref::Server::FloodProtectionEnabled = 1;
$Pref::Server::Info = "This is a Torque Demo server.";
$Pref::Server::KickBanTime = 300;
$Pref::Server::MaxChatLen = 120;
$Pref::Server::MaxPlayers = 64;
$Pref::Server::Name = "Torque Demo Server";
$Pref::Server::Password = "";
$Pref::Server::Port = 28000;
$Pref::Server::RegionMask = 2;
$Pref::Server::TimeLimit = 20;

View File

@ -0,0 +1,255 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// AIPlayer callbacks
// The AIPlayer class implements the following callbacks:
//
// PlayerData::onStuck(%this,%obj)
// PlayerData::onUnStuck(%this,%obj)
// PlayerData::onStop(%this,%obj)
// PlayerData::onMove(%this,%obj)
// PlayerData::onReachDestination(%this,%obj)
// PlayerData::onTargetEnterLOS(%this,%obj)
// PlayerData::onTargetExitLOS(%this,%obj)
// PlayerData::onAdd(%this,%obj)
//
// Since the AIPlayer doesn't implement it's own datablock, these callbacks
// all take place in the PlayerData namespace.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Demo Pathed AIPlayer.
//-----------------------------------------------------------------------------
datablock StaticShapeData(ElfDance)
{
category = "Misc";
shapeFile = "~/data/shapes/tge_elf/elf.dts";
};
function ElfDance::onAdd(%this,%obj)
{
%obj.playThread(0,"celmirror");
%obj.repeatFlag = true;
}
datablock PlayerData(DemoPlayer : PlayerBody)
{
className = "PathedPlayer";
maxInv[CrossbowAmmo] = 500000; // Lots of ammo for the demo
demo = true;
};
function DemoPlayer::onReachDestination(%this,%obj)
{
// Moves to the next node on the path.
// Override for all player. Normally we'd override this for only
// a specific player datablock or class of players.
if (%obj.path !$= "") {
if (%obj.currentNode == %obj.targetNode)
%this.onEndOfPath(%obj,%obj.path);
else
%obj.moveToNextNode();
}
}
function DemoPlayer::onEndOfPath(%this,%obj,%path)
{
%obj.nextTask();
}
function DemoPlayer::onEndSequence(%this,%obj,%slot)
{
echo("Sequence Done!");
%obj.stopThread(%slot);
%obj.nextTask();
}
//-----------------------------------------------------------------------------
// AIPlayer static functions
//-----------------------------------------------------------------------------
function AIPlayer::spawn(%name,%spawnPoint)
{
// Create the demo player object
%player = new AiPlayer() {
dataBlock = DemoPlayer;
path = "";
};
MissionCleanup.add(%player);
%player.setShapeName(%name);
%player.setTransform(%spawnPoint);
return %player;
}
function AIPlayer::spawnOnPath(%name,%path)
{
// Spawn a player and place him on the first node of the path
if (!isObject(%path))
return;
%node = %path.getObject(0);
%player = AIPlayer::spawn(%name,%node.getTransform());
return %player;
}
//-----------------------------------------------------------------------------
// AIPlayer methods
//-----------------------------------------------------------------------------
function AIPlayer::followPath(%this,%path,%node)
{
// Start the player following a path
%this.stopThread(0);
if (!isObject(%path)) {
%this.path = "";
return;
}
if (%node > %path.getCount() - 1)
%this.targetNode = %path.getCount() - 1;
else
%this.targetNode = %node;
if (%this.path $= %path)
%this.moveToNode(%this.currentNode);
else {
%this.path = %path;
%this.moveToNode(0);
}
}
function AIPlayer::moveToNextNode(%this)
{
if (%this.targetNode < 0 || %this.currentNode < %this.targetNode) {
if (%this.currentNode < %this.path.getCount() - 1)
%this.moveToNode(%this.currentNode + 1);
else
%this.moveToNode(0);
}
else
if (%this.currentNode == 0)
%this.moveToNode(%this.path.getCount() - 1);
else
%this.moveToNode(%this.currentNode - 1);
}
function AIPlayer::moveToNode(%this,%index)
{
// Move to the given path node index
%this.currentNode = %index;
%node = %this.path.getObject(%index);
%this.setMoveDestination(%node.getTransform(), %index == %this.targetNode);
}
//-----------------------------------------------------------------------------
//
//-----------------------------------------------------------------------------
function AIPlayer::pushTask(%this,%method)
{
if (%this.taskIndex $= "") {
%this.taskIndex = 0;
%this.taskCurrent = -1;
}
%this.task[%this.taskIndex] = %method;
%this.taskIndex++;
if (%this.taskCurrent == -1)
%this.executeTask(%this.taskIndex - 1);
}
function AIPlayer::clearTasks(%this)
{
%this.taskIndex = 0;
%this.taskCurrent = -1;
}
function AIPlayer::nextTask(%this)
{
if (%this.taskCurrent != -1)
if (%this.taskCurrent < %this.taskIndex - 1)
%this.executeTask(%this.taskCurrent++);
else
%this.taskCurrent = -1;
}
function AIPlayer::executeTask(%this,%index)
{
%this.taskCurrent = %index;
eval(%this.getId() @ "." @ %this.task[%index] @ ";");
}
//-----------------------------------------------------------------------------
function AIPlayer::singleShot(%this)
{
// This shooting delay is here for the demo, don't want to fire
// at the weapon's full rate.
%this.setImageTrigger(0,true);
%this.setImageTrigger(0,false);
%this.trigger = %this.schedule(2000,singleShot);
}
//-----------------------------------------------------------------------------
function AIPlayer::wait(%this,%time)
{
%this.schedule(%time * 1000,"nextTask");
}
function AIPlayer::done(%this,%time)
{
%this.schedule(0,"delete");
}
function AIPlayer::fire(%this,%bool)
{
if (%bool) {
cancel(%this.trigger);
%this.singleShot();
}
else
cancel(%this.trigger);
%this.nextTask();
}
function AIPlayer::aimAt(%this,%object)
{
echo("Aim: " @ %object);
%this.setAimObject(%object);
%this.nextTask();
}
function AIPlayer::animate(%this,%seq)
{
//%this.stopThread(0);
//%this.playThread(0,%seq);
%this.setActionThread(%seq);
}
function AIPlayer::test()
{
%player = AIPlayer::spawnOnPath("xasd","MissionGroup/Paths/Path2");
%player.mountImage(CrossbowImage,0);
%player.setInventory(CrossbowAmmo,1000);
%player.pushTask("followPath(\"MissionGroup/Paths/Path2\")");
%player.pushTask("aimAt(\"MissionGroup/Room6/target\")");
%player.pushTask("wait(1)");
%player.pushTask("fire(true)");
%player.pushTask("wait(10)");
%player.pushTask("fire(false)");
%player.pushTask("playThread(0,\"celwave\")");
%player.pushTask("done()");
}

Binary file not shown.

View File

@ -0,0 +1,124 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// 3D Sounds
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Single shot sounds
datablock AudioDescription(AudioDefault3d)
{
volume = 1.0;
isLooping= false;
is3D = true;
ReferenceDistance= 20.0;
MaxDistance= 100.0;
type = $SimAudioType;
};
datablock AudioDescription(AudioClose3d)
{
volume = 1.0;
isLooping= false;
is3D = true;
ReferenceDistance= 10.0;
MaxDistance= 60.0;
type = $SimAudioType;
};
datablock AudioDescription(AudioClosest3d)
{
volume = 1.0;
isLooping= false;
is3D = true;
ReferenceDistance= 5.0;
MaxDistance= 30.0;
type = $SimAudioType;
};
datablock AudioDescription(AudioLightning3d)
{
volume = 1.0;
isLooping= false;
is3D = true;
ReferenceDistance= 10.0;
MaxDistance= 400.0;
type = $SimAudioType;
};
//-----------------------------------------------------------------------------
// Looping sounds
datablock AudioDescription(AudioDefaultLooping3d)
{
volume = 1.0;
isLooping= true;
is3D = true;
ReferenceDistance= 20.0;
MaxDistance= 100.0;
type = $SimAudioType;
};
datablock AudioDescription(AudioCloseLooping3d)
{
volume = 1.0;
isLooping= true;
is3D = true;
ReferenceDistance= 10.0;
MaxDistance= 50.0;
type = $SimAudioType;
};
datablock AudioDescription(AudioClosestLooping3d)
{
volume = 1.0;
isLooping= true;
is3D = true;
ReferenceDistance= 5.0;
MaxDistance= 30.0;
type = $SimAudioType;
};
//-----------------------------------------------------------------------------
// 2d sounds
//-----------------------------------------------------------------------------
// Used for non-looping environmental sounds (like power on, power off)
datablock AudioDescription(Audio2D)
{
volume = 1.0;
isLooping = false;
is3D = false;
type = $SimAudioType;
};
// Used for Looping Environmental Sounds
datablock AudioDescription(AudioLooping2D)
{
volume = 1.0;
isLooping = true;
is3D = false;
type = $SimAudioType;
};
//-----------------------------------------------------------------------------
datablock AudioProfile(takeme)
{
filename = "~/data/sound/takeme.wav";
description = "AudioDefaultLooping3d";
preload = false;
};

Binary file not shown.

View File

@ -0,0 +1,80 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
// Global movement speed that affects all cameras. This should be moved
// into the camera datablock.
$Camera::movementSpeed = 40;
//-----------------------------------------------------------------------------
// Define a datablock class to use for our observer camera
//-----------------------------------------------------------------------------
datablock CameraData(Observer)
{
mode = "Observer";
};
//-----------------------------------------------------------------------------
function Observer::onTrigger(%this,%obj,%trigger,%state)
{
// state = 0 means that a trigger key was released
if (%state == 0)
return;
// Default player triggers: 0=fire 1=altFire 2=jump
%client = %obj.getControllingClient();
switch$ (%obj.mode)
{
case "Observer":
// Do something interesting.
case "Corpse":
// Viewing dead corpse, so we probably want to respawn.
%client.spawnPlayer();
// Set the camera back into observer mode, since in
// debug mode we like to switch to it.
%this.setMode(%obj,"Observer");
}
}
function Observer::setMode(%this,%obj,%mode,%arg1,%arg2,%arg3)
{
switch$ (%mode)
{
case "Observer":
// Let the player fly around
%obj.setFlyMode();
case "Corpse":
// Lock the camera down in orbit around the corpse,
// which should be arg1
%transform = %arg1.getTransform();
%obj.setOrbitMode(%arg1, %transform, 0.5, 4.5, 4.5);
}
%obj.mode = %mode;
}
//-----------------------------------------------------------------------------
// Camera methods
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function Camera::onAdd(%this,%obj)
{
// Default start mode
%this.setMode(%this.mode);
}
function Camera::setMode(%this,%mode,%arg1,%arg2,%arg3)
{
// Punt this one over to our datablock
%this.getDatablock().setMode(%this,%mode,%arg1,%arg2,%arg3);
}

Binary file not shown.

View File

@ -0,0 +1,87 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
function centerPrintAll( %message, %time, %lines )
{
if( %lines $= "" || ((%lines > 3) || (%lines < 1)) )
%lines = 1;
%count = ClientGroup.getCount();
for (%i = 0; %i < %count; %i++)
{
%cl = ClientGroup.getObject(%i);
if( !%cl.isAIControlled() )
commandToClient( %cl, 'centerPrint', %message, %time, %lines );
}
}
function bottomPrintAll( %message, %time, %lines )
{
if( %lines $= "" || ((%lines > 3) || (%lines < 1)) )
%lines = 1;
%count = ClientGroup.getCount();
for (%i = 0; %i < %count; %i++)
{
%cl = ClientGroup.getObject(%i);
if( !%cl.isAIControlled() )
commandToClient( %cl, 'bottomPrint', %message, %time, %lines );
}
}
//-------------------------------------------------------------------------------------------------------
function centerPrint( %client, %message, %time, %lines )
{
if( %lines $= "" || ((%lines > 3) || (%lines < 1)) )
%lines = 1;
commandToClient( %client, 'CenterPrint', %message, %time, %lines );
}
function bottomPrint( %client, %message, %time, %lines )
{
if( %lines $= "" || ((%lines > 3) || (%lines < 1)) )
%lines = 1;
commandToClient( %client, 'BottomPrint', %message, %time, %lines );
}
//-------------------------------------------------------------------------------------------------------
function clearCenterPrint( %client )
{
commandToClient( %client, 'ClearCenterPrint');
}
function clearBottomPrint( %client )
{
commandToClient( %client, 'ClearBottomPrint');
}
//-------------------------------------------------------------------------------------------------------
function clearCenterPrintAll()
{
%count = ClientGroup.getCount();
for (%i = 0; %i < %count; %i++)
{
%cl = ClientGroup.getObject(%i);
if( !%cl.isAIControlled() )
commandToClient( %cl, 'ClearCenterPrint');
}
}
function clearBottomPrintAll()
{
%count = ClientGroup.getCount();
for (%i = 0; %i < %count; %i++)
{
%cl = ClientGroup.getObject(%i);
if( !%cl.isAIControlled() )
commandToClient( %cl, 'ClearBottomPrint');
}
}

Binary file not shown.

View File

@ -0,0 +1,394 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
datablock ParticleData(ChimneySmoke)
{
textureName = "~/data/shapes/particles/smoke";
dragCoefficient = 0.0;
gravityCoefficient = -0.2; // rises slowly
inheritedVelFactor = 0.00;
lifetimeMS = 3000;
lifetimeVarianceMS = 250;
useInvAlpha = false;
spinRandomMin = -30.0;
spinRandomMax = 30.0;
colors[0] = "0.6 0.6 0.6 0.1";
colors[1] = "0.6 0.6 0.6 0.1";
colors[2] = "0.6 0.6 0.6 0.0";
sizes[0] = 0.5;
sizes[1] = 0.75;
sizes[2] = 1.5;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(ChimneySmokeEmitter)
{
ejectionPeriodMS = 20;
periodVarianceMS = 5;
ejectionVelocity = 0.25;
velocityVariance = 0.10;
thetaMin = 0.0;
thetaMax = 90.0;
particles = ChimneySmoke;
};
datablock ParticleEmitterNodeData(ChimneySmokeEmitterNode)
{
timeMultiple = 1;
};
datablock ParticleData(CottageSmoke)
{
textureName = "~/data/shapes/particles/smoke";
dragCoefficient = 0.0;
gravityCoefficient = 0.02; // rises slowly
inheritedVelFactor = 0.00;
lifetimeMS = 3000;
lifetimeVarianceMS = 250;
useInvAlpha = false;
spinRandomMin = -30.0;
spinRandomMax = 30.0;
colors[0] = "0.0 0.0 0.0 0.0";
colors[1] = "0.2 0.2 0.2 0.1";
colors[2] = "0.0 0.0 0.0 0.0";
sizes[0] = 0.5;
sizes[1] = 0.75;
sizes[2] = 1.5;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(CottageSmokeEmitter)
{
ejectionPeriodMS = 20;
periodVarianceMS = 5;
ejectionVelocity = 0.0;
velocityVariance = 0.0;
thetaMin = 0.0;
thetaMax = 90.0;
particles = CottageSmoke;
};
datablock ParticleEmitterNodeData(CottageSmokeEmitterNode)
{
timeMultiple = 1;
};
//-----------------------------------------------------------------------------
datablock ParticleData(ChimneyFire1)
{
textureName = "~/data/shapes/particles/smoke";
dragCoefficient = 0.0;
gravityCoefficient = -0.3; // rises slowly
inheritedVelFactor = 0.00;
lifetimeMS = 500;
lifetimeVarianceMS = 250;
useInvAlpha = false;
spinRandomMin = -30.0;
spinRandomMax = 30.0;
colors[0] = "0.8 0.6 0.0 0.1";
colors[1] = "0.8 0.6 0.0 0.1";
colors[2] = "0.0 0.0 0.0 0.0";
sizes[0] = 1.0;
sizes[1] = 1.0;
sizes[2] = 5.0;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleData(ChimneyFire2)
{
textureName = "~/data/shapes/particles/smoke";
dragCoefficient = 0.0;
gravityCoefficient = -0.5; // rises slowly
inheritedVelFactor = 0.00;
lifetimeMS = 800;
lifetimeVarianceMS = 150;
useInvAlpha = false;
spinRandomMin = -30.0;
spinRandomMax = 30.0;
colors[0] = "0.6 0.6 0.0 0.1";
colors[1] = "0.6 0.6 0.0 0.1";
colors[2] = "0.0 0.0 0.0 0.0";
sizes[0] = 0.5;
sizes[1] = 0.5;
sizes[2] = 0.5;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(ChimneyFireEmitter)
{
ejectionPeriodMS = 15;
periodVarianceMS = 5;
ejectionVelocity = 0.25;
velocityVariance = 0.10;
thetaMin = 0.0;
thetaMax = 90.0;
particles = "ChimneyFire1" TAB "ChimneyFire2";
};
datablock ParticleEmitterNodeData(ChimneyFireEmitterNode)
{
timeMultiple = 1;
};
//-----------------------------------------------------------------------------
// TORCHFIRE particle emitters - used on the braziers in the Orc Temple
//-----------------------------------------------------------------------------
datablock ParticleData(TorchFire1)
{
textureName = "~/data/shapes/particles/smoke";
dragCoefficient = 0.0;
gravityCoefficient = -0.3; // rises slowly
inheritedVelFactor = 0.00;
lifetimeMS = 500;
lifetimeVarianceMS = 250;
useInvAlpha = false;
spinRandomMin = -30.0;
spinRandomMax = 30.0;
colors[0] = "0.6 0.6 0.0 0.1";
colors[1] = "0.8 0.6 0.0 0.1";
colors[2] = "0.0 0.0 0.0 0.1";
sizes[0] = 0.5;
sizes[1] = 0.5;
sizes[2] = 2.4;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleData(TorchFire2)
{
textureName = "~/data/shapes/particles/smoke";
dragCoefficient = 0.0;
gravityCoefficient = -0.5; // rises slowly
inheritedVelFactor = 0.00;
lifetimeMS = 800;
lifetimeVarianceMS = 150;
useInvAlpha = false;
spinRandomMin = -30.0;
spinRandomMax = 30.0;
colors[0] = "0.8 0.6 0.0 0.1";
colors[1] = "0.6 0.6 0.0 0.1";
colors[2] = "0.0 0.0 0.0 0.1";
sizes[0] = 0.3;
sizes[1] = 0.3;
sizes[2] = 0.3;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(TorchFireEmitter)
{
ejectionPeriodMS = 15;
periodVarianceMS = 5;
ejectionVelocity = 0.25;
velocityVariance = 0.10;
thetaMin = 0.0;
thetaMax = 45.0;
particles = "TorchFire1" TAB "TorchFire2";
};
datablock ParticleEmitterNodeData(TorchFireEmitterNode)
{
timeMultiple = 1;
};
// ----------------------------------------
datablock ParticleData(FliesParticle)
{
textureName = "~/data/shapes/particles/firefly";
dragCoefficient = 0.0;
windCoefficient = 5.0;
gravityCoefficient = 0.0;
inheritedVelFactor = 0.00;
lifetimeMS = 8000;
lifetimeVarianceMS = 0;
useInvAlpha = false;
spinRandomMin = -90.0;
spinRandomMax = 90.0;
colors[0] = "0 0 0 0 ";
colors[1] = "1 0 0 1";
colors[2] = "1 1 0 1";
colors[3] = "0 0 0 0";
sizes[0] = 0.0;
sizes[1] = 0.15;
sizes[2] = 0.2;
sizes[3] = 0.0;
times[0] = 0.0;
times[1] = 0.1;
times[2] = 0.5;
times[3] = 1.0;
};
datablock ParticleEmitterData(FliesEmitter)
{
ejectionPeriodMS = 300;
periodVarianceMS = 0;
ejectionVelocity = 3;
velocityVariance = 1.00;
ejectionOffset = 1.0;
thetaMin = 75.0;
thetaMax = 90.0;
phiReferenceVel = 360.00;
phiVariance = 360.00;
particles = "FliesParticle";
};
datablock ParticleEmitterNodeData(FliesNode)
{
timeMultiple = 1;
};
// ----------------------------------------
datablock ParticleData(EmberParticle)
{
textureName = "~/data/shapes/particles/ember";
dragCoefficient = 0.0;
windCoefficient = 0.0;
gravityCoefficient = -0.05; // rises slowly
inheritedVelFactor = 0.00;
lifetimeMS = 5000;
lifetimeVarianceMS = 0;
useInvAlpha = false;
spinRandomMin = -90.0;
spinRandomMax = 90.0;
colors[0] = "1.000000 0.800000 0.000000 0.800000";
colors[1] = "1.000000 0.700000 0.000000 0.800000";
colors[2] = "1.000000 0.000000 0.000000 0.200000";
sizes[0] = 0.05;
sizes[1] = 0.1;
sizes[2] = 0.05;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(EmberEmitter)
{
ejectionPeriodMS = 100;
periodVarianceMS = 0;
ejectionVelocity = 0.75;
velocityVariance = 0.00;
ejectionOffset = 2.0;
thetaMin = 1.0;
thetaMax = 100.0;
particles = "EmberParticle";
};
datablock ParticleEmitterNodeData(EmberNode)
{
timeMultiple = 1;
};
// ----------------------------------------
datablock ParticleData(CampFireParticle)
{
textureName = "~/data/shapes/particles/smoke";
dragCoefficient = 0.0;
windCoefficient = 0.0;
gravityCoefficient = -0.05; // rises slowly
inheritedVelFactor = 0.00;
lifetimeMS = 5000;
lifetimeVarianceMS = 1000;
useInvAlpha = false;
spinRandomMin = -90.0;
spinRandomMax = 90.0;
spinSpeed = 1.0;
colors[0] = "0.2 0.2 0.0 0.2";
colors[1] = "0.6 0.2 0.0 0.2";
colors[2] = "0.4 0.0 0.0 0.1";
colors[3] = "0.1 0.04 0.0 0.3";
sizes[0] = 0.5;
sizes[1] = 4.0;
sizes[2] = 5.0;
sizes[3] = 6.0;
times[0] = 0.0;
times[1] = 0.1;
times[2] = 0.2;
times[3] = 0.3;
};
datablock ParticleEmitterData(CampFireEmitter)
{
ejectionPeriodMS = 50;
periodVarianceMS = 0;
ejectionVelocity = 0.55;
velocityVariance = 0.00;
ejectionOffset = 1.0;
thetaMin = 1.0;
thetaMax = 100.0;
particles = "CampFireParticle";
};
datablock ParticleEmitterNodeData(CampFireNode)
{
timeMultiple = 1;
};

Binary file not shown.

View File

@ -0,0 +1,64 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Misc. server commands avialable to clients
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function serverCmdToggleCamera(%client)
{
%control = %client.getControlObject();
if (%control == %client.player)
{
%control = %client.camera;
%control.mode = toggleCameraFly;
}
else
{
%control = %client.player;
%control.mode = observerFly;
}
%client.setControlObject(%control);
}
function serverCmdDropPlayerAtCamera(%client)
{
if ($Server::TestCheats || isObject(EditorGui))
{
%client.player.setTransform(%client.camera.getTransform());
%client.player.setVelocity("0 0 0");
%client.setControlObject(%client.player);
}
}
function serverCmdDropCameraAtPlayer(%client)
{
%client.camera.setTransform(%client.player.getEyeTransform());
%client.camera.setVelocity("0 0 0");
%client.setControlObject(%client.camera);
}
//-----------------------------------------------------------------------------
function serverCmdSuicide(%client)
{
if (isObject(%client.player))
%client.player.kill("Suicide");
}
function serverCmdPlayCel(%client,%anim)
{
if (isObject(%client.player))
%client.player.playCelAnimation(%anim);
}
function serverCmdPlayDeath(%client)
{
if (isObject(%client.player))
%client.player.playDeathAnimation();
}

Binary file not shown.

View File

@ -0,0 +1,941 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Crossbow weapon. This file contains all the items related to this weapon
// including explosions, ammo, the item and the weapon item image.
// These objects rely on the item & inventory support system defined
// in item.cs and inventory.cs
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Sounds profiles
datablock AudioProfile(CrossbowReloadSound)
{
filename = "~/data/sound/crossbow_reload.ogg";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(CrossbowFireSound)
{
filename = "~/data/sound/crossbow_firing.ogg";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(CrossbowFireEmptySound)
{
filename = "~/data/sound/crossbow_firing_empty.ogg";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(CrossbowExplosionSound)
{
filename = "~/data/sound/crossbow_explosion.ogg";
description = AudioDefault3d;
preload = true;
};
//-----------------------------------------------------------------------------
// Crossbow bolt projectile splash
datablock ParticleData(CrossbowSplashMist)
{
dragCoefficient = 2.0;
gravityCoefficient = -0.05;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 400;
lifetimeVarianceMS = 100;
useInvAlpha = false;
spinRandomMin = -90.0;
spinRandomMax = 500.0;
textureName = "~/data/shapes/crossbow/splash";
colors[0] = "0.7 0.8 1.0 1.0";
colors[1] = "0.7 0.8 1.0 0.5";
colors[2] = "0.7 0.8 1.0 0.0";
sizes[0] = 0.5;
sizes[1] = 0.5;
sizes[2] = 0.8;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(CrossbowSplashMistEmitter)
{
ejectionPeriodMS = 5;
periodVarianceMS = 0;
ejectionVelocity = 3.0;
velocityVariance = 2.0;
ejectionOffset = 0.0;
thetaMin = 85;
thetaMax = 85;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
lifetimeMS = 250;
particles = "CrossbowSplashMist";
};
datablock ParticleData( CrossbowSplashParticle )
{
dragCoefficient = 1;
gravityCoefficient = 0.2;
inheritedVelFactor = 0.2;
constantAcceleration = -0.0;
lifetimeMS = 600;
lifetimeVarianceMS = 0;
colors[0] = "0.7 0.8 1.0 1.0";
colors[1] = "0.7 0.8 1.0 0.5";
colors[2] = "0.7 0.8 1.0 0.0";
sizes[0] = 0.5;
sizes[1] = 0.5;
sizes[2] = 0.5;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData( CrossbowSplashEmitter )
{
ejectionPeriodMS = 1;
periodVarianceMS = 0;
ejectionVelocity = 3;
velocityVariance = 1.0;
ejectionOffset = 0.0;
thetaMin = 60;
thetaMax = 80;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
orientParticles = true;
lifetimeMS = 100;
particles = "CrossbowSplashParticle";
};
datablock SplashData(CrossbowSplash)
{
numSegments = 15;
ejectionFreq = 15;
ejectionAngle = 40;
ringLifetime = 0.5;
lifetimeMS = 300;
velocity = 4.0;
startRadius = 0.0;
acceleration = -3.0;
texWrap = 5.0;
texture = "~/data/shapes/crossbow/splash";
emitter[0] = CrossbowSplashEmitter;
emitter[1] = CrossbowSplashMistEmitter;
colors[0] = "0.7 0.8 1.0 0.0";
colors[1] = "0.7 0.8 1.0 0.3";
colors[2] = "0.7 0.8 1.0 0.7";
colors[3] = "0.7 0.8 1.0 0.0";
times[0] = 0.0;
times[1] = 0.4;
times[2] = 0.8;
times[3] = 1.0;
};
//-----------------------------------------------------------------------------
// Crossbow bolt projectile particles
datablock ParticleData(CrossbowBoltParticle)
{
textureName = "~/data/shapes/particles/smoke";
dragCoefficient = 0.0;
gravityCoefficient = -0.1; // rises slowly
inheritedVelFactor = 0.0;
lifetimeMS = 150;
lifetimeVarianceMS = 10; // ...more or less
useInvAlpha = false;
spinRandomMin = -30.0;
spinRandomMax = 30.0;
colors[0] = "0.1 0.1 0.1 1.0";
colors[1] = "0.1 0.1 0.1 1.0";
colors[2] = "0.1 0.1 0.1 0";
sizes[0] = 0.15;
sizes[1] = 0.20;
sizes[2] = 0.25;
times[0] = 0.0;
times[1] = 0.3;
times[2] = 1.0;
};
datablock ParticleData(CrossbowBubbleParticle)
{
textureName = "~/data/shapes/particles/bubble";
dragCoefficient = 0.0;
gravityCoefficient = -0.25; // rises slowly
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 1500;
lifetimeVarianceMS = 600; // ...more or less
useInvAlpha = false;
spinRandomMin = -100.0;
spinRandomMax = 100.0;
colors[0] = "0.7 0.8 1.0 0.4";
colors[1] = "0.7 0.8 1.0 1.0";
colors[2] = "0.7 0.8 1.0 0.0";
sizes[0] = 0.2;
sizes[1] = 0.2;
sizes[2] = 0.2;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(CrossbowBoltEmitter)
{
ejectionPeriodMS = 2;
periodVarianceMS = 0;
ejectionVelocity = 0.0;
velocityVariance = 0.0;
thetaMin = 0.0;
thetaMax = 90.0;
particles = CrossbowBoltParticle;
};
datablock ParticleEmitterData(CrossbowBoltBubbleEmitter)
{
ejectionPeriodMS = 9;
periodVarianceMS = 0;
ejectionVelocity = 1.0;
ejectionOffset = 0.1;
velocityVariance = 0.5;
thetaMin = 0.0;
thetaMax = 80.0;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvances = false;
particles = CrossbowBubbleParticle;
};
//-----------------------------------------------------------------------------
// Explosion Debris
// Debris "spark" explosion
datablock ParticleData(CrossbowDebrisSpark)
{
textureName = "~/data/shapes/particles/fire";
dragCoefficient = 0;
gravityCoefficient = 0.0;
windCoefficient = 0;
inheritedVelFactor = 0.5;
constantAcceleration = 0.0;
lifetimeMS = 500;
lifetimeVarianceMS = 50;
spinRandomMin = -90.0;
spinRandomMax = 90.0;
useInvAlpha = false;
colors[0] = "0.8 0.2 0 1.0";
colors[1] = "0.8 0.2 0 1.0";
colors[2] = "0 0 0 0.0";
sizes[0] = 0.2;
sizes[1] = 0.3;
sizes[2] = 0.1;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(CrossbowDebrisSparkEmitter)
{
ejectionPeriodMS = 20;
periodVarianceMS = 0;
ejectionVelocity = 0.5;
velocityVariance = 0.25;
ejectionOffset = 0.0;
thetaMin = 0;
thetaMax = 90;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvances = false;
orientParticles = false;
lifetimeMS = 300;
particles = "CrossbowDebrisSpark";
};
datablock ExplosionData(CrossbowDebrisExplosion)
{
emitter[0] = CrossbowDebrisSparkEmitter;
// Turned off..
shakeCamera = false;
impulseRadius = 0;
lightStartRadius = 0;
lightEndRadius = 0;
};
// Debris smoke trail
datablock ParticleData(CrossbowDebrisTrail)
{
textureName = "~/data/shapes/particles/fire";
dragCoefficient = 1;
gravityCoefficient = 0;
inheritedVelFactor = 0;
windCoefficient = 0;
constantAcceleration = 0;
lifetimeMS = 800;
lifetimeVarianceMS = 100;
spinSpeed = 0;
spinRandomMin = -90.0;
spinRandomMax = 90.0;
useInvAlpha = true;
colors[0] = "0.8 0.3 0.0 1.0";
colors[1] = "0.1 0.1 0.1 0.7";
colors[2] = "0.1 0.1 0.1 0.0";
sizes[0] = 0.2;
sizes[1] = 0.3;
sizes[2] = 0.4;
times[0] = 0.1;
times[1] = 0.2;
times[2] = 1.0;
};
datablock ParticleEmitterData(CrossbowDebrisTrailEmitter)
{
ejectionPeriodMS = 30;
periodVarianceMS = 0;
ejectionVelocity = 0.0;
velocityVariance = 0.0;
ejectionOffset = 0.0;
thetaMin = 170;
thetaMax = 180;
phiReferenceVel = 0;
phiVariance = 360;
//overrideAdvances = false;
//orientParticles = true;
lifetimeMS = 5000;
particles = "CrossbowDebrisTrail";
};
// Debris object
datablock DebrisData(CrossbowExplosionDebris)
{
shapeFile = "~/data/shapes/crossbow/debris.dts";
emitters = "CrossbowDebrisTrailEmitter";
explosion = CrossbowDebrisExplosion;
elasticity = 0.6;
friction = 0.5;
numBounces = 1;
bounceVariance = 1;
explodeOnMaxBounce = true;
staticOnMaxBounce = false;
snapOnMaxBounce = false;
minSpinSpeed = 0;
maxSpinSpeed = 700;
render2D = false;
lifetime = 4;
lifetimeVariance = 0.4;
velocity = 5;
velocityVariance = 0.5;
fade = false;
useRadiusMass = true;
baseRadius = 0.3;
gravModifier = 0.5;
terminalVelocity = 6;
ignoreWater = true;
};
//-----------------------------------------------------------------------------
// Bolt Explosion
datablock ParticleData(CrossbowExplosionSmoke)
{
textureName = "~/data/shapes/particles/smoke";
dragCoeffiecient = 100.0;
gravityCoefficient = 0;
inheritedVelFactor = 0.25;
constantAcceleration = -0.30;
lifetimeMS = 1200;
lifetimeVarianceMS = 300;
useInvAlpha = true;
spinRandomMin = -80.0;
spinRandomMax = 80.0;
colors[0] = "0.56 0.36 0.26 1.0";
colors[1] = "0.2 0.2 0.2 1.0";
colors[2] = "0.0 0.0 0.0 0.0";
sizes[0] = 4.0;
sizes[1] = 2.5;
sizes[2] = 1.0;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleData(CrossbowExplosionBubble)
{
textureName = "~/data/shapes/particles/bubble";
dragCoeffiecient = 0.0;
gravityCoefficient = -0.25;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 1500;
lifetimeVarianceMS = 600;
useInvAlpha = false;
spinRandomMin = -100.0;
spinRandomMax = 100.0;
colors[0] = "0.7 0.8 1.0 0.4";
colors[1] = "0.7 0.8 1.0 0.4";
colors[2] = "0.7 0.8 1.0 0.0";
sizes[0] = 0.3;
sizes[1] = 0.3;
sizes[2] = 0.3;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(CrossbowExplosionSmokeEmitter)
{
ejectionPeriodMS = 10;
periodVarianceMS = 0;
ejectionVelocity = 4;
velocityVariance = 0.5;
thetaMin = 0.0;
thetaMax = 180.0;
lifetimeMS = 250;
particles = "CrossbowExplosionSmoke";
};
datablock ParticleEmitterData(CrossbowExplosionBubbleEmitter)
{
ejectionPeriodMS = 9;
periodVarianceMS = 0;
ejectionVelocity = 1;
ejectionOffset = 0.1;
velocityVariance = 0.5;
thetaMin = 0.0;
thetaMax = 80.0;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvances = false;
particles = "CrossbowExplosionBubble";
};
datablock ParticleData(CrossbowExplosionFire)
{
textureName = "~/data/shapes/particles/fire";
dragCoeffiecient = 100.0;
gravityCoefficient = 0;
inheritedVelFactor = 0.25;
constantAcceleration = 0.1;
lifetimeMS = 1200;
lifetimeVarianceMS = 300;
useInvAlpha = false;
spinRandomMin = -80.0;
spinRandomMax = 80.0;
colors[0] = "0.8 0.4 0 0.8";
colors[1] = "0.2 0.0 0 0.8";
colors[2] = "0.0 0.0 0.0 0.0";
sizes[0] = 1.5;
sizes[1] = 0.9;
sizes[2] = 0.5;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(CrossbowExplosionFireEmitter)
{
ejectionPeriodMS = 10;
periodVarianceMS = 0;
ejectionVelocity = 0.8;
velocityVariance = 0.5;
thetaMin = 0.0;
thetaMax = 180.0;
lifetimeMS = 250;
particles = "CrossbowExplosionFire";
};
datablock ParticleData(CrossbowExplosionSparks)
{
textureName = "~/data/shapes/particles/spark";
dragCoefficient = 1;
gravityCoefficient = 0.0;
inheritedVelFactor = 0.2;
constantAcceleration = 0.0;
lifetimeMS = 500;
lifetimeVarianceMS = 350;
colors[0] = "0.60 0.40 0.30 1.0";
colors[1] = "0.60 0.40 0.30 1.0";
colors[2] = "1.0 0.40 0.30 0.0";
sizes[0] = 0.25;
sizes[1] = 0.15;
sizes[2] = 0.15;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleData(CrossbowExplosionWaterSparks)
{
textureName = "~/data/shapes/particles/bubble";
dragCoefficient = 0;
gravityCoefficient = 0.0;
inheritedVelFactor = 0.2;
constantAcceleration = 0.0;
lifetimeMS = 500;
lifetimeVarianceMS = 350;
colors[0] = "0.4 0.4 1.0 1.0";
colors[1] = "0.4 0.4 1.0 1.0";
colors[2] = "0.4 0.4 1.0 0.0";
sizes[0] = 0.5;
sizes[1] = 0.5;
sizes[2] = 0.5;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(CrossbowExplosionSparkEmitter)
{
ejectionPeriodMS = 3;
periodVarianceMS = 0;
ejectionVelocity = 5;
velocityVariance = 1;
ejectionOffset = 0.0;
thetaMin = 0;
thetaMax = 180;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvances = false;
orientParticles = true;
lifetimeMS = 100;
particles = "CrossbowExplosionSparks";
};
datablock ParticleEmitterData(CrossbowExplosionWaterSparkEmitter)
{
ejectionPeriodMS = 3;
periodVarianceMS = 0;
ejectionVelocity = 4;
velocityVariance = 4;
ejectionOffset = 0.0;
thetaMin = 0;
thetaMax = 60;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvances = false;
orientParticles = true;
lifetimeMS = 200;
particles = "CrossbowExplosionWaterSparks";
};
datablock ExplosionData(CrossbowSubExplosion1)
{
offset = 0;
emitter[0] = CrossbowExplosionSmokeEmitter;
emitter[1] = CrossbowExplosionSparkEmitter;
};
datablock ExplosionData(CrossbowSubExplosion2)
{
offset = 1.0;
emitter[0] = CrossbowExplosionSmokeEmitter;
emitter[1] = CrossbowExplosionSparkEmitter;
};
datablock ExplosionData(CrossbowSubWaterExplosion1)
{
delayMS = 100;
offset = 1.2;
playSpeed = 1.5;
emitter[0] = CrossbowExplosionBubbleEmitter;
emitter[1] = CrossbowExplosionWaterSparkEmitter;
sizes[0] = "0.75 0.75 0.75";
sizes[1] = "1.0 1.0 1.0";
sizes[2] = "0.5 0.5 0.5";
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ExplosionData(CrossbowSubWaterExplosion2)
{
delayMS = 50;
offset = 1.2;
playSpeed = 0.75;
emitter[0] = CrossbowExplosionBubbleEmitter;
emitter[1] = CrossbowExplosionWaterSparkEmitter;
sizes[0] = "1.5 1.5 1.5";
sizes[1] = "1.5 1.5 1.5";
sizes[2] = "1.0 1.0 1.0";
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ExplosionData(CrossbowExplosion)
{
soundProfile = CrossbowExplosionSound;
lifeTimeMS = 1200;
// Volume particles
particleEmitter = CrossbowExplosionFireEmitter;
particleDensity = 75;
particleRadius = 2;
// Point emission
emitter[0] = CrossbowExplosionSmokeEmitter;
emitter[1] = CrossbowExplosionSparkEmitter;
// Sub explosion objects
subExplosion[0] = CrossbowSubExplosion1;
subExplosion[1] = CrossbowSubExplosion2;
// Camera Shaking
shakeCamera = true;
camShakeFreq = "10.0 11.0 10.0";
camShakeAmp = "1.0 1.0 1.0";
camShakeDuration = 0.5;
camShakeRadius = 10.0;
// Exploding debris
debris = CrossbowExplosionDebris;
debrisThetaMin = 0;
debrisThetaMax = 60;
debrisPhiMin = 0;
debrisPhiMax = 360;
debrisNum = 6;
debrisNumVariance = 2;
debrisVelocity = 1;
debrisVelocityVariance = 0.5;
// Impulse
impulseRadius = 10;
impulseForce = 15;
// Dynamic light
lightStartRadius = 6;
lightEndRadius = 3;
lightStartColor = "0.5 0.5 0";
lightEndColor = "0 0 0";
};
datablock ExplosionData(CrossbowWaterExplosion)
{
soundProfile = CrossbowExplosionSound;
// Volume particles
particleEmitter = CrossbowExplosionBubbleEmitter;
particleDensity = 375;
particleRadius = 2;
// Point emission
emitter[0] = CrossbowExplosionBubbleEmitter;
emitter[1] = CrossbowExplosionWaterSparkEmitter;
// Sub explosion objects
subExplosion[0] = CrossbowSubWaterExplosion1;
subExplosion[1] = CrossbowSubWaterExplosion2;
// Camera Shaking
shakeCamera = true;
camShakeFreq = "8.0 9.0 7.0";
camShakeAmp = "3.0 3.0 3.0";
camShakeDuration = 1.3;
camShakeRadius = 20.0;
// Exploding debris
debris = CrossbowExplosionDebris;
debrisThetaMin = 0;
debrisThetaMax = 60;
debrisPhiMin = 0;
debrisPhiMax = 360;
debrisNum = 6;
debrisNumVariance = 2;
debrisVelocity = 0.5;
debrisVelocityVariance = 0.2;
// Impulse
impulseRadius = 10;
impulseForce = 15;
// Dynamic light
lightStartRadius = 6;
lightEndRadius = 3;
lightStartColor = "0 0.5 0.5";
lightEndColor = "0 0 0";
};
//-----------------------------------------------------------------------------
// Projectile Object
datablock ProjectileData(CrossbowProjectile)
{
projectileShapeName = "~/data/shapes/crossbow/projectile.dts";
directDamage = 20;
radiusDamage = 20;
damageRadius = 1.5;
areaImpulse = 2000;
explosion = CrossbowExplosion;
waterExplosion = CrossbowWaterExplosion;
particleEmitter = CrossbowBoltEmitter;
particleWaterEmitter= CrossbowBoltBubbleEmitter;
splash = CrossbowSplash;
muzzleVelocity = 100;
velInheritFactor = 0.3;
armingDelay = 0;
lifetime = 5000;
fadeDelay = 5000;
bounceElasticity = 0;
bounceFriction = 0;
isBallistic = false;
gravityMod = 0.80;
hasLight = true;
lightRadius = 4;
lightColor = "0.5 0.5 0.25";
hasWaterLight = true;
waterLightColor = "0 0.5 0.5";
};
function CrossbowProjectile::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
// Apply damage to the object all shape base objects
if (%col.getType() & $TypeMasks::ShapeBaseObjectType)
%col.damage(%obj,%pos,%this.directDamage,"CrossbowBolt");
// Radius damage is a support scripts defined in radiusDamage.cs
// Push the contact point away from the contact surface slightly
// along the contact normal to derive the explosion center. -dbs
radiusDamage(%obj, %pos, %this.damageRadius, %this.radiusDamage, "Radius", %this.areaImpulse);
}
//-----------------------------------------------------------------------------
// Ammo Item
datablock ItemData(CrossbowAmmo)
{
// Mission editor category
category = "Ammo";
// Add the Ammo namespace as a parent. The ammo namespace provides
// common ammo related functions and hooks into the inventory system.
className = "Ammo";
// Basic Item properties
shapeFile = "~/data/shapes/crossbow/ammo.dts";
mass = 1;
elasticity = 0.2;
friction = 0.6;
// Dynamic properties defined by the scripts
pickUpName = "crossbow bolts";
maxInventory = 20;
};
//--------------------------------------------------------------------------
// Weapon Item. This is the item that exists in the world, i.e. when it's
// been dropped, thrown or is acting as re-spawnable item. When the weapon
// is mounted onto a shape, the CrossbowImage is used.
datablock ItemData(Crossbow)
{
// Mission editor category
category = "Weapon";
// Hook into Item Weapon class hierarchy. The weapon namespace
// provides common weapon handling functions in addition to hooks
// into the inventory system.
className = "Weapon";
// Basic Item properties
shapeFile = "~/data/shapes/crossbow/weapon.dts";
mass = 1;
elasticity = 0.2;
friction = 0.6;
emap = true;
// Dynamic properties defined by the scripts
pickUpName = "a crossbow";
image = CrossbowImage;
};
//--------------------------------------------------------------------------
// Crossbow image which does all the work. Images do not normally exist in
// the world, they can only be mounted on ShapeBase objects.
datablock ShapeBaseImageData(CrossbowImage)
{
// Basic Item properties
shapeFile = "~/data/shapes/crossbow/weapon.dts";
emap = true;
// Specify mount point & offset for 3rd person, and eye offset
// for first person rendering.
mountPoint = 0;
eyeOffset = "0.1 0.4 -0.6";
// When firing from a point offset from the eye, muzzle correction
// will adjust the muzzle vector to point to the eye LOS point.
// Since this weapon doesn't actually fire from the muzzle point,
// we need to turn this off.
correctMuzzleVector = false;
// Add the WeaponImage namespace as a parent, WeaponImage namespace
// provides some hooks into the inventory system.
className = "WeaponImage";
// Projectile && Ammo.
item = Crossbow;
ammo = CrossbowAmmo;
projectile = CrossbowProjectile;
projectileType = Projectile;
// Images have a state system which controls how the animations
// are run, which sounds are played, script callbacks, etc. This
// state system is downloaded to the client so that clients can
// predict state changes and animate accordingly. The following
// system supports basic ready->fire->reload transitions as
// well as a no-ammo->dryfire idle state.
// Initial start up state
stateName[0] = "Preactivate";
stateTransitionOnLoaded[0] = "Activate";
stateTransitionOnNoAmmo[0] = "NoAmmo";
// Activating the gun. Called when the weapon is first
// mounted and there is ammo.
stateName[1] = "Activate";
stateTransitionOnTimeout[1] = "Ready";
stateTimeoutValue[1] = 0.6;
stateSequence[1] = "Activate";
// Ready to fire, just waiting for the trigger
stateName[2] = "Ready";
stateTransitionOnNoAmmo[2] = "NoAmmo";
stateTransitionOnTriggerDown[2] = "Fire";
// Fire the weapon. Calls the fire script which does
// the actual work.
stateName[3] = "Fire";
stateTransitionOnTimeout[3] = "Reload";
stateTimeoutValue[3] = 0.2;
stateFire[3] = true;
stateRecoil[3] = LightRecoil;
stateAllowImageChange[3] = false;
stateSequence[3] = "Fire";
stateScript[3] = "onFire";
stateSound[3] = CrossbowFireSound;
// Play the relead animation, and transition into
stateName[4] = "Reload";
stateTransitionOnNoAmmo[4] = "NoAmmo";
stateTransitionOnTimeout[4] = "Ready";
stateTimeoutValue[4] = 0.8;
stateAllowImageChange[4] = false;
stateSequence[4] = "Reload";
stateEjectShell[4] = true;
stateSound[4] = CrossbowReloadSound;
// No ammo in the weapon, just idle until something
// shows up. Play the dry fire sound if the trigger is
// pulled.
stateName[5] = "NoAmmo";
stateTransitionOnAmmo[5] = "Reload";
stateSequence[5] = "NoAmmo";
stateTransitionOnTriggerDown[5] = "DryFire";
// No ammo dry fire
stateName[6] = "DryFire";
stateTimeoutValue[6] = 1.0;
stateTransitionOnTimeout[6] = "NoAmmo";
stateSound[6] = CrossbowFireEmptySound;
};
//-----------------------------------------------------------------------------
function CrossbowImage::onFire(%this, %obj, %slot)
{
%projectile = %this.projectile;
// Decrement inventory ammo. The image's ammo state is update
// automatically by the ammo inventory hooks.
%obj.decInventory(%this.ammo,1);
// Determin initial projectile velocity based on the
// gun's muzzle point and the object's current velocity
%muzzleVector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%muzzleVelocity = VectorAdd(
VectorScale(%muzzleVector, %projectile.muzzleVelocity),
VectorScale(%objectVelocity, %projectile.velInheritFactor));
// Create the projectile object
%p = new (%this.projectileType)() {
dataBlock = %projectile;
initialVelocity = %muzzleVelocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
return %p;
}

Binary file not shown.

View File

@ -0,0 +1,104 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
//Env Pack: Heavy Rain Datablock
// Look to starter.fps for proper scripting blocks, these are demo specific
//datablock AudioProfile(HeavyRainSound)
//{
// filename = "~/data/sound/amb.ogg";
// description = AudioLooping2d;
//};
datablock PrecipitationData(HeavyRain2)
{
dropTexture = "~/data/environment/mist";
splashTexture = "~/data/environment/mist2";
dropSize = 10;
splashSize = 0.1;
useTrueBillboards = false;
splashMS = 250;
};
datablock PrecipitationData(HeavyRain3)
{
dropTexture = "~/data/environment/shine";
splashTexture = "~/data/environment/mist2";
dropSize = 20;
splashSize = 0.1;
useTrueBillboards = false;
splashMS = 250;
};
datablock PrecipitationData(HeavyRain)
{
//soundProfile = "HeavyRainSound";
dropTexture = "~/data/environment/rain";
splashTexture = "~/data/environment/water_splash";
dropSize = 0.35;
splashSize = 0.1;
useTrueBillboards = false;
splashMS = 500;
};
//-----------------------------------------------------------------------------
datablock AudioProfile(ThunderCrash1Sound)
{
filename = "~/data/sound/environment/ambient/thunder1.ogg";
description = Audio2d;
};
datablock AudioProfile(ThunderCrash2Sound)
{
filename = "~/data/sound/environment/ambient/thunder2.ogg";
description = Audio2d;
};
datablock AudioProfile(ThunderCrash3Sound)
{
filename = "~/data/sound/environment/ambient/thunder3.ogg";
description = Audio2d;
};
datablock AudioProfile(ThunderCrash4Sound)
{
filename = "~/data/sound/environment/ambient/thunder4.ogg";
description = Audio2d;
};
//datablock AudioProfile(LightningHitSound)
//{
// filename = "~/data/sound/crossbow_explosion.ogg";
// description = AudioLightning3d;
//};
datablock LightningData(LightningStorm)
{
strikeTextures[0] = "demo/data/environment/lightning1frame1";
strikeTextures[1] = "demo/data/environment/lightning1frame2";
strikeTextures[2] = "demo/data/environment/lightning1frame3";
//strikeSound = LightningHitSound;
thunderSounds[0] = ThunderCrash1Sound;
thunderSounds[1] = ThunderCrash2Sound;
thunderSounds[2] = ThunderCrash3Sound;
thunderSounds[3] = ThunderCrash4Sound;
};
datablock PrecipitationData(Leaves)
{
//soundProfile = "Blackforest";
dropTexture = "~/data/environment/leaves";
//splashTexture = "~/data/environment/deathrain_splash";
dropSize = 0.35;
splashSize = 0.1;
useTrueBillboards = false;
splashMS = 500;
};

Binary file not shown.

View File

@ -0,0 +1,19 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
datablock StaticShapeData(FlagPole)
{
category = "Demo";
shapeFile = "~/data/shapes/objects/flagpole.dts";
};
datablock ShapeBaseImageData(FlagPoleImage)
{
shapeFile = "~/data/shapes/objects/flagpole.dts";
mountPoint = 1;
offset = "0 0 -1";
emap = false;
};

Binary file not shown.

View File

@ -0,0 +1,212 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Hook into the mission editor.
function fxLightData::create(%data)
{
// The mission editor invokes this method when it wants to create
// an object of the given datablock type.
%obj = new fxLight() {
dataBlock = %data;
};
return %obj;
}
//-----------------------------------------------------------------------------
datablock fxLightData(LightHalo)
{
category = "fxLights";
// Dynamic light
LightOn = false;
Radius = 1.0;
Brightness = 1.0;
Colour = "1 1 1";
// Flare effect
FlareOn = true;
FlareTP = true;
FlareBitmap = "common/lighting/corona";
FlareColour = "1 1 0.5";
ConstantSizeOn = false;
ConstantSize = 0.2;
NearSize = 1.2;
FarSize = 0.2;
NearDistance = 10.0;
FarDistance = 30.0;
FadeTime = 0.1;
BlendMode = 0;
LinkFlare = true;
LinkFlareSize = false;
// Brightness animation
AnimBrightness = true;
MinBrightness = 0.8;
MaxBrightness = 1.0;
BrightnessTime = 0.2;
LerpBrightness = true;
BrightnessKeys = "AZA";
// Color animation
AnimColour = false;
MinColour = "0 0 0";
MaxColour = "1 1 1";
ColourTime = 1.0;
LerpColour = true;
SingleColourKeys = true;
RedKeys = "AZA";
GreenKeys = "AZA";
BlueKeys = "AZA";
// Radius animation
AnimRadius = false;
MinRadius = 0.1;
MaxRadius = 20.0;
RadiusTime = 5.0;
LerpRadius = true;
RadiusKeys = "AZA";
// Offset animation
AnimOffset = false;
StartOffset = "-5 0 0";
EndOffset = "5 0 0";
OffsetTime = 5.0;
LerpOffset = true;
OffsetKeys = "AZA";
// Rotation animation
AnimRotation = false;
MinRotation = 0;
MaxRotation = 350;
RotationTime = 5.0;
LerpRotation = true;
RotationKeys = "AZA";
};
//-----------------------------------------------------------------------------
datablock fxLightData(FlameLight)
{
category = "fxLights";
// Dynamic light
LightOn = true;
Radius = 3.0;
Brightness = 1.0;
Colour = "1 1 0.5";
// Flare effect
FlareOn = true;
FlareTP = true;
FlareBitmap = "common/lighting/corona";
FlareColour = "1 1 0.5";
ConstantSizeOn = false;
ConstantSize = 0.2;
NearSize = 0.5;
FarSize = 0.2;
NearDistance = 10.0;
FarDistance = 30.0;
FadeTime = 0.1;
BlendMode = 0;
LinkFlare = true;
LinkFlareSize = false;
// Brightness animation
AnimBrightness = true;
MinBrightness = 0.8;
MaxBrightness = 1.0;
BrightnessTime = 0.2;
LerpBrightness = true;
BrightnessKeys = "AZA";
// Color animation
AnimColour = false;
MinColour = "0 0 0";
MaxColour = "1 1 1";
ColourTime = 1.0;
LerpColour = true;
SingleColourKeys = true;
RedKeys = "AZA";
GreenKeys = "AZA";
BlueKeys = "AZA";
// Radius animation
AnimRadius = false;
MinRadius = 0.1;
MaxRadius = 20.0;
RadiusTime = 5.0;
LerpRadius = true;
RadiusKeys = "AZA";
// Offset animation
AnimOffset = false;
StartOffset = "-5 0 0";
EndOffset = "5 0 0";
OffsetTime = 5.0;
LerpOffset = true;
OffsetKeys = "AZA";
// Rotation animation
AnimRotation = false;
MinRotation = 0;
MaxRotation = 350;
RotationTime = 5.0;
LerpRotation = true;
RotationKeys = "AZA";
};
//-----------------------------------------------------------------------------
datablock ParticleData(FlameSmoke)
{
textureName = "~/data/shapes/particles/smoke";
dragCoefficient = 0.0;
gravityCoefficient = -0.2; // rises slowly
windCoefficient = 0;
inheritedVelFactor = 0.00;
lifetimeMS = 2000;
lifetimeVarianceMS = 250;
useInvAlpha = false;
spinRandomMin = -30.0;
spinRandomMax = 30.0;
colors[0] = "0.6 0.6 0.6 0.1";
colors[1] = "0.6 0.6 0.6 0.1";
colors[2] = "0.6 0.6 0.6 0.0";
sizes[0] = 0.25;
sizes[1] = 0.5;
sizes[2] = 1.0;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1;
};
datablock ParticleEmitterData(FlameSmokeEmitter)
{
ejectionPeriodMS = 40;
periodVarianceMS = 5;
ejectionVelocity = 0.25;
velocityVariance = 0.10;
thetaMin = 0.0;
thetaMax = 90.0;
particles = FlameSmoke;
};
datablock ParticleEmitterNodeData(FlameSmokeEmitterNode)
{
timeMultiple = 1;
};

Binary file not shown.

View File

@ -0,0 +1,407 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
// Game duration in secs, no limit if the duration is set to 0
$Game::Duration = 20 * 60;
// When a client score reaches this value, the game is ended.
$Game::EndGameScore = 30;
// Pause while looking over the end game screen (in secs)
$Game::EndGamePause = 10;
$BlockSave = 0;
//-----------------------------------------------------------------------------
// Functions that implement game-play
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function onServerCreated()
{
// Server::GameType is sent to the master server.
// This variable should uniquely identify your game and/or mod.
$Server::GameType = "TGE Demo";
// Server::MissionType sent to the master server. Clients can
// filter servers based on mission type.
$Server::MissionType = "Demo Match";
// GameStartTime is the sim time the game started. Used to calculated
// game elapsed time.
$Game::StartTime = 0;
// Load up basic datablocks, objects etc.
exec("./audioProfiles.cs");
exec("./camera.cs");
exec("./markers.cs");
exec("./triggers.cs");
exec("./inventory.cs");
exec("./shapeBase.cs");
exec("./staticShape.cs");
exec("./rigidShape.cs");
exec("./radiusDamage.cs");
exec("./chimneyfire.cs");
exec("./item.cs");
exec("./weapon.cs");
exec("./flag.cs");
exec("common/server/lightingSystem.cs");
// Room demo...
exec("./scene.cs");
exec("./fxlights.cs");
exec("./environment.cs");
// Fps game...
//exec("./fps.cs");
exec("./player.cs");
exec("./aiPlayer.cs");
exec("./crossbow.cs");
// Racing game...
//exec("./racing.cs");
//exec("./car.cs");
// Keep track of when the game started
$Game::StartTime = $Sim::Time;
}
function onServerDestroyed()
{
// This function is called as part of a server shutdown.
}
//-----------------------------------------------------------------------------
function onMissionLoaded()
{
// Called by loadMission() once the mission is finished loading.
// Nothing special for now, just start up the game play.
// Determin what type of game play we have and activate the
// associated package.
echo("Mission Type: " @ MissionInfo.type);
activatePackage(MissionInfo.type @ "Game");
// Override the default game type
$Server::GameType = MissionInfo.type;
$Server::MissionType = "Play";
$Game::Duration = 0;
if (MissionInfo.type $= "DemoScene") $BlockSave = 1;
else $BlockSave = 0;
// Start game play, this doesn't wait players...
startGame();
}
function onMissionEnded()
{
// Called by endMission(), right before the mission is destroyed
// Normally the game should be ended first before the next
// mission is loaded, this is here in case loadMission has been
// called directly. The mission will be ended if the server
// is destroyed, so we only need to cleanup here.
deactivatePackage($Server::GameType @ "Game");
cancel($Game::Schedule);
$Game::Running = false;
$Game::Cycling = false;
}
//-----------------------------------------------------------------------------
function startGame()
{
// Start up the game. Normally only called once ater a mission is loaded,
// but theoretically a game can be stopped and restarted without reloading
// the mission.
if ($Game::Running) {
error("startGame: End the game first!");
return;
}
// Inform the client we're starting up
for( %clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++ ) {
%cl = ClientGroup.getObject( %clientIndex );
commandToClient(%cl, 'GameStart');
// Other client specific setup..
%cl.score = 0;
}
// Start the game timer
if ($Game::Duration)
$Game::Schedule = schedule($Game::Duration * 1000, 0, "onGameDurationEnd" );
$Game::Running = true;
}
function endGame()
{
// Game specific cleanup...
if (!$Game::Running) {
error("endGame: No game running!");
return;
}
// Stop any game timers
cancel($Game::Schedule);
// Inform the client the game is over
for( %clientIndex = 0; %clientIndex < ClientGroup.getCount(); %clientIndex++ ) {
%cl = ClientGroup.getObject( %clientIndex );
commandToClient(%cl, 'GameEnd');
}
// Delete all the temporary mission objects
resetMission();
$Game::Running = false;
}
function onGameDurationEnd()
{
// This "redirect" is here so that we can abort the game cycle if
// the $Game::Duration variable has been cleared, without having
// to have a function to cancel the schedule.
if ($Game::Duration && !isObject(EditorGui))
cycleGame();
}
//-----------------------------------------------------------------------------
function cycleGame()
{
// This is setup as a schedule so that this function can be called
// directly from object callbacks. Object callbacks have to be
// carefull about invoking server functions that could cause
// their object to be deleted.
if (!$Game::Cycling) {
$Game::Cycling = true;
$Game::Schedule = schedule(0, 0, "onCycleExec");
}
}
function onCycleExec()
{
// End the current game and start another one, we'll pause for a little
// so the end game victory screen can be examined by the clients.
endGame();
$Game::Schedule = schedule($Game::EndGamePause * 1000, 0, "onCyclePauseEnd");
}
function onCyclePauseEnd()
{
$Game::Cycling = false;
// Just cycle through the missions for now.
%search = $Server::MissionFileSpec;
for (%file = findFirstFile(%search); %file !$= ""; %file = findNextFile(%search)) {
if (%file $= $Server::MissionFile) {
// Get the next one, back to the first if there
// is no next.
%file = findNextFile(%search);
if (%file $= "")
%file = findFirstFile(%search);
break;
}
}
loadMission(%file);
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function Game::onClientEnterGame(%this,%client)
{
// Player has joined the game, normally called when a
// new client has connected to the server.
}
function Game::onLeaveEnterGame(%this,%client)
{
// Player has left the game, normally called when a client
// disconnects from the server.
}
function Game::onDeath(%this,%player,%sourceObject, %sourceClient, %damageType, %damLoc)
{
// Invoked when a client has died.
}
function Game::onLeaveMissionArea(%this,%player)
{
// The control objects invoked this method when they
// move out of the mission area.
}
function Game::onEnterMissionArea(%this,%player)
{
// The control objects invoked this method when they
// move back into the mission area.
}
function Game::spawnPlayer(%this,%client)
{
// Create a new player for the client and drop him into the world.
}
function Game::createPlayer(%this, %client, %location)
{
// Create a new player for the client and start him at the
// given location.
}
//-----------------------------------------------------------------------------
// GameConnection Methods
// These methods are extensions to the GameConnection class. Extending
// GameConnection make is easier to deal with some of this functionality,
// but these could also be implemented as stand-alone functions.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function GameConnection::onClientEnterGame(%this)
{
commandToClient(%this, 'SyncClock', $Sim::Time - $Game::StartTime);
commandToClient(%this, 'SetGameGUI',"PlayGUI");
// Create a new camera object.
%this.camera = new Camera() {
dataBlock = Observer;
};
MissionCleanup.add( %this.camera );
%this.camera.scopeToClient(%this);
// Spawn the player
%this.score = 0;
%this.spawnPlayer();
}
function GameConnection::onClientLeaveGame(%this)
{
if (isObject(%this.camera))
%this.camera.delete();
if (isObject(%this.player))
%this.player.delete();
}
//-----------------------------------------------------------------------------
function GameConnection::onLeaveMissionArea(%this)
{
// The control objects invoked this method when they
// move out of the mission area.
}
function GameConnection::onEnterMissionArea(%this)
{
// The control objects invoked this method when they
// move back into the mission area.
}
//-----------------------------------------------------------------------------
function GameConnection::onDeath(%this, %sourceObject, %sourceClient, %damageType, %damLoc)
{
// Clear out the name on the corpse
%this.player.setShapeName("");
// Switch the client over to the death cam and unhook the player object.
if (isObject(%this.camera) && isObject(%this.player)) {
%this.camera.setMode("Corpse",%this.player);
%this.setControlObject(%this.camera);
}
%this.player = 0;
// Doll out points and display an appropriate message
if (%damageType $= "Suicide" || %sourceClient == %this) {
%this.incScore(-1);
messageAll('MsgClientKilled','%1 takes his own life!',%this.name);
}
else {
%sourceClient.incScore(1);
messageAll('MsgClientKilled','%1 gets nailed by %2!',%this.name,%sourceClient.name);
if (%sourceClient.score >= $Game::EndGameScore)
cycleGame();
}
}
//-----------------------------------------------------------------------------
function GameConnection::spawnPlayer(%this)
{
// Combination create player and drop him somewhere
%spawnPoint = pickSpawnPoint();
%this.createPlayer(%spawnPoint);
}
//-----------------------------------------------------------------------------
function GameConnection::createPlayer(%this, %spawnPoint)
{
if (%this.player > 0) {
// The client should not have a player currently
// assigned. Assigning a new one could result in
// a player ghost.
error( "Attempting to create an angus ghost!" );
}
// Create the player object
%player = new Player() {
dataBlock = PlayerBody;
client = %this;
};
MissionCleanup.add(%player);
// Player setup...
%player.setTransform(%spawnPoint);
%player.setEnergyLevel(60);
%player.setShapeName(%this.name);
// Update the camera to start with the player
%this.camera.setTransform(%player.getEyeTransform());
// Give the client control of the player
%this.player = %player;
%this.setControlObject(%player);
}
//-----------------------------------------------------------------------------
// Support functions
//-----------------------------------------------------------------------------
function pickSpawnPoint()
{
%groupName = "MissionGroup/PlayerDropPoints";
%group = nameToID(%groupName);
if (%group != -1) {
%count = %group.getCount();
if (%count != 0) {
%index = getRandom(%count-1);
%spawn = %group.getObject(%index);
return %spawn.getTransform();
}
else
error("No spawn points found in " @ %groupName);
}
else
error("Missing spawn points group " @ %groupName);
// Could be no spawn points, in which case we'll stick the
// player at the center of the world.
return "0 0 300 1 0 0 0";
}

Binary file not shown.

View File

@ -0,0 +1,256 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
// This inventory system is totally scripted, no C++ code involved.
// It uses object datablock names to track inventory and is generally
// object type, or class, agnostic. In other words, it will inventory
// any kind of ShapeBase object, though the throw method does assume
// that the objects are small enough to throw :)
//
// For a ShapeBase object to support inventory, it must have an array
// of inventory max values:
//
// %this.maxInv[GunAmmo] = 100;
// %this.maxInv[SpeedGun] = 1;
//
// where the names "SpeedGun" and "GunAmmo" are datablocks.
//
// For objects to be inventoriable, they must provide a set of inventory
// callback methods, mainly:
//
// onUse
// onThrow
// onPickup
//
// Example methods are given further down. The item.cs file also contains
// example inventory items.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Inventory server commands
//-----------------------------------------------------------------------------
function serverCmdUse(%client,%data)
{
%client.getControlObject().use(%data);
}
//-----------------------------------------------------------------------------
// ShapeBase inventory support
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function ShapeBase::use(%this,%data)
{
// Use an object in the inventory.
if (%this.getInventory(%data) > 0)
return %data.onUse(%this);
return false;
}
function ShapeBase::throw(%this,%data,%amount)
{
// Throw objects from inventory. The onThrow method is
// responsible for decrementing the inventory.
if (%this.getInventory(%data) > 0) {
%obj = %data.onThrow(%this,%amount);
if (%obj) {
%this.throwObject(%obj);
return true;
}
}
return false;
}
function ShapeBase::pickup(%this,%obj,%amount)
{
// This method is called to pickup an object and add it
// to the inventory. The datablock onPickup method is actually
// responsible for doing all the work, including incrementing
// the inventory.
%data = %obj.getDatablock();
// Try and pickup the max if no value was specified
if (%amount $= "")
%amount = %this.maxInventory(%data) - %this.getInventory(%data);
// The datablock does the work...
if (%amount < 0)
%amount = 0;
if (%amount)
return %data.onPickup(%obj,%this,%amount);
return false;
}
//-----------------------------------------------------------------------------
function ShapeBase::maxInventory(%this,%data)
{
// If there is no limit defined, we assume 0
return %this.getDatablock().maxInv[%data.getName()];
}
function ShapeBase::incInventory(%this,%data,%amount)
{
// Increment the inventory by the given amount. The return value
// is the amount actually added, which may be less than the
// requested amount due to inventory restrictions.
%max = %this.maxInventory(%data);
%total = %this.inv[%data.getName()];
if (%total < %max) {
if (%total + %amount > %max)
%amount = %max - %total;
%this.setInventory(%data,%total + %amount);
return %amount;
}
return 0;
}
function ShapeBase::decInventory(%this,%data,%amount)
{
// Decrement the inventory by the given amount. The return value
// is the amount actually removed.
%total = %this.inv[%data.getName()];
if (%total > 0) {
if (%total < %amount)
%amount = %total;
%this.setInventory(%data,%total - %amount);
return %amount;
}
return 0;
}
//-----------------------------------------------------------------------------
function ShapeBase::getInventory(%this,%data)
{
// Return the current inventory amount
return %this.inv[%data.getName()];
}
function ShapeBase::setInventory(%this,%data,%value)
{
// Set the inventory amount for this datablock and invoke
// inventory callbacks. All changes to inventory go through this
// single method.
// Impose inventory limits
if (%value < 0)
%value = 0;
else {
%max = %this.maxInventory(%data);
if (%value > %max)
%value = %max;
}
// Set the value and invoke object callbacks
%name = %data.getName();
if (%this.inv[%name] != %value)
{
%this.inv[%name] = %value;
%data.onInventory(%this,%value);
%this.getDataBlock().onInventory(%data,%value);
}
return %value;
}
//-----------------------------------------------------------------------------
function ShapeBase::clearInventory(%this)
{
// To be filled in...
}
//-----------------------------------------------------------------------------
function ShapeBase::throwObject(%this,%obj)
{
// Throw the given object in the direction the shape is looking.
// The force value is hardcoded according to the current default
// object mass and mission gravity (20m/s^2).
%throwForce = %this.throwForce;
if (!%throwForce)
%throwForce = 20;
// Start with the shape's eye vector...
%eye = %this.getEyeVector();
%vec = vectorScale(%eye, %throwForce);
// Add a vertical component to give the object a better arc
%verticalForce = %throwForce / 2;
%dot = vectorDot("0 0 1",%eye);
if (%dot < 0)
%dot = -%dot;
%vec = vectorAdd(%vec,vectorScale("0 0 " @ %verticalForce,1 - %dot));
// Add the shape's velocity
%vec = vectorAdd(%vec,%this.getVelocity());
// Set the object's position and initial velocity
%pos = getBoxCenter(%this.getWorldBox());
%obj.setTransform(%pos);
%obj.applyImpulse(%pos,%vec);
// Since the object is thrown from the center of the
// shape, the object needs to avoid colliding with it's
// thrower.
%obj.setCollisionTimeout(%this);
}
//-----------------------------------------------------------------------------
// Callback hooks invoked by the inventory system
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// ShapeBase object callbacks invoked by the inventory system
function ShapeBase::onInventory(%this, %data, %value)
{
// Invoked on ShapeBase objects whenever their inventory changes
// for the given datablock.
}
//-----------------------------------------------------------------------------
// ShapeBase datablock callback invoked by the inventory system.
function ShapeBaseData::onUse(%this,%user)
{
// Invoked when the object uses this datablock, should return
// true if the item was used.
return false;
}
function ShapeBaseData::onThrow(%this,%user,%amount)
{
// Invoked when the object is thrown. This method should
// construct and return the actual mission object to be
// physically thrown. This method is also responsible for
// decrementing the user's inventory.
return 0;
}
function ShapeBaseData::onPickup(%this,%obj,%user,%amount)
{
// Invoked when the user attempts to pickup this datablock object.
// The %amount argument is the space in the user's inventory for
// this type of datablock. This method is responsible for
// incrementing the user's inventory is something is addded.
// Should return true if something was added to the inventory.
return false;
}
function ShapeBaseData::onInventory(%this,%user,%value)
{
// Invoked whenever an user's inventory total changes for
// this datablock.
}

Binary file not shown.

View File

@ -0,0 +1,130 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
// These scripts make use of dynamic attribute values on Item datablocks,
// these are as follows:
//
// maxInventory Max inventory per object (100 bullets per box, etc.)
// pickupName Name to display when client pickups item
//
// Item objects can have:
//
// count The # of inventory items in the object. This
// defaults to maxInventory if not set.
// Respawntime is the amount of time it takes for a static "auto-respawn"
// object, such as an ammo box or weapon, to re-appear after it's been
// picked up. Any item marked as "static" is automaticlly respawned.
$Item::RespawnTime = 20 * 1000;
// Poptime represents how long dynamic items (those that are thrown or
// dropped) will last in the world before being deleted.
$Item::PopTime = 10 * 1000;
//-----------------------------------------------------------------------------
// ItemData base class methods used by all items
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function Item::respawn(%this)
{
// This method is used to respawn static ammo and weapon items
// and is usually called when the item is picked up.
// Instant fade...
%this.startFade(0, 0, true);
%this.setHidden(true);
// Shedule a reapearance
%this.schedule($Item::RespawnTime, "setHidden", false);
%this.schedule($Item::RespawnTime + 100, "startFade", 1000, 0, false);
}
function Item::schedulePop(%this)
{
// This method deletes the object after a default duration. Dynamic
// items such as thrown or drop weapons are usually popped to avoid
// world clutter.
%this.schedule($Item::PopTime - 1000, "startFade", 1000, 0, true);
%this.schedule($Item::PopTime, "delete");
}
//-----------------------------------------------------------------------------
// Callbacks to hook items into the inventory system
function ItemData::onThrow(%this,%user,%amount)
{
// Remove the object from the inventory
if (%amount $= "")
%amount = 1;
if (%this.maxInventory !$= "")
if (%amount > %this.maxInventory)
%amount = %this.maxInventory;
if (!%amount)
return 0;
%user.decInventory(%this,%amount);
// Construct the actual object in the world, and add it to
// the mission group so it's cleaned up when the mission is
// done. The object is given a random z rotation.
%obj = new Item() {
datablock = %this;
rotation = "0 0 1 " @ (getRandom() * 360);
count = %amount;
};
MissionGroup.add(%obj);
%obj.schedulePop();
return %obj;
}
function ItemData::onPickup(%this,%obj,%user,%amount)
{
// Add it to the inventory, this currently ignores the request
// amount, you get what you get. If the object doesn't have
// a count or the datablock doesn't have maxIventory set, the
// object cannot be picked up.
%count = %obj.count;
if (%count $= "")
if (%this.maxInventory !$= "") {
if (!(%count = %this.maxInventory))
return;
}
else
%count = 1;
%user.incInventory(%this,%count);
// Inform the client what they got.
if (%user.client)
messageClient(%user.client, 'MsgItemPickup', '\c0You picked up %1', %this.pickupName);
// If the item is a static respawn item, then go ahead and
// respawn it, otherwise remove it from the world.
// Anything not taken up by inventory is lost.
if (%obj.isStatic())
%obj.respawn();
else
%obj.delete();
return true;
}
//-----------------------------------------------------------------------------
// Hook into the mission editor.
function ItemData::create(%data)
{
// The mission editor invokes this method when it wants to create
// an object of the given datablock type. For the mission editor
// we always create "static" re-spawnable rotating objects.
%obj = new Item() {
dataBlock = %data;
static = true;
rotate = true;
};
return %obj;
}

Binary file not shown.

View File

@ -0,0 +1,37 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
datablock MissionMarkerData(WayPointMarker)
{
category = "Misc";
shapeFile = "~/data/shapes/markers/octahedron.dts";
};
datablock MissionMarkerData(SpawnSphereMarker)
{
category = "Misc";
shapeFile = "~/data/shapes/markers/octahedron.dts";
};
//------------------------------------------------------------------------------
// - serveral marker types may share MissionMarker datablock type
function MissionMarkerData::create(%block)
{
switch$(%block)
{
case "WayPointMarker":
%obj = new WayPoint() {
dataBlock = %block;
};
return(%obj);
case "SpawnSphereMarker":
%obj = new SpawnSphere() {
datablock = %block;
};
return(%obj);
}
return(-1);
}

Binary file not shown.

View File

@ -0,0 +1,965 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
// Load dts shapes and merge animations
exec("~/data/shapes/player/player.cs");
exec("~/data/shapes/tge_elf/elf.cs");
// Timeouts for corpse deletion.
$CorpseTimeoutValue = 22 * 1000;
// Damage Rate for entering Liquid
$DamageLava = 0.01;
$DamageHotLava = 0.01;
$DamageCrustyLava = 0.01;
//
$PlayerDeathAnim::TorsoFrontFallForward = 1;
$PlayerDeathAnim::TorsoFrontFallBack = 2;
$PlayerDeathAnim::TorsoBackFallForward = 3;
$PlayerDeathAnim::TorsoLeftSpinDeath = 4;
$PlayerDeathAnim::TorsoRightSpinDeath = 5;
$PlayerDeathAnim::LegsLeftGimp = 6;
$PlayerDeathAnim::LegsRightGimp = 7;
$PlayerDeathAnim::TorsoBackFallForward = 8;
$PlayerDeathAnim::HeadFrontDirect = 9;
$PlayerDeathAnim::HeadBackFallForward = 10;
$PlayerDeathAnim::ExplosionBlowBack = 11;
//----------------------------------------------------------------------------
// Player Audio Profiles
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
datablock AudioProfile(DeathCrySound)
{
fileName = "~/data/sound/orc_death.ogg";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(PainCrySound)
{
fileName = "~/data/sound/orc_pain.ogg";
description = AudioClose3d;
preload = true;
};
//----------------------------------------------------------------------------
datablock AudioProfile(FootLightSoftSound)
{
filename = "~/data/sound/footstep_soft.ogg";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(FootLightHardSound)
{
filename = "~/data/sound/footstep_hard.ogg";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(FootLightMetalSound)
{
filename = "~/data/sound/footstep_hard.ogg";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(FootLightSnowSound)
{
filename = "~/data/sound/footstep_soft.ogg";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(FootLightShallowSplashSound)
{
filename = "~/data/sound/footstep_water.ogg";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(FootLightWadingSound)
{
filename = "~/data/sound/footstep_water.ogg";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(FootLightUnderwaterSound)
{
filename = "~/data/sound/footstep_water.ogg";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(FootLightBubblesSound)
{
filename = "~/data/sound/replaceme.ogg";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(ArmorMoveBubblesSound)
{
filename = "~/data/sound/replaceme.ogg";
description = AudioCloseLooping3d;
preload = true;
};
datablock AudioProfile(WaterBreathMaleSound)
{
filename = "~/data/sound/replaceme.ogg";
description = AudioClosestLooping3d;
preload = true;
};
//----------------------------------------------------------------------------
datablock AudioProfile(ImpactLightSoftSound)
{
filename = "~/data/sound/replaceme.ogg";
description = AudioClose3d;
preload = true;
effect = ImpactSoftEffect;
};
datablock AudioProfile(ImpactLightHardSound)
{
filename = "~/data/sound/replaceme.ogg";
description = AudioClose3d;
preload = true;
effect = ImpactHardEffect;
};
datablock AudioProfile(ImpactLightMetalSound)
{
filename = "~/data/sound/replaceme.ogg";
description = AudioClose3d;
preload = true;
effect = ImpactMetalEffect;
};
datablock AudioProfile(ImpactLightSnowSound)
{
filename = "~/data/sound/replaceme.ogg";
description = AudioClosest3d;
preload = true;
effect = ImpactSnowEffect;
};
datablock AudioProfile(ImpactLightWaterEasySound)
{
filename = "~/data/sound/replaceme.ogg";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(ImpactLightWaterMediumSound)
{
filename = "~/data/sound/replaceme.ogg";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(ImpactLightWaterHardSound)
{
filename = "~/data/sound/replaceme.ogg";
description = AudioDefault3d;
preload = true;
};
datablock AudioProfile(ExitingWaterLightSound)
{
filename = "~/data/sound/replaceme.ogg";
description = AudioClose3d;
preload = true;
};
//----------------------------------------------------------------------------
// Splash
//----------------------------------------------------------------------------
datablock ParticleData(PlayerSplashMist)
{
dragCoefficient = 2.0;
gravityCoefficient = -0.05;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 400;
lifetimeVarianceMS = 100;
useInvAlpha = false;
spinRandomMin = -90.0;
spinRandomMax = 500.0;
textureName = "~/data/shapes/player/splash";
colors[0] = "0.7 0.8 1.0 1.0";
colors[1] = "0.7 0.8 1.0 0.5";
colors[2] = "0.7 0.8 1.0 0.0";
sizes[0] = 0.5;
sizes[1] = 0.5;
sizes[2] = 0.8;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(PlayerSplashMistEmitter)
{
ejectionPeriodMS = 5;
periodVarianceMS = 0;
ejectionVelocity = 3.0;
velocityVariance = 2.0;
ejectionOffset = 0.0;
thetaMin = 85;
thetaMax = 85;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
lifetimeMS = 250;
particles = "PlayerSplashMist";
};
datablock ParticleData(PlayerBubbleParticle)
{
dragCoefficient = 0.0;
gravityCoefficient = -0.50;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 400;
lifetimeVarianceMS = 100;
useInvAlpha = false;
textureName = "~/data/shapes/player/splash";
colors[0] = "0.7 0.8 1.0 0.4";
colors[1] = "0.7 0.8 1.0 0.4";
colors[2] = "0.7 0.8 1.0 0.0";
sizes[0] = 0.1;
sizes[1] = 0.3;
sizes[2] = 0.3;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(PlayerBubbleEmitter)
{
ejectionPeriodMS = 1;
periodVarianceMS = 0;
ejectionVelocity = 2.0;
ejectionOffset = 0.5;
velocityVariance = 0.5;
thetaMin = 0;
thetaMax = 80;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
particles = "PlayerBubbleParticle";
};
datablock ParticleData(PlayerFoamParticle)
{
dragCoefficient = 2.0;
gravityCoefficient = -0.05;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 400;
lifetimeVarianceMS = 100;
useInvAlpha = false;
spinRandomMin = -90.0;
spinRandomMax = 500.0;
textureName = "~/data/shapes/player/splash";
colors[0] = "0.7 0.8 1.0 0.20";
colors[1] = "0.7 0.8 1.0 0.20";
colors[2] = "0.7 0.8 1.0 0.00";
sizes[0] = 0.2;
sizes[1] = 0.4;
sizes[2] = 1.6;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(PlayerFoamEmitter)
{
ejectionPeriodMS = 10;
periodVarianceMS = 0;
ejectionVelocity = 3.0;
velocityVariance = 1.0;
ejectionOffset = 0.0;
thetaMin = 85;
thetaMax = 85;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
particles = "PlayerFoamParticle";
};
datablock ParticleData( PlayerFoamDropletsParticle )
{
dragCoefficient = 1;
gravityCoefficient = 0.2;
inheritedVelFactor = 0.2;
constantAcceleration = -0.0;
lifetimeMS = 600;
lifetimeVarianceMS = 0;
textureName = "~/data/shapes/player/splash";
colors[0] = "0.7 0.8 1.0 1.0";
colors[1] = "0.7 0.8 1.0 0.5";
colors[2] = "0.7 0.8 1.0 0.0";
sizes[0] = 0.8;
sizes[1] = 0.3;
sizes[2] = 0.0;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData( PlayerFoamDropletsEmitter )
{
ejectionPeriodMS = 7;
periodVarianceMS = 0;
ejectionVelocity = 2;
velocityVariance = 1.0;
ejectionOffset = 0.0;
thetaMin = 60;
thetaMax = 80;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
orientParticles = true;
particles = "PlayerFoamDropletsParticle";
};
datablock ParticleData( PlayerSplashParticle )
{
dragCoefficient = 1;
gravityCoefficient = 0.2;
inheritedVelFactor = 0.2;
constantAcceleration = -0.0;
lifetimeMS = 600;
lifetimeVarianceMS = 0;
colors[0] = "0.7 0.8 1.0 1.0";
colors[1] = "0.7 0.8 1.0 0.5";
colors[2] = "0.7 0.8 1.0 0.0";
sizes[0] = 0.5;
sizes[1] = 0.5;
sizes[2] = 0.5;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData( PlayerSplashEmitter )
{
ejectionPeriodMS = 1;
periodVarianceMS = 0;
ejectionVelocity = 3;
velocityVariance = 1.0;
ejectionOffset = 0.0;
thetaMin = 60;
thetaMax = 80;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
orientParticles = true;
lifetimeMS = 100;
particles = "PlayerSplashParticle";
};
datablock SplashData(PlayerSplash)
{
numSegments = 15;
ejectionFreq = 15;
ejectionAngle = 40;
ringLifetime = 0.5;
lifetimeMS = 300;
velocity = 4.0;
startRadius = 0.0;
acceleration = -3.0;
texWrap = 5.0;
texture = "~/data/shapes/player/splash";
emitter[0] = PlayerSplashEmitter;
emitter[1] = PlayerSplashMistEmitter;
colors[0] = "0.7 0.8 1.0 0.0";
colors[1] = "0.7 0.8 1.0 0.3";
colors[2] = "0.7 0.8 1.0 0.7";
colors[3] = "0.7 0.8 1.0 0.0";
times[0] = 0.0;
times[1] = 0.4;
times[2] = 0.8;
times[3] = 1.0;
};
//----------------------------------------------------------------------------
// Foot puffs
//----------------------------------------------------------------------------
datablock ParticleData(LightPuff)
{
dragCoefficient = 2.0;
gravityCoefficient = -0.01;
inheritedVelFactor = 0.6;
constantAcceleration = 0.0;
lifetimeMS = 800;
lifetimeVarianceMS = 100;
useInvAlpha = true;
spinRandomMin = -35.0;
spinRandomMax = 35.0;
colors[0] = "1.0 1.0 1.0 1.0";
colors[1] = "1.0 1.0 1.0 0.0";
sizes[0] = 0.1;
sizes[1] = 0.8;
times[0] = 0.3;
times[1] = 1.0;
};
datablock ParticleEmitterData(LightPuffEmitter)
{
ejectionPeriodMS = 35;
periodVarianceMS = 10;
ejectionVelocity = 0.2;
velocityVariance = 0.1;
ejectionOffset = 0.0;
thetaMin = 20;
thetaMax = 60;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
useEmitterColors = true;
particles = "LightPuff";
};
//----------------------------------------------------------------------------
// Liftoff dust
//----------------------------------------------------------------------------
datablock ParticleData(LiftoffDust)
{
dragCoefficient = 1.0;
gravityCoefficient = -0.01;
inheritedVelFactor = 0.0;
constantAcceleration = 0.0;
lifetimeMS = 1000;
lifetimeVarianceMS = 100;
useInvAlpha = true;
spinRandomMin = -90.0;
spinRandomMax = 500.0;
colors[0] = "1.0 1.0 1.0 1.0";
sizes[0] = 1.0;
times[0] = 1.0;
};
datablock ParticleEmitterData(LiftoffDustEmitter)
{
ejectionPeriodMS = 5;
periodVarianceMS = 0;
ejectionVelocity = 2.0;
velocityVariance = 0.0;
ejectionOffset = 0.0;
thetaMin = 90;
thetaMax = 90;
phiReferenceVel = 0;
phiVariance = 360;
overrideAdvance = false;
useEmitterColors = true;
particles = "LiftoffDust";
};
//----------------------------------------------------------------------------
datablock DecalData(PlayerFootprint)
{
sizeX = 0.25;
sizeY = 0.25;
textureName = "~/data/shapes/player/footprint";
};
datablock DebrisData( PlayerDebris )
{
explodeOnMaxBounce = false;
elasticity = 0.15;
friction = 0.5;
lifetime = 4.0;
lifetimeVariance = 0.0;
minSpinSpeed = 40;
maxSpinSpeed = 600;
numBounces = 5;
bounceVariance = 0;
staticOnMaxBounce = true;
gravModifier = 1.0;
useRadiusMass = true;
baseRadius = 1;
velocity = 20.0;
velocityVariance = 12.0;
};
datablock PlayerData(PlayerBody)
{
renderFirstPerson = false;
emap = true;
className = Armor;
shapeFile = "~/data/shapes/player/player.dts";
cameraMaxDist = 3;
computeCRC = true;
canObserve = true;
cmdCategory = "Clients";
cameraDefaultFov = 90.0;
cameraMinFov = 5.0;
cameraMaxFov = 120.0;
debrisShapeName = "~/data/shapes/player/debris_player.dts";
debris = playerDebris;
aiAvoidThis = true;
minLookAngle = -1.4;
maxLookAngle = 1.4;
maxFreelookAngle = 3.0;
mass = 90;
drag = 0.3;
maxdrag = 0.4;
density = 10;
maxDamage = 100;
maxEnergy = 60;
repairRate = 0.33;
energyPerDamagePoint = 75.0;
rechargeRate = 0.256;
runForce = 48 * 90;
runEnergyDrain = 0;
minRunEnergy = 0;
maxForwardSpeed = 14;
maxBackwardSpeed = 13;
maxSideSpeed = 13;
maxUnderwaterForwardSpeed = 8.4;
maxUnderwaterBackwardSpeed = 7.8;
maxUnderwaterSideSpeed = 7.8;
jumpForce = 8.3 * 90;
jumpEnergyDrain = 0;
minJumpEnergy = 0;
jumpDelay = 15;
recoverDelay = 9;
recoverRunForceScale = 1.2;
minImpactSpeed = 45;
speedDamageScale = 0.4;
boundingBox = "1.2 1.2 2.3";
pickupRadius = 0.75;
// Damage location details
boxNormalHeadPercentage = 0.83;
boxNormalTorsoPercentage = 0.49;
boxHeadLeftPercentage = 0;
boxHeadRightPercentage = 1;
boxHeadBackPercentage = 0;
boxHeadFrontPercentage = 1;
// Foot Prints
decalData = PlayerFootprint;
decalOffset = 0.25;
footPuffEmitter = LightPuffEmitter;
footPuffNumParts = 10;
footPuffRadius = 0.25;
dustEmitter = LiftoffDustEmitter;
splash = PlayerSplash;
splashVelocity = 4.0;
splashAngle = 67.0;
splashFreqMod = 300.0;
splashVelEpsilon = 0.60;
bubbleEmitTime = 0.4;
splashEmitter[0] = PlayerFoamDropletsEmitter;
splashEmitter[1] = PlayerFoamEmitter;
splashEmitter[2] = PlayerBubbleEmitter;
mediumSplashSoundVelocity = 10.0;
hardSplashSoundVelocity = 20.0;
exitSplashSoundVelocity = 5.0;
// Controls over slope of runnable/jumpable surfaces
runSurfaceAngle = 70;
jumpSurfaceAngle = 80;
minJumpSpeed = 20;
maxJumpSpeed = 30;
horizMaxSpeed = 68;
horizResistSpeed = 33;
horizResistFactor = 0.35;
upMaxSpeed = 80;
upResistSpeed = 25;
upResistFactor = 0.3;
footstepSplashHeight = 0.35;
//NOTE: some sounds commented out until wav's are available
// Footstep Sounds
FootSoftSound = FootLightSoftSound;
FootHardSound = FootLightHardSound;
FootMetalSound = FootLightMetalSound;
FootSnowSound = FootLightSnowSound;
FootShallowSound = FootLightShallowSplashSound;
FootWadingSound = FootLightWadingSound;
FootUnderwaterSound = FootLightUnderwaterSound;
//FootBubblesSound = FootLightBubblesSound;
//movingBubblesSound = ArmorMoveBubblesSound;
//waterBreathSound = WaterBreathMaleSound;
//impactSoftSound = ImpactLightSoftSound;
//impactHardSound = ImpactLightHardSound;
//impactMetalSound = ImpactLightMetalSound;
//impactSnowSound = ImpactLightSnowSound;
//impactWaterEasy = ImpactLightWaterEasySound;
//impactWaterMedium = ImpactLightWaterMediumSound;
//impactWaterHard = ImpactLightWaterHardSound;
groundImpactMinSpeed = 10.0;
groundImpactShakeFreq = "4.0 4.0 4.0";
groundImpactShakeAmp = "1.0 1.0 1.0";
groundImpactShakeDuration = 0.8;
groundImpactShakeFalloff = 10.0;
//exitingWater = ExitingWaterLightSound;
observeParameters = "0.5 4.5 4.5";
// Allowable Inventory Items
maxInv[BulletAmmo] = 20;
maxInv[HealthKit] = 1;
maxInv[RifleAmmo] = 100;
maxInv[CrossbowAmmo] = 50;
maxInv[Crossbow] = 1;
maxInv[Rifle] = 1;
};
//----------------------------------------------------------------------------
// Armor Datablock methods
//----------------------------------------------------------------------------
//----------------------------------------------------------------------------
function Armor::onAdd(%this,%obj)
{
// Vehicle timeout
%obj.mountVehicle = true;
// Default dynamic armor stats
%obj.setRechargeRate(%this.rechargeRate);
%obj.setRepairRate(0);
}
function Armor::onRemove(%this, %obj)
{
if (%obj.client.player == %obj)
%obj.client.player = 0;
}
function Armor::onNewDataBlock(%this,%obj)
{
}
//----------------------------------------------------------------------------
function Armor::onMount(%this,%obj,%vehicle,%node)
{
if (%node == 0) {
%obj.setTransform("0 0 0 0 0 1 0");
%obj.setActionThread(%vehicle.getDatablock().mountPose[%node],true,true);
%obj.lastWeapon = %obj.getMountedImage($WeaponSlot);
%obj.unmountImage($WeaponSlot);
%obj.setControlObject(%vehicle);
}
}
function Armor::onUnmount( %this, %obj, %vehicle, %node )
{
if (%node == 0)
%obj.mountImage(%obj.lastWeapon, $WeaponSlot);
}
function Armor::doDismount(%this, %obj, %forced)
{
// This function is called by player.cc when the jump trigger
// is true while mounted
if (!%obj.isMounted())
return;
// Position above dismount point
%pos = getWords(%obj.getTransform(), 0, 2);
%oldPos = %pos;
%vec[0] = " 0 0 1";
%vec[1] = " 0 0 1";
%vec[2] = " 0 0 -1";
%vec[3] = " 1 0 0";
%vec[4] = "-1 0 0";
%impulseVec = "0 0 0";
%vec[0] = MatrixMulVector( %obj.getTransform(), %vec[0]);
// Make sure the point is valid
%pos = "0 0 0";
%numAttempts = 5;
%success = -1;
for (%i = 0; %i < %numAttempts; %i++) {
%pos = VectorAdd(%oldPos, VectorScale(%vec[%i], 3));
if (%obj.checkDismountPoint(%oldPos, %pos)) {
%success = %i;
%impulseVec = %vec[%i];
break;
}
}
if (%forced && %success == -1)
%pos = %oldPos;
%obj.mountVehicle = false;
%obj.schedule(4000, "mountVehicles", true);
// Unmount from node, and give player control.
%obj.unMount();
%this.onUnMount(%obj);
%obj.setControlObject(%obj);
// Position above dismount point
%obj.setTransform(%pos);
%obj.applyImpulse(%pos, VectorScale(%impulseVec, %obj.getDataBlock().mass));
}
//----------------------------------------------------------------------------
function Armor::onCollision(%this,%obj,%col)
{
if (%obj.getState() $= "Dead")
return;
// Try and pickup all items
if (%col.getClassName() $= "Item") {
%obj.pickup(%col);
return;
}
// Mount vehicles
if (%col.getDataBlock().className $= WheeledVehicleData && %obj.mountVehicle &&
%obj.getState() $= "Move" && %col.mountable) {
// Only mount drivers for now.
%node = 0;
%col.mountObject(%obj,%node);
%obj.mVehicle = %col;
}
}
function Armor::onImpact(%this, %obj, %collidedObject, %vec, %vecLen)
{
%obj.damage(0, VectorAdd(%obj.getPosition(),%vec),
%vecLen * %this.speedDamageScale, "Impact");
}
//----------------------------------------------------------------------------
function Armor::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
{
if (%obj.getState() $= "Dead")
return;
%obj.applyDamage(%damage);
%location = "Body";
// Deal with client callbacks here because we don't have this
// information in the onDamage or onDisable methods
%client = %obj.client;
%sourceClient = %sourceObject ? %sourceObject.client : 0;
if (%obj.getState() $= "Dead")
%client.onDeath(%sourceObject, %sourceClient, %damageType, %location);
}
function Armor::onDamage(%this, %obj, %delta)
{
// This method is invoked by the ShapeBase code whenever the
// object's damage level changes.
if (%delta > 0 && %obj.getState() !$= "Dead") {
// Increment the flash based on the amount.
%flash = %obj.getDamageFlash() + ((%delta / %this.maxDamage) * 2);
if (%flash > 0.75)
%flash = 0.75;
%obj.setDamageFlash(%flash);
// If the pain is excessive, let's hear about it.
if (%delta > 10)
%obj.playPain();
}
}
function Armor::onDisabled(%this,%obj,%state)
{
// The player object sets the "disabled" state when damage exceeds
// it's maxDamage value. This is method is invoked by ShapeBase
// state mangement code.
// If we want to deal with the damage information that actually
// caused this death, then we would have to move this code into
// the script "damage" method.
%obj.playDeathCry();
%obj.playDeathAnimation();
%obj.setDamageFlash(0.75);
// Release the main weapon trigger
%obj.setImageTrigger(0,false);
// Schedule corpse removal. Just keeping the place clean.
%obj.schedule($CorpseTimeoutValue - 1000, "startFade", 1000, 0, true);
%obj.schedule($CorpseTimeoutValue, "delete");
}
//-----------------------------------------------------------------------------
function Armor::onLeaveMissionArea(%this, %obj)
{
// Inform the client
%obj.client.onLeaveMissionArea();
}
function Armor::onEnterMissionArea(%this, %obj)
{
// Inform the client
%obj.client.onEnterMissionArea();
}
//-----------------------------------------------------------------------------
function Armor::onEnterLiquid(%this, %obj, %coverage, %type)
{
switch(%type)
{
case 0: //Water
case 1: //Ocean Water
case 2: //River Water
case 3: //Stagnant Water
case 4: //Lava
%obj.setDamageDt(%this, $DamageLava, "Lava");
case 5: //Hot Lava
%obj.setDamageDt(%this, $DamageHotLava, "Lava");
case 6: //Crusty Lava
%obj.setDamageDt(%this, $DamageCrustyLava, "Lava");
case 7: //Quick Sand
}
}
function Armor::onLeaveLiquid(%this, %obj, %type)
{
%obj.clearDamageDt();
}
//-----------------------------------------------------------------------------
function Armor::onTrigger(%this, %obj, %triggerNum, %val)
{
// This method is invoked when the player receives a trigger
// move event. The player automatically triggers slot 0 and
// slot one off of triggers # 0 & 1. Trigger # 2 is also used
// as the jump key.
}
//-----------------------------------------------------------------------------
// Player methods
//-----------------------------------------------------------------------------
//----------------------------------------------------------------------------
function Player::kill(%this, %damageType)
{
%this.damage(0, %this.getPosition(), 10000, %damageType);
}
//----------------------------------------------------------------------------
function Player::mountVehicles(%this,%bool)
{
// If set to false, this variable disables vehicle mounting.
%this.mountVehicle = %bool;
}
function Player::isPilot(%this)
{
%vehicle = %this.getObjectMount();
// There are two "if" statements to avoid a script warning.
if (%vehicle)
if (%vehicle.getMountNodeObject(0) == %this)
return true;
return false;
}
//----------------------------------------------------------------------------
function Player::playDeathAnimation(%this)
{
if (%this.deathIdx++ > 11)
%this.deathIdx = 1;
%this.setActionThread("Death" @ %this.deathIdx);
}
function Player::playCelAnimation(%this,%anim)
{
if (%this.getState() !$= "Dead")
%this.setActionThread("cel"@%anim);
}
//----------------------------------------------------------------------------
function Player::playDeathCry( %this )
{
%this.playAudio(0,DeathCrySound);
}
function Player::playPain( %this )
{
%this.playAudio(0,PainCrySound);
}

Binary file not shown.

View File

@ -0,0 +1,54 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
// Support function which applies damage to objects within the radius of
// some effect, usually an explosion. This function will also optionally
// apply an impulse to each object.
function radiusDamage(%sourceObject, %position, %radius, %damage, %damageType, %impulse)
{
// Use the container system to iterate through all the objects
// within our explosion radius. We'll apply damage to all ShapeBase
// objects.
InitContainerRadiusSearch(%position, %radius, $TypeMasks::ShapeBaseObjectType);
%halfRadius = %radius / 2;
while ((%targetObject = containerSearchNext()) != 0) {
// Calculate how much exposure the current object has to
// the explosive force. The object types listed are objects
// that will block an explosion. If the object is totally blocked,
// then no damage is applied.
%coverage = calcExplosionCoverage(%position, %targetObject,
$TypeMasks::InteriorObjectType | $TypeMasks::TerrainObjectType |
$TypeMasks::ForceFieldObjectType | $TypeMasks::VehicleObjectType);
if (%coverage == 0)
continue;
// Radius distance subtracts out the length of smallest bounding
// box axis to return an appriximate distance to the edge of the
// object's bounds, as opposed to the distance to it's center.
%dist = containerSearchCurrRadiusDist();
// Calculate a distance scale for the damage and the impulse.
// Full damage is applied to anything less than half the radius away,
// linear scale from there.
%distScale = (%dist < %halfRadius)? 1.0:
1.0 - ((%dist - %halfRadius) / %halfRadius);
// Apply the damage
%targetObject.damage(%sourceObject, %position,
%damage * %coverage * %distScale, %damageType);
// Apply the impulse
if (%impulse)
{
%impulseVec = VectorSub(%targetObject.getWorldBoxCenter(), %position);
%impulseVec = VectorNormalize(%impulseVec);
%impulseVec = VectorScale(%impulseVec, %impulse * %distScale);
%targetObject.applyImpulse(%position, %impulseVec);
}
}
}

Binary file not shown.

View File

@ -0,0 +1,49 @@
datablock RigidShapeData( BouncingBoulder )
{
category = "RigidShape";
shapeFile = "~/data/shapes/rocks/boulder.dts";
emap = true;
// Rigid Body
mass = 200;
massCenter = "0 0 0"; // Center of mass for rigid body
massBox = "0 0 0"; // Size of box used for moment of inertia,
// if zero it defaults to object bounding box
drag = 0.2; // Drag coefficient
bodyFriction = 0.2;
bodyRestitution = 0.1;
minImpactSpeed = 5; // Impacts over this invoke the script callback
softImpactSpeed = 5; // Play SoftImpact Sound
hardImpactSpeed = 15; // Play HardImpact Sound
integration = 4; // Physics integration: TickSec/Rate
collisionTol = 0.1; // Collision distance tolerance
contactTol = 0.1; // Contact velocity tolerance
minRollSpeed = 10;
maxDrag = 0.5;
minDrag = 0.01;
triggerDustHeight = 1;
dustHeight = 10;
dragForce = 0.05;
vertFactor = 0.05;
normalForce = 0.05;
restorativeForce = 0.05;
rollForce = 0.05;
pitchForce = 0.05;
};
// Hook into the mission editor.
function RigidShapeData::create(%data)
{
// The mission editor invokes this method when it wants to create
// an object of the given datablock type.
%obj = new RigidShape() {
dataBlock = %data;
};
return %obj;
}

Binary file not shown.

View File

@ -0,0 +1,628 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Functions that implement game-play
//-----------------------------------------------------------------------------
package DemoSceneGame {
//-----------------------------------------------------------------------------
function GameConnection::onClientEnterGame(%this)
{
commandToClient(%this,'SyncClock', $Sim::Time - $Game::StartTime);
commandToClient(%this,'SetGameGUI',"SceneGui");
// Create a new camera object.
%this.camera = new Camera() {
dataBlock = Observer;
};
MissionCleanup.add( %this.camera );
%this.camera.scopeToClient(%this);
// Create path camera
%this.player = new PathCamera() {
dataBlock = LoopingCam;
position = Scene::getStartPos();
};
MissionCleanup.add( %this.player );
%this.player.scopeToClient(%this);
// Start up the room gui system
$Server::Client = %this;
%this.setControlObject(%this.player);
SceneGui.setSceneNumber(0);
// Force detail settings
$Pref::TS::detailAdjust = 1;
$Pref::TS::screenError = 10;
// Start NPC orcs
newNPCOrc("MissionGroup/Paths/OrcNPC1",0.75);
newNPCOrc("MissionGroup/Paths/OrcNPC2",0.75);
newNPCOrc("MissionGroup/Paths/OrcNPC3",0.40);
}
//-----------------------------------------------------------------------------
function GameConnection::createPlayer(%this, %spawnPoint)
{
}
//-----------------------------------------------------------------------------
function serverCmdSuicide(%client)
{
if (isObject(%client.player)) {
%client.player.delete();
%client.player = 0;
}
%client.spawnPlayer();
}
};
//-----------------------------------------------------------------------------
// Scene Class
//-----------------------------------------------------------------------------
$Server::CurrentScene = 0;
// Scene activation is driven from the DemoGui and related scripts.
// (see demo/client/scripts/demoGui.cs)
function Scene::activateScene(%number)
{
if (isObject($Server::CurrentScene))
$Server::CurrentScene.close();
$Server::CurrentScene = "MissionGroup/Scenes".getObject(%number);
echo("Activating Scene #"@%number);
$Server::CurrentScene.open();
return $Server::CurrentScene;
}
function Scene::open(%this)
{
echo("Scene " @ %this.getName() @ " open");
%client = $Server::Client;
// Push any scene specific controls
if (isObject(%this.gui))
Canvas.pushDialog(%this.gui);
// Set the path to follow, the camera will start at
// the first node in the path.
%path = %this.getId() @ "/path";
if (isObject(%path)) {
%client.player.reset(0);
%client.player.followPath(%path);
}
else {
// Check for a static camera
%start = %this.getId() @ "/start";
if (isObject(%start)) {
echo("Static Camera");
%client.player.reset(0);
%client.player.pushNode(%start);
%client.player.popFront();
}
}
}
function Scene::getStartPos()
{
%scene = "MissionGroup/Scenes".getObject(0);
%start = %scene.getId() @ "/start";
if (isObject(%start))
return %start.getTransform();
return "0 0 100";
}
function Scene::close(%this)
{
%client = $Server::Client;
// Pop any scene specific controls
if (isObject(%this.gui))
Canvas.popDialog(%this.gui);
echo("Scene " @ %this.getName() @ " closed");
}
//-----------------------------------------------------------------------------
// Orc Animation
//-----------------------------------------------------------------------------
function newNPCOrc(%path,%speed)
{
%orc = AIPlayer::spawnOnPath("NPC",%path);
%orc.setMoveSpeed(%speed);
%orc.mountImage(CrossbowImage,0);
%orc.pushTask("followPath(\""@%path@"\",-1)");
}
function newAnimationOrc()
{
if (isObject($AnimationOrc))
$AnimationOrc.clearTasks();
else {
$AnimationOrc = AIPlayer::spawnOnPath("Tarkof","MissionGroup/Paths/OrcAnimation");
$AnimationOrc.setMoveSpeed(0.75);
$AnimationOrc.mountImage(CrossbowImage,0);
$AnimationOrc.setInventory(CrossbowAmmo,1000);
}
$AnimationOrc.pushTask("followPath(\"MissionGroup/Paths/OrcAnimation\",100)");
}
function deleteAnimationOrc()
{
if (isObject($AnimationOrc)) {
$AnimationOrc.clearTasks();
$AnimationOrc.pushTask("followPath(\"MissionGroup/Paths/OrcAnimation\",0)");
$AnimationOrc.pushTask("done()");
}
}
function AnimationOrcPlay(%anim)
{
$AnimationOrc.clearTasks();
$AnimationOrc.pushTask("animate(\""@%anim@"\")");
}
function newDancingOrc()
{
if (isObject($DancingOrc))
$DancingOrc.clearTasks();
else {
$DancingOrc = AIPlayer::spawnOnPath("Dance","MissionGroup/Paths/OrcDance");
$DancingOrc.setMoveSpeed(0.75);
}
$DancingOrc.pushTask("followPath(\"MissionGroup/Paths/OrcDance\",100)");
$DancingOrc.pushTask("animate(\"dance\")");
}
function deleteDancingOrc()
{
if (isObject($DancingOrc)) {
$DancingOrc.clearTasks();
$DancingOrc.pushTask("followPath(\"MissionGroup/Paths/OrcDance\",0)");
$DancingOrc.pushTask("done()");
}
}
function newDetailOrc()
{
if (isObject($DetailOrc)) {
$DetailOrc.clearTasks();
$DetailOrc.unmountImage(0);
$DetailOrc.unmountImage(1);
$DetailOrc.setArmThread("looknw");
}
else {
$DetailOrc = AIPlayer::spawnOnPath("Detail","MissionGroup/Paths/OrcDetail");
$DetailOrc.setMoveSpeed(0.75);
$DetailOrc.setArmThread("looknw");
}
$DetailOrc.pushTask("followPath(\"MissionGroup/Paths/OrcDetail\",100)");
}
function deleteDetailOrc()
{
if (isObject($DetailOrc)) {
$DetailOrc.clearTasks();
$DetailOrc.pushTask("followPath(\"MissionGroup/Paths/OrcDetail\",0)");
$DetailOrc.pushTask("done()");
}
}
function mountDetailOrc(%object,%slot)
{
if ($DetailOrc.getMountedImage(%slot) == %object.getId()) {
$DetailOrc.unmountImage(%slot);
if (%slot == 0)
$DetailOrc.setArmThread("looknw");
}
else {
$DetailOrc.mountImage(%object,%slot);
if (%slot == 0)
$DetailOrc.setArmThread("look");
}
}
function newShootingOrc()
{
if (isObject($ShootingOrc))
$ShootingOrc.clearTasks();
else {
$ShootingOrc = AIPlayer::spawnOnPath("Detail","MissionGroup/Paths/OrcShooting");
$ShootingOrc.mountImage(CrossbowImage,0);
$ShootingOrc.setInventory(CrossbowAmmo,500000);
$ShootingOrc.setMoveSpeed(0.75);
}
$ShootingOrc.pushTask("followPath(\"MissionGroup/Paths/OrcShooting\",100)");
$ShootingOrc.pushTask("aimAt(\"MissionGroup/Scenes/ProjectileScene/target\")");
$ShootingOrc.pushTask("wait(1)");
$ShootingOrc.pushTask("fire(true)");
}
function deleteShootingOrc()
{
if (isObject($ShootingOrc)) {
$ShootingOrc.clearTasks();
$ShootingOrc.pushTask("fire(false)");
$ShootingOrc.pushTask("followPath(\"MissionGroup/Paths/OrcShooting\",0)");
$ShootingOrc.pushTask("done()");
}
}
//-----------------------------------------------------------------------------
// Environment effects
//-----------------------------------------------------------------------------
function startRain()
{
if (!isObject($Rain))
$Rain = new Precipitation() {
dataBlock = "HeavyRain";
minSpeed = "10";
maxSpeed = "15";
minMass = "0.05";
maxMass = "5";
maxTurbulence = "0.1";
turbulenceSpeed = "0.2";
rotateWithCamVel = "1";
useTurbulence = "1";
numDrops = "500";
boxWidth = "30";
boxHeight = "50";
doCollision = "1";
};
if (!isObject($Rain2))
$Rain2 = new Precipitation() {
dataBlock = "HeavyRain3";
minSpeed = "0.3";
maxSpeed = "0.6";
minMass = "0.01";
maxMass = "1";
maxTurbulence = "0.05";
turbulenceSpeed = "0.15";
rotateWithCamVel = "1";
useTurbulence = "1";
numDrops = "200";
boxWidth = "65";
boxHeight = "100";
doCollision = "0";
};
}
function startLeaves()
{
if (!isObject($Leaves))
{
$Leaves = new Precipitation() {
dataBlock = "Leaves";
minSpeed = "0.05";
maxSpeed = "0.1";
minMass = "0.1";
maxMass = "0.3";
maxTurbulence = "1";
turbulenceSpeed = "0.02";
rotateWithCamVel = "0";
useTurbulence = "1";
numDrops = "100";
boxWidth = "70";
boxHeight = "100";
doCollision = "0";
};
MissionCleanup.add($Leaves);
}
}
function stopLeaves()
{
if (isObject($Leaves))
$Leaves.delete();
$Leaves = "";
}
function stopRain()
{
if (isObject($Rain))
$Rain.delete();
$Rain = "";
if (isObject($Rain2))
$Rain2.delete();
$Rain2 = "";
}
function startLightning()
{
if (!isObject($Lightning))
$Lightning = new Lightning() {
position = "350 300 180";
scale = "250 400 500";
dataBlock = "LightningStorm";
strikesPerMinute = "50";
strikeWidth = "2.5";
chanceToHitTarget = "100";
strikeRadius = "50";
boltStartRadius = "20";
color = "1.000000 1.000000 1.000000 1.000000";
fadeColor = "0.400000 0.400000 0.100000 1.000000";
useFog = "1";
locked = "false";
};
}
function stopLightning()
{
if (isObject($Lightning))
$Lightning.delete();
$Lightning = "";
}
//-----------------------------------------------------------------------------
// Scenes
//-----------------------------------------------------------------------------
function WelcomeScene::open(%this)
{
Parent::open(%this);
startLeaves();
}
function TerrainEngineScene::open(%this)
{
Parent::open(%this);
stopLeaves();
}
function SkyScene::open(%this)
{
Parent::open(%this);
startLeaves();
}
function BakedShadowsScene::open(%this)
{
Parent::open(%this);
startLeaves();
}
function InteriorSpaces::open(%this)
{
Parent::open(%this);
newAnimationOrc();
stopLeaves();
}
function InteriorSpaces::close(%this)
{
Parent::close(%this);
deleteAnimationOrc();
}
function OrcAnimationScene::open(%this)
{
Parent::open(%this);
newAnimationOrc();
deleteDancingOrc();
$AnimationOrc.pushTask("wait(0.5)");
$AnimationOrc.pushTask("animate(\"celwave\")");
}
function OrcDanceScene::open(%this)
{
Parent::open(%this);
deleteAnimationOrc();
newDancingOrc();
}
function OrcShadowScene::open(%this)
{
Parent::open(%this);
newDancingOrc();
deleteDetailOrc();
}
function OrcDetailScene::open(%this)
{
Parent::open(%this);
deleteDancingOrc();
newDetailOrc();
%this.detailSetting = $Pref::TS::detailAdjust;
%this.screenError = $pref::TS::screenError;
DetailSceneSlider.setValue($Pref::TS::detailAdjust);
}
function OrcDetailScene::close(%this)
{
$Pref::TS::detailAdjust = %this.detailSetting;
$Pref::TS::detailAdjust = %this.screenError;
DetailSceneSlider.setValue(%this.detailSetting);
Parent::close(%this);
}
function OrcDetailScene::slider(%this)
{
$Pref::TS::detailAdjust = DetailSceneSlider.getValue();
$Pref::TS::screenError = 1 + 35 * (1 - $Pref::TS::detailAdjust);
}
function OrcMountingScene::open(%this)
{
Parent::open(%this);
newDetailOrc();
deleteShootingOrc();
stopLeaves();
}
function ProjectileScene::open(%this)
{
Parent::open(%this);
deleteDetailOrc();
newShootingOrc();
startLeaves();
}
function ExplosionScene::open(%this)
{
Parent::open(%this);
newShootingOrc();
startLeaves();
}
function FXLightScene::open(%this)
{
Parent::open(%this);
deleteShootingOrc();
stopLeaves();
}
function MirrorScene::open(%this)
{
Parent::open(%this);
stopLightning();
stopLeaves();
stopRain();
Sky.setFieldValue(fogDistance, "500");
Sky.setFieldValue(fogColor, "0.75 0.75 0.75 0.5");
Sky.setFieldValue(useSkyTextures, "1");
Sky.setFieldValue(SkySolidColor, "0.64 0.148 0.215 0");
Sky.setFieldValue(WindVelocity, "0.01 0.01 0");
Sky.setFieldValue(VisibleDistance, "800");
Sky.applySkyChanges();
}
function PrecipitationScene::open(%this)
{
Parent::open(%this);
startLeaves();
startRain();
Sky.setFieldValue(fogDistance, "0");
Sky.setFieldValue(fogColor, "0.45 0.45 0.45 1");
Sky.setFieldValue(useSkyTextures, "0");
Sky.setFieldValue(SkySolidColor, "1 1 1 1");
Sky.setFieldValue(WindVelocity, "0.11 0.11 0");
Sky.setFieldValue(VisibleDistance, "300");
Sky.applySkyChanges();
stopLightning();
}
function LightningScene::open(%this)
{
Parent::open(%this);
startLightning();
Sky.stormFog(0,3);
startRain();
Sky.setFieldValue(fogDistance, "0");
Sky.setFieldValue(fogColor, "0.45 0.45 0.45 1");
Sky.setFieldValue(useSkyTextures, "0");
Sky.setFieldValue(SkySolidColor, "1 1 1 1");
Sky.setFieldValue(WindVelocity, "0.11 0.11 0");
Sky.setFieldValue(VisibleDistance, "300");
Sky.applySkyChanges();
}
function WaterScene::open(%this)
{
stopLeaves();
Parent::open(%this);
stopLightning();
stopRain();
Sky.setFieldValue(fogDistance, "500");
Sky.setFieldValue(fogColor, "0.75 0.75 0.75 0.5");
Sky.setFieldValue(useSkyTextures, "1");
Sky.setFieldValue(SkySolidColor, "0.64 0.148 0.215 0");
Sky.setFieldValue(WindVelocity, "0.01 0.01 0");
Sky.setFieldValue(VisibleDistance, "800");
Sky.applySkyChanges();
}
function FxReplicatorScene::open(%this)
{
startLeaves();
Parent::open(%this);
Sky.stormFog(0,3);
}
function FogScene::open(%this)
{
Parent::open(%this);
Sky.stormFog(1.25,1.25);
}
function InFogScene::open(%this)
{
Parent::open(%this);
Sky.stormFog(1.25,1.25);
}
function GoodbyeScene::open(%this)
{
Parent::open(%this);
Sky.stormFog(0,3);
}
//-----------------------------------------------------------------------------
// Path Camera
//-----------------------------------------------------------------------------
datablock PathCameraData(LoopingCam)
{
mode = "";
};
function LoopingCam::onNode(%this,%camera,%node)
{
if (%node == %camera.loopNode) {
%camera.pushPath(%camera.path);
%camera.loopNode += %camera.path.getCount();
}
}
function PathCamera::followPath(%this,%path)
{
%this.path = %path;
if (!(%this.speed = %path.speed))
%this.speed = 100;
if (%path.isLooping)
%this.loopNode = %path.getCount() - 2;
else
%this.loopNode = -1;
%this.pushPath(%path);
%this.popFront();
}
function PathCamera::pushPath(%this,%path)
{
for (%i = 0; %i < %path.getCount(); %i++)
%this.pushNode(%path.getObject(%i));
}
function PathCamera::pushNode(%this,%node)
{
if (!(%speed = %node.speed))
%speed = %this.speed;
if ((%type = %node.type) $= "")
%type = "Normal";
if ((%smoothing = %node.smoothing) $= "")
%smoothing = "Linear";
%this.pushBack(%node.getTransform(),%speed,%type,%smoothing);
}

Binary file not shown.

View File

@ -0,0 +1,60 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
// This file contains ShapeBase methods used by all the derived classes
//-----------------------------------------------------------------------------
// ShapeBase object
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
function ShapeBase::damage(%this, %sourceObject, %position, %damage, %damageType)
{
// All damage applied by one object to another should go through this
// method. This function is provided to allow objects some chance of
// overriding or processing damage values and types. As opposed to
// having weapons call ShapeBase::applyDamage directly.
// Damage is redirected to the datablock, this is standard proceedure
// for many built in callbacks.
%this.getDataBlock().damage(%this, %sourceObject, %position, %damage, %damageType);
}
//-----------------------------------------------------------------------------
function ShapeBase::setDamageDt(%this, %damageAmount, %damageType)
{
// This function is used to apply damage over time. The damage
// is applied at a fixed rate (50 ms). Damage could be applied
// over time using the built in ShapBase C++ repair functions
// (using a neg. repair), but this has the advantage of going
// through the normal script channels.
if (%obj.getState() !$= "Dead") {
%this.damage(0, "0 0 0", %damageAmount, %damageType);
%obj.damageSchedule = %obj.schedule(50, "setDamageDt", %damageAmount, %damageType);
}
else
%obj.damageSchedule = "";
}
function ShapeBase::clearDamageDt(%this)
{
if (%obj.damageSchedule !$= "") {
cancel(%obj.damageSchedule);
%obj.damageSchedule = "";
}
}
//-----------------------------------------------------------------------------
// ShapeBase datablock
//-----------------------------------------------------------------------------
function ShapeBaseData::damage(%this, %obj, %position, %source, %amount, %damageType)
{
// Ignore damage by default. This empty method is here to
// avoid console warnings.
}

Binary file not shown.

View File

@ -0,0 +1,20 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Hook into the mission editor.
function StaticShapeData::create(%data)
{
// The mission editor invokes this method when it wants to create
// an object of the given datablock type.
%obj = new StaticShape() {
dataBlock = %data;
};
return %obj;
}

Binary file not shown.

View File

@ -0,0 +1,52 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// DefaultTrigger is used by the mission editor. This is also an example
// of trigger methods and callbacks.
datablock TriggerData(DefaultTrigger)
{
// The period is value is used to control how often the console
// onTriggerTick callback is called while there are any objects
// in the trigger. The default value is 100 MS.
tickPeriodMS = 100;
};
//-----------------------------------------------------------------------------
function DefaultTrigger::onEnterTrigger(%this,%trigger,%obj)
{
// This method is called whenever an object enters the %trigger
// area, the object is passed as %obj. The default onEnterTrigger
// method (in the C++ code) invokes the ::onTrigger(%trigger,1) method on
// every object (whatever it's type) in the same group as the trigger.
Parent::onEnterTrigger(%this,%trigger,%obj);
}
function DefaultTrigger::onLeaveTrigger(%this,%trigger,%obj)
{
// This method is called whenever an object leaves the %trigger
// area, the object is passed as %obj. The default onLeaveTrigger
// method (in the C++ code) invokes the ::onTrigger(%trigger,0) method on
// every object (whatever it's type) in the same group as the trigger.
Parent::onLeaveTrigger(%this,%trigger,%obj);
}
function DefaultTrigger::onTickTrigger(%this,%trigger)
{
// This method is called every tickPerioMS, as long as any
// objects intersect the trigger. The default onTriggerTick
// method (in the C++ code) invokes the ::onTriggerTick(%trigger) method on
// every object (whatever it's type) in the same group as the trigger.
// You can iterate through the objects in the list by using these
// methods:
// %this.getNumObjects();
// %this.getObject(n);
Parent::onTickTrigger(%this,%trigger);
}

Binary file not shown.

View File

@ -0,0 +1,118 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
// This file contains Weapon and Ammo Class/"namespace" helper methods
// as well as hooks into the inventory system. These functions are not
// attached to a specific C++ class or datablock, but define a set of
// methods which are part of dynamic namespaces "class". The Items
// include these namespaces into their scope using the ItemData and
// ItemImageData "className" variable.
// All ShapeBase images are mounted into one of 8 slots on a shape.
// This weapon system assumes all primary weapons are mounted into
// this specified slot:
$WeaponSlot = 0;
//-----------------------------------------------------------------------------
// Audio profiles
datablock AudioProfile(WeaponUseSound)
{
filename = "~/data/sound/weapon_switch.ogg";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(WeaponPickupSound)
{
filename = "~/data/sound/weapon_pickup.ogg";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(AmmoPickupSound)
{
filename = "~/data/sound/ammo_pickup.ogg";
description = AudioClose3d;
preload = true;
};
//-----------------------------------------------------------------------------
// Weapon Class
//-----------------------------------------------------------------------------
function Weapon::onUse(%data,%obj)
{
// Default behavoir for all weapons is to mount it into the
// this object's weapon slot, which is currently assumed
// to be slot 0
if (%obj.getMountedImage($WeaponSlot) != %data.image.getId()) {
serverPlay3D(WeaponUseSound,%obj.getTransform());
%obj.mountImage(%data.image, $WeaponSlot);
if (%obj.client)
messageClient(%obj.client, 'MsgWeaponUsed', '\c0Weapon selected');
}
}
function Weapon::onPickup(%this, %obj, %shape, %amount)
{
// The parent Item method performs the actual pickup.
// For player's we automatically use the weapon if the
// player does not already have one in hand.
if (Parent::onPickup(%this, %obj, %shape, %amount)) {
serverPlay3D(WeaponPickupSound,%obj.getTransform());
if (%shape.getClassName() $= "Player" &&
%shape.getMountedImage($WeaponSlot) == 0) {
%shape.use(%this);
}
}
}
function Weapon::onInventory(%this,%obj,%amount)
{
// Weapon inventory has changed, make sure there are no weapons
// of this type mounted if there are none left in inventory.
if (!%amount && (%slot = %obj.getMountSlot(%this.image)) != -1)
%obj.unmountImage(%slot);
}
//-----------------------------------------------------------------------------
// Weapon Image Class
//-----------------------------------------------------------------------------
function WeaponImage::onMount(%this,%obj,%slot)
{
// Images assume a false ammo state on load. We need to
// set the state according to the current inventory.
if (%obj.getInventory(%this.ammo))
%obj.setImageAmmo(%slot,true);
}
//-----------------------------------------------------------------------------
// Ammmo Class
//-----------------------------------------------------------------------------
function Ammo::onPickup(%this, %obj, %shape, %amount)
{
// The parent Item method performs the actual pickup.
if (Parent::onPickup(%this, %obj, %shape, %amount)) {
serverPlay3D(AmmoPickupSound,%obj.getTransform());
}
}
function Ammo::onInventory(%this,%obj,%amount)
{
// The ammo inventory state has changed, we need to update any
// mounted images using this ammo to reflect the new state.
for (%i = 0; %i < 8; %i++) {
if ((%image = %obj.getMountedImage(%i)) > 0)
if (isObject(%image.ammo) && %image.ammo.getId() == %this.getId())
%obj.setImageAmmo(%i,%amount != 0);
}
}

Binary file not shown.