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

View File

@ -0,0 +1,253 @@
//-----------------------------------------------------------------------------
// 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 PlayerData(DemoPlayer : PlayerBody)
{
shootingDelay = 2000;
};
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 0;
%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)
{
// The shooting delay is used to pulse the trigger
%this.setImageTrigger(0,true);
%this.setImageTrigger(0,false);
%this.trigger = %this.schedule(%this.shootingDelay,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 AIManager::think(%this)
{
// We could hook into the player's onDestroyed state instead of
// having to "think", but thinking allows us to consider other
// things...
if (!isObject(%this.player))
%this.player = %this.spawn();
%this.schedule(500,think);
}
function AIManager::spawn(%this)
{
%player = AIPlayer::spawnOnPath("Kork","MissionGroup/Paths/Path1");
if (isObject(%player))
{
%player.followPath("MissionGroup/Paths/Path1",-1);
%player.mountImage(CrossbowImage,0);
%player.setInventory(CrossbowAmmo,1000);
return %player;
}
else
return 0;
}

View File

@ -0,0 +1,113 @@
//-----------------------------------------------------------------------------
// 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;
};
//-----------------------------------------------------------------------------
// 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;
};

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);
}

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');
}
}

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;
};

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();
}

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/relbow_mono_01.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/explosion_mono_01.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.10;
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;
}

View File

@ -0,0 +1,85 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
// Environment Audio Profiles
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// 3D Sounds
//-----------------------------------------------------------------------------
datablock AudioDescription(Shore01Looping3d)
{
volume = 1.0;
isLooping= true;
is3D = true;
ReferenceDistance = 20;
maxDistance = 65;
type = $EnvAudioType;
};
datablock AudioDescription(TreeGrove01Looping3d)
{
volume = 1.0;
isLooping= true;
is3D = true;
ReferenceDistance = 20;
maxDistance = 80;
type = $EnvAudioType;
};
datablock AudioDescription(Tree01Looping3d)
{
volume = 1.0;
isLooping= true;
is3D = true;
ReferenceDistance = 20;
maxDistance = 60;
type = $EnvAudioType;
};
datablock AudioDescription(Fire01Looping3d)
{
volume = 1.0;
isLooping= true;
is3D = true;
ReferenceDistance = 3;
maxDistance = 10;
type = $EnvAudioType;
};
//-----------------------------------------------------------------------------
datablock AudioProfile(Shore01Snd)
{
fileName = "~/data/sound/Lakeshore_mono_01.ogg";
description = "Shore01Looping3d";
preload = true;
};
datablock AudioProfile(TreeGrove01Snd)
{
fileName = "~/data/sound/treegrove_mono_01.ogg";
description = "TreeGrove01Looping3d";
preload = true;
};
datablock AudioProfile(Tree01Snd)
{
fileName = "~/data/sound/tree_mono_01.ogg";
description = "Tree01Looping3d";
preload = true;
};
datablock AudioProfile(Fire01Snd)
{
fileName = "~/data/sound/Fire_Mono_01.ogg";
description = "Fire01Looping3d";
preload = true;
};

View File

@ -0,0 +1,97 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
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(Sandstormsound)
{
filename = "~/data/sound/waste.ogg";
description = AudioLooping2d;
volume = 1.0;
};
datablock PrecipitationData(Sandstorm)
{
soundProfile = "Sandstormsound";
dropTexture = "~/data/environment/sandstorm";
splashTexture = "~/data/environment/sandstorm2";
dropSize = 10;
splashSize = 2;
useTrueBillboards = false;
splashMS = 250;
};
datablock AudioProfile(dustsound)
{
filename = "~/data/sound/dust.ogg";
description = AudioLooping2d;
};
datablock PrecipitationData(dustspecks)
{
soundProfile = "dustsound";
dropTexture = "~/data/environment/dust";
splashTexture = "~/data/environment/dust2";
dropSize = 0.25;
splashSize = 0.25;
useTrueBillboards = false;
splashMS = 250;
};
//-=-=-=-=-=-=-=-
datablock PrecipitationData(HeavySnow)
{
dropTexture = "~/data/environment/snow";
splashTexture = "~/data/environment/snow";
dropSize = 0.27;
splashSize = 0.27;
useTrueBillboards = false;
splashMS = 50;
};

View File

@ -0,0 +1,351 @@
//-----------------------------------------------------------------------------
// 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;
//-----------------------------------------------------------------------------
// 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 = "FPS Starter Kit";
// Server::MissionType sent to the master server. Clients can
// filter servers based on mission type.
$Server::MissionType = "Deathmatch";
// GameStartTime is the sim time the game started. Used to calculated
// game elapsed time.
$Game::StartTime = 0;
// Load up all datablocks, objects etc. This function is called when
// a server is constructed.
exec("./audioProfiles.cs");
exec("./envAudioProfiles.cs");
exec("./camera.cs");
exec("./markers.cs");
exec("./triggers.cs");
exec("./inventory.cs");
exec("./shapeBase.cs");
exec("./item.cs");
exec("./environment.cs");
exec("./health.cs");
exec("./staticShape.cs");
exec("./weapon.cs");
exec("./radiusDamage.cs");
exec("./crossbow.cs");
exec("./environment.cs");
exec("common/server/lightingSystem.cs");
exec("./player.cs");
exec("./chimneyfire.cs");
exec("./aiPlayer.cs");
exec("./sgExamples.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.
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.
cancel($Game::Schedule);
$Game::Running = false;
$Game::Cycling = false;
}
//-----------------------------------------------------------------------------
function startGame()
{
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;
// Start the AIManager
new ScriptObject(AIManager) {};
MissionCleanup.add(AIManager);
AIManager.think();
}
function endGame()
{
if (!$Game::Running) {
error("endGame: No game running!");
return;
}
// Stop the AIManager
AIManager.delete();
// 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);
}
//-----------------------------------------------------------------------------
// 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);
// Create a new camera object.
%this.camera = new Camera() {
dataBlock = Observer;
};
MissionCleanup.add( %this.camera );
%this.camera.scopeToClient(%this);
// Setup game parameters, the onConnect method currently starts
// everyone with a 0 score.
%this.score = 0;
// Create a player object.
%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.setShapeName(%this.name);
// Starting equipment
%player.setInventory(Crossbow,1);
%player.setInventory(CrossbowAmmo,10);
%player.mountImage(CrossbowImage,0);
// 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";
}

View File

@ -0,0 +1,96 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
// Inventory items. These objects rely on the item & inventory support
// system defined in item.cs and inventory.cs
//-----------------------------------------------------------------------------
// Health kits can be added to your inventory and used to heal up.
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Audio profiles
//-----------------------------------------------------------------------------
datablock AudioProfile(HealthUseSound)
{
filename = "~/data/sound/health_mono_01.ogg";
description = AudioClose3d;
preload = true;
};
//------------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Health Kits are designed to be picked up and stored in the player's
// inventory until they "use" it. This differs from the Health Patches below
// that apply immediately on collision with a wounded player.
//-----------------------------------------------------------------------------
datablock ItemData(HealthKit)
{
// Mission editor category, this datablock will show up in the
// specified category under the "shapes" root category.
category = "Health";
// Basic Item properties
shapeFile = "~/data/shapes/items/healthKit.dts";
mass = 1;
friction = 1;
elasticity = 0.3;
emap = true;
// Dynamic properties defined by the scripts
pickupName = "a health kit";
repairAmount = 50;
};
function HealthKit::onUse(%this,%user)
{
// Apply some health to whoever uses it, the health kit is only
// used if the user is currently damaged.
if (%user.getDamageLevel() != 0) {
%user.decInventory(%this,1);
%user.applyRepair(%this.repairAmount);
if (%user.client)
messageClient(%user.client, 'MsgHealthKitUsed', '\c2Health Kit Applied');
}
}
//-----------------------------------------------------------------------------
// Health Patchs cannot be picked up and are not meant to be added to
// inventory. Health is applied automatically when an objects collides
// with a patch.
//-----------------------------------------------------------------------------
datablock ItemData(HealthPatch)
{
// Mission editor category, this datablock will show up in the
// specified category under the "shapes" root category.
category = "Health";
// Basic Item properties
shapeFile = "~/data/shapes/items/healthPatch.dts";
mass = 1;
friction = 1;
elasticity = 0.3;
emap = true;
// Dynamic properties defined by the scripts
repairAmount = 20;
maxInventory = 0; // No pickup or throw
};
function HealthPatch::onCollision(%this,%obj,%col)
{
// Apply health to colliding object if it needs it.
// Works for all shapebase objects.
if (%col.getDamageLevel() != 0 && %col.getState() !$= "Dead" ) {
%col.applyRepair(%this.repairAmount);
%obj.respawn();
if (%col.client)
messageClient(%col.client, 'MsgHealthPatchUsed', '\c2Health Patch Applied');
serverPlay3D(HealthUseSound,%obj.getTransform());
}
}

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.
}

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;
}

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);
}

View File

@ -0,0 +1,986 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
// Load dts shapes and merge animations
exec("~/data/shapes/player/player.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.wav";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(PainCrySound)
{
fileName = "~/data/sound/orc_pain.wav";
description = AudioClose3d;
preload = true;
};
//----------------------------------------------------------------------------
datablock AudioProfile(FootLightSoftSound)
{
filename = "~/data/sound/lgtstep_mono_01.ogg";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(FootLightHardSound)
{
filename = "~/data/sound/hvystep_ mono_01.ogg";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(FootLightMetalSound)
{
filename = "~/data/sound/metalstep_mono_01.ogg";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(FootLightSnowSound)
{
filename = "~/data/sound/snowstep_mono_01.ogg";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(FootLightShallowSplashSound)
{
filename = "~/data/sound/waterstep_mono_01.ogg";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(FootLightWadingSound)
{
filename = "~/data/sound/waterstep_mono_01.ogg";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(FootLightUnderwaterSound)
{
filename = "~/data/sound/waterstep_mono_01.ogg";
description = AudioClosest3d;
preload = true;
};
datablock AudioProfile(FootLightBubblesSound)
{
filename = "~/data/sound/replaceme.wav";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(ArmorMoveBubblesSound)
{
filename = "~/data/sound/replaceme.wav";
description = AudioCloseLooping3d;
preload = true;
};
datablock AudioProfile(WaterBreathMaleSound)
{
filename = "~/data/sound/replaceme.wav";
description = AudioClosestLooping3d;
preload = true;
};
//----------------------------------------------------------------------------
datablock AudioProfile(ImpactLightSoftSound)
{
filename = "~/data/sound/replaceme.wav";
description = AudioClose3d;
preload = true;
effect = ImpactSoftEffect;
};
datablock AudioProfile(ImpactLightHardSound)
{
filename = "~/data/sound/replaceme.wav";
description = AudioClose3d;
preload = true;
effect = ImpactHardEffect;
};
datablock AudioProfile(ImpactLightMetalSound)
{
filename = "~/data/sound/replaceme.wav";
description = AudioClose3d;
preload = true;
effect = ImpactMetalEffect;
};
datablock AudioProfile(ImpactLightSnowSound)
{
filename = "~/data/sound/replaceme.wav";
description = AudioClosest3d;
preload = true;
effect = ImpactSnowEffect;
};
datablock AudioProfile(ImpactLightWaterEasySound)
{
filename = "~/data/sound/replaceme.wav";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(ImpactLightWaterMediumSound)
{
filename = "~/data/sound/replaceme.wav";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(ImpactLightWaterHardSound)
{
filename = "~/data/sound/replaceme.wav";
description = AudioDefault3d;
preload = true;
};
datablock AudioProfile(ExitingWaterLightSound)
{
filename = "~/data/sound/replaceme.wav";
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);
//%light = new volumeLight() {
// dataBlock = "sgMountLight";
// rotation = "-0.357694 0.933839 9.9834e-009 180";
// scale = "1 1 1";
// dataBlock = "sgMountLight";
// Enable = "1";
// IconSize = "1";
// ParticleColorAttenuation = "1";
// Texture = "common/lighting/lightFalloffMono.png";
// lpDistance = "0.35";
// ShootDistance = "5";
// Xextent = "0.6";
// Yextent = "0.6";
// SubdivideU = "4";
// SubdivideV = "4";
// FootColour = "1.000000 1.000000 1.000000 0.182000";
// TailColour = "0.000000 0.000000 0.000000 0.000000";
//};
//%light.attachtoobject(%obj);
//%obj.light = %light;
}
function Armor::onRemove(%this, %obj)
{
if (%obj.client.player == %obj)
%obj.client.player = 0;
//if(isObject(%obj.light))
// %obj.light.delete();
}
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);
%obj.client.setObjectActiveImage(%vehicle, 2);
}
}
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);
// Position above dismount point
%obj.setTransform(%pos);
%obj.applyImpulse(%pos, VectorScale(%impulseVec, %obj.getDataBlock().mass));
%obj.setPilot(false);
%obj.vehicleTurret = "";
}
//----------------------------------------------------------------------------
function Armor::onCollision(%this,%obj,%col)
{
if (%obj.getState() $= "Dead")
return;
// Try and pickup all items
if (%col.getClassName() $= "Item")
%obj.pickup(%col);
// Mount vehicles
%this = %col.getDataBlock();
if ((%this.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);
}

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);
}
}
}

View File

@ -0,0 +1,503 @@
//-----------------------------------------------------------------------------
// Torque Game Engine
// Copyright (C) GarageGames.com, Inc.
//-----------------------------------------------------------------------------
// detail material mapping...
addMaterialMapping("Wall_filler101m" , "detail: starter.fps/data/interiors/lightingPack/wall_detail");
datablock DecalData(GlowDecal)
{
sizeX = 2;
sizeY = 2;
textureName = "starter.fps/data/shapes/lightingPack/Arrow";
SelfIlluminated = true;
LifeSpan = 1000000000;
};
//sgCreateDecal(clientgroup.getobject(0).getcontrolobject().getposition(), "", "", "", GlowDecal);
//sgDropDecal(spotlightleft.getposition(), "", "", "", GlowDecal);
datablock ScopeAlwaysShapeData(PipeScopeAlwaysShape)
{
category = "Pipe";
className = "PipeClass";
shapeFile = "~/data/shapes/lightingPack/pipe.dts";
};
//datablock ScopeAlwaysShapeData(SpotSwingScopeAlwaysShape)
//{
// category = "Lights";
// className = "SpotSwing";
// shapeFile = "~/data/shapes/lightingPack/spotswing.dts";
//};
datablock StaticShapeData(SpotSwingStaticShape)
{
category = "Lights";
className = "SpotSwing";
shapeFile = "~/data/shapes/lightingPack/spotswing.dts";
};
function SpotSwing::onAdd(%this, %obj)
{
%obj.playthread(0, "ambient");
%light = new volumeLight() {
dataBlock = "sgMountLight";
rotation = "-0.357694 0.933839 9.9834e-009 180";
scale = "1 1 1";
dataBlock = "sgMountLight";
Enable = "1";
IconSize = "1";
ParticleColorAttenuation = "1";
Texture = "common/lighting/lightFalloffMono.png";
lpDistance = "0.35";
ShootDistance = "5";
Xextent = "0.6";
Yextent = "0.6";
SubdivideU = "4";
SubdivideV = "4";
FootColour = "1.000000 1.000000 1.000000 0.182000";
TailColour = "0.000000 0.000000 0.000000 0.000000";
};
%light.attachtoobject(%obj);
}
datablock ItemData(sgCrossbow)
{
// 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 = sgCrossbowImage;
lightType = ConstantLight;
lightColor = "0.5 0.5 0.5";
lightRadius = 4;
};
//--------------------------------------------------------------------------
// 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(sgCrossbowImage)
{
// 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 = sgCrossbow;
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;
lightType = ConstantLight;
lightColor = "0.5 0.5 0.5";
lightRadius = 4;
};
datablock StaticShapeData(Tree2StaticShape)
{
category = "Trees";
className = "Tree2";
shapeFile = "~/data/shapes/trees/tree2.dts";
};
datablock ScopeAlwaysShapeData(Tree2ScopeAlwaysShape)
{
category = "Trees";
className = "Tree2SA";
shapeFile = "~/data/shapes/trees/tree2.dts";
};
datablock ParticleData(RealFireParticle)
{
textureName = "~/data/shapes/particles/smoke";
dragCoefficient = 0.0;
gravityCoefficient = -0.075; // rises slowly
inheritedVelFactor = 0.00;
lifetimeMS = 2000;
lifetimeVarianceMS = 0;
useInvAlpha = false;
spinRandomMin = -90.0;
spinRandomMax = 90.0;
colors[0] = "0.6 0.2 0.0 1.0";
colors[1] = "0.6 0.2 0.0 1.0";
colors[2] = "0.2 0.0 0.0 0.0";
sizes[0] = 0.9;
sizes[1] = 0.75;
sizes[2] = 0.3;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(RealFireEmitter)
{
ejectionPeriodMS = 200;
periodVarianceMS = 0;
ejectionVelocity = 0.07;
velocityVariance = 0.00;
thetaMin = 1.0;
thetaMax = 100.0;
particles = "RealFireParticle";
};
datablock ParticleData(RealFireSmallParticle)
{
textureName = "~/data/shapes/particles/smoke";
dragCoefficient = 0.0;
gravityCoefficient = -0.05; // rises slowly
inheritedVelFactor = 0.00;
lifetimeMS = 2000;
lifetimeVarianceMS = 0;
useInvAlpha = false;
spinRandomMin = -90.0;
spinRandomMax = 90.0;
colors[0] = "0.6 0.2 0.0 1.0";
colors[1] = "0.6 0.2 0.0 1.0";
colors[2] = "0.2 0.0 0.0 0.0";
sizes[0] = 0.6;
sizes[1] = 0.5;
sizes[2] = 0.1;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(RealFireSmallEmitter)
{
ejectionPeriodMS = 200;
periodVarianceMS = 0;
ejectionVelocity = 0.07;
velocityVariance = 0.00;
thetaMin = 1.0;
thetaMax = 100.0;
particles = "RealFireSmallParticle";
};
datablock ParticleData(RealFireBigParticle)
{
textureName = "~/data/shapes/particles/smoke";
dragCoefficient = 0.0;
gravityCoefficient = -0.15; // rises slowly
inheritedVelFactor = 0.00;
lifetimeMS = 2000;
lifetimeVarianceMS = 0;
useInvAlpha = false;
spinRandomMin = -90.0;
spinRandomMax = 90.0;
colors[0] = "0.6 0.2 0.0 1.0";
colors[1] = "0.6 0.2 0.0 1.0";
colors[2] = "0.2 0.0 0.0 0.0";
sizes[0] = 2.0;
sizes[1] = 1.6;
sizes[2] = 0.75;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(RealFireBigEmitter)
{
ejectionPeriodMS = 200;
periodVarianceMS = 0;
ejectionVelocity = 0.07;
velocityVariance = 0.00;
thetaMin = 2.0;
thetaMax = 200.0;
particles = "RealFireBigParticle";
};
datablock ParticleEmitterNodeData(RealFireNode)
{
timeMultiple = 1;
};
datablock ParticleData(SparkParticle)
{
textureName = "~/data/shapes/particles/smoke";
dragCoefficient = 4.0;
gravityCoefficient = 0.2; // rises slowly
inheritedVelFactor = 0.00;
lifetimeMS = 1000;
lifetimeVarianceMS = 750;
useInvAlpha = false;
spinRandomMin = 0.0;
spinRandomMax = 0.0;
colors[0] = "0.6 0.6 0.6 1.0";
colors[1] = "0.6 0.6 0.6 1.0";
colors[2] = "0.0 0.0 0.0 0.0";
sizes[0] = 0.2;
sizes[1] = 0.15;
sizes[2] = 0.1;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(SparkEmitter)
{
ejectionPeriodMS = 200;
periodVarianceMS = 100;
ejectionVelocity = 1.50;
velocityVariance = 0.50;
thetaMin = 0.0;
thetaMax = 0.0;
particles = "SparkParticle";
};
datablock ParticleEmitterNodeData(SparkNode)
{
timeMultiple = 1;
};
datablock ParticleData(TriggeredFireParticle)
{
textureName = "~/data/shapes/particles/smoke";
dragCoefficient = 0.0;
gravityCoefficient = -0.075; // rises slowly
inheritedVelFactor = 0.00;
lifetimeMS = 2000;
lifetimeVarianceMS = 0;
useInvAlpha = false;
spinRandomMin = -90.0;
spinRandomMax = 90.0;
colors[0] = "0.0 0.0 0.0 1.0";
colors[1] = "0.0 0.0 0.0 1.0";
colors[2] = "0.0 0.0 0.0 0.0";
sizes[0] = 0.9;
sizes[1] = 0.75;
sizes[2] = 0.3;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData(TriggeredFireEmitter)
{
ejectionPeriodMS = 500;
periodVarianceMS = 0;
ejectionVelocity = 0.07;
velocityVariance = 0.00;
thetaMin = 1.0;
thetaMax = 100.0;
particles = "TriggeredFireParticle";
};
datablock TriggerData(sgParticleEmitterTriggerDataBlock)
{
// 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 sgParticleEmitterTriggerDataBlock::sgResetTriggeredFireEmitter()
{
TriggeredFireParticle.colors[0] = "0.0 0.0 0.0 1.0";
TriggeredFireParticle.colors[1] = "0.0 0.0 0.0 1.0";
TriggeredFireEmitter.ejectionPeriodMS = 750;
}
function sgParticleEmitterTriggerDataBlock::onEnterTrigger(%this,%trigger,%obj)
{
TriggeredFireParticle.colors[0] = "0.6 0.2 0.0 1.0";
TriggeredFireParticle.colors[1] = "0.6 0.2 0.0 1.0";
TriggeredFireEmitter.ejectionPeriodMS = 200;
Parent::onEnterTrigger(%this,%trigger,%obj);
}
function sgParticleEmitterTriggerDataBlock::onLeaveTrigger(%this,%trigger,%obj)
{
TriggeredFireEmitter.ejectionPeriodMS = 3500;
Parent::onLeaveTrigger(%this,%trigger,%obj);
%this.schedule(3000, "sgResetTriggeredFireEmitter");
}
datablock ParticleData(SteamParticle)
{
animateTexture = "0";
animTexName[0] = "starter.fps/data/shapes/particles/smoke";
colors[0] = "1.000000 1.000000 1.000000 0.551180";
colors[1] = "1.000000 1.000000 1.000000 0.2055118";
colors[2] = "1.000000 1.000000 1.000000 0.000000";
colors[3] = "1.000000 1.000000 1.000000 1.000000";
constantAcceleration = "0.1";
dragCoefficient = "0.44";
framesPerSec = "1";
gravityCoefficient = "0.0";
inheritedVelFactor = "0";
lifetimeMS = "3022";
lifetimeVarianceMS = "320";
allowLighting = "1";
sizes[0] = "0.6";
sizes[1] = "0.74";
sizes[2] = "1.49";
sizes[3] = "1";
spinRandomMax = "35";
spinRandomMin = "-100";
spinSpeed = "0.29";
textureName = "starter.fps/data/shapes/particles/smoke";
times[0] = "0";
times[1] = "0.49";
times[2] = "1";
times[3] = "1";
useInvAlpha = "1";
windCoefficient = "1";
};
datablock ParticleEmitterData(SteamEmitter)
{
className = "ParticleEmitterData";
ejectionOffset = "0.09";
ejectionPeriodMS = "40";
ejectionVelocity = "2";
lifetimeMS = "0";
lifetimeVarianceMS = "0";
orientOnVelocity = "1";
orientParticles = "0";
overrideAdvance = "0";
particles = "SteamParticle";
periodVarianceMS = "10";
phiReferenceVel = "0";
phiVariance = "360";
thetaMax = "15.0";
thetaMin = "0";
useEmitterColors = "0";
useEmitterSizes = "0";
velocityVariance = "0";
};
datablock ParticleEmitterNodeData(SteamEmitterNode)
{
timeMultiple = 1;
};
//-----------------------------------------------------------------------------

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.
}

View File

@ -0,0 +1,19 @@
//-----------------------------------------------------------------------------
// 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;
}

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);
}

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.wav";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(WeaponPickupSound)
{
filename = "~/data/sound/weapon_pickup.wav";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(AmmoPickupSound)
{
filename = "~/data/sound/ammo_mono_01.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);
}
}