//-----------------------------------------------------------------------------
// Realm Wars - Team Objective Module
//
// Author: James Lupiani (JL) <defiant@flyingtemple.com> and Phil Carlisle
// Created: 21 Mar 2002 (JL)
// Revised: 22 Mar 2002 (JL)
//
// Notes: This is a hack, but it more or less works.
// - It will have to be overhauled once team support is fully in.
// The number and names of teams and the number of objectives to win
// are right in here. That sort of info should come from the mission.
//
// - If the mission time runs out, the number of objectives from the
// last mission will remain. See above note for suggested fix. +)
//
// - Does the particle emitter need to be added to MissionCleanup?
//
// - Isn't there a cleaner way of implementing smoke that's simply
// a different color?
//
// Copyright (c) 2001 GarageGames.Com
//-----------------------------------------------------------------------------
// Trigger count
$Game::TeamObjectives[1] = 0;
$Game::TeamObjectives[2] = 0;
$Game::TeamScores[1] = 0;
$Game::TeamScores[2] = 0;
$Game::TeamFlagCaptures[1] = 0;
$Game::TeamFlagCaptures[2] = 0;
$Game::PointsForCapture = 50;
//--------------------------------------------------------------
// Particle data
//--------------------------------------------------------------
datablock ParticleData( ObjectiveSmoke )
{
textureName = "~/data/shapes/particles/smoke";
dragCoeffiecient = 0.0;
gravityCoefficient = -0.5; // rises slowly
inheritedVelFactor = 0.00;
lifetimeMS = 3500;
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] = 1.75;
sizes[1] = 2.0;
sizes[2] = 3.25;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
};
datablock ParticleEmitterData( ObjectiveSmokeEmitter )
{
ejectionPeriodMS = 20;
periodVarianceMS = 5;
ejectionVelocity = 0.25;
velocityVariance = 0.10;
thetaMin = 0.0;
thetaMax = 90.0;
particles = ObjectiveSmoke;
};
datablock ParticleEmitterNodeData( ObjectiveEmitterNode )
{
timeMultiple = 1;
};
//--------------------------------------------------------------
// Derived particle datablocks
//--------------------------------------------------------------
datablock ParticleData( RedObjSmoke : ObjectiveSmoke )
{
colors[0] = "1.0 0.2 0.2 0.1";
colors[1] = "1.0 0.3 0.3 0.1";
colors[2] = "1.0 0.4 0.4 0.0";
};
datablock ParticleData( BlueObjSmoke : ObjectiveSmoke )
{
colors[0] = "0.2 0.2 1.0 0.1";
colors[1] = "0.3 0.3 1.0 0.1";
colors[2] = "0.4 0.4 1.0 0.0";
};
datablock ParticleEmitterData( RedObjSmokeEmitter : ObjectiveSmokeEmitter )
{
particles = RedObjSmoke;
};
datablock ParticleEmitterData( BlueObjSmokeEmitter : ObjectiveSmokeEmitter )
{
particles = BlueObjSmoke;
};
//--------------------------------------------------------------
// Trigger datablock
//--------------------------------------------------------------
datablock TriggerData(TeamTrigger)
{
tickPeriodMS = 100;
team = -1;
teamEmitter = 0;
};
//--------------------------------------------------------------
// Events
//--------------------------------------------------------------
function TeamTrigger::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 );
// Does the objective belong to the capper's team?
if( %obj.client.team != %trigger.team )
{
// Has this objective been taken yet?
if( %trigger.team != -1 )
{
// Someone's had this before. Switch team scores
// and remove the emitter.
$Game::TeamObjectives[%trigger.team]--;
$Game::TeamObjectives[%obj.client.team]++;
%trigger.teamEmitter.delete();
}
else
{
// Just give the object's team a point.
$Game::TeamObjectives[%obj.client.team]++;
}
// Make a new particle emitter for the capping team.
if( %obj.client.team == 1 )
{
%trigger.teamEmitter = new ParticleEmitterNode(%trigger.getName() @ "Emitter")
{
position = %trigger.getWorldBoxCenter();
datablock = ObjectiveEmitterNode;
emitter = RedObjSmokeEmitter;
velocity = 1;
};
}
else if( %obj.client.team == 2 )
{
%trigger.teamEmitter = new ParticleEmitterNode(%trigger.getName() @ "Emitter")
{
position = %trigger.getWorldBoxCenter();
datablock = ObjectiveEmitterNode;
emitter = BlueObjSmokeEmitter;
velocity = 1;
};
}
// Do the actual claiming.
%trigger.team = %obj.client.team;
messageAll( 'MsgObjective', '\c2Team %1 took an objective!', %obj.client.team );
messageAll( 'MsgObjective', '\c2Skarj Objectives: %1, Krall Objectives: %2', $Game::TeamObjectives[1], $Game::TeamObjectives[2] );
}
}
function TeamTrigger::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 TeamTrigger::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 );
echo("TeamTrigger: " @ %this.getClassName());
// PC: added in to make things a bit more fun.. adds ammo to the player
// as long as they are in thier own trigger.
for (%i = 0; %i < %trigger.getNumObjects(); %i++)
{
%obj = %trigger.getName().getObject(%i);
echo("object: " @ %i @ " " @ %obj.getClassName());
if (%obj.client.team == %trigger.team)
{
// give ammo to this guy.. he's on our "team" :)
%obj.incInventory(CrossbowAmmo,20);
}
else
{
echo("Cant get ammo at a spawn that aint yours!");
}
}
}