TribesReplay/base/scripts/turret.cs
Robert MacGregor b1941454ec v22228 (04/06/01):
* Fixed a problem that could have caused texture leaking in the interiors
* Fixed an AI problem in Training 2
* Chinese "simplified" keyboard supported
* Korean keyboard supported
* A bug where infinite ammo could be gained by tossing the ammo was prevented.
* Fixed a problem in Training 2 where a waypoint wouldn't update properly.
* Thundersword and Havoc hold steady now when players try to jump in so they don't invert and detonate.
* CD is now required in the drive for on-line play.
* Scoring has been fixed so that it isn't blanked any longer if the admin changes the time limit during a game.
* Active server queries will be cancelled now when you join a game (loads game faster now).
* If standing in an inventory station when it is destroyed you no longer permanently lose weapons.
* Fixed two issues that *could* cause crashes.
* Fixed a problem where the bombardier could create a permanent targeting laser.
* Cleaned up Chat text to remove programming characters.
* Fixed "highlight text with my nick" option so it saves preference to file correctly.
* Made MPB able to climb hills more easily and reduced damage from impact with the ground.
* Added button to stop server queries in progress on "JOIN" screen.
* Observers can now only chat with other observers (no one else can hear them).
* Made deployable inv stations have smaller trigger so they don't "suck you in" from so far away.
* Bots will now claim switches in CnH more accurately.
* Added a "max distance" ring for sensors on the commander map so players can more accurately assess how well they placed the sensor in relation to how much area it is actually sensing.
* Added a "ding" sound when you have filled up a text buffer so that you know why your text isn't showing up.
* Fixed Chat HUD so that page up/page down works better.
* Fixed a situation where Heavies could end up being permanently cloaked.
* The MPBs on the "Alcatraz" map now deploy correctly (Siege map).
* The "edited post" date stamp now works correctly.
* If you jump into a vehicle while zoomed in, the zoom will reset correctly therafter now.
* The Score Screen (F2) is now available while in a vehicle.
* You can now vote to kick observers, if desired.
* The ELF turret is fixed so it no longer fires at players when destroyed (an intermittent bug)
* Some console spam associated with the Wildcat has been removed.
* There was a situation where a player could die twice if he fell out of bounds. That has been resolved.
* Screen resolution information should update properly now when restarting the application.
* The camera should no longer be able to dip below terrain when in third person mode.
2017-07-17 23:05:21 -04:00

341 lines
No EOL
9.3 KiB
C#

//--------------------------------------------------------------------------
// Shockwave
//--------------------------------------------------------------------------
datablock ShockwaveData(TurretShockwave)
{
width = 6.0;
numSegments = 20;
numVertSegments = 2;
velocity = 8;
acceleration = 20.0;
lifetimeMS = 1500;
height = 1.0;
verticalCurve = 0.5;
mapToTerrain = false;
renderBottom = true;
texture[0] = "special/shockwave4";
texture[1] = "special/gradient";
texWrap = 6.0;
times[0] = 0.0;
times[1] = 0.5;
times[2] = 1.0;
colors[0] = "0.8 0.8 0.8 1.00";
colors[1] = "0.8 0.5 0.2 0.20";
colors[2] = "1.0 0.5 0.5 0.0";
};
//--------------------------------------------------------------------------
// Explosion
//--------------------------------------------------------------------------
datablock ExplosionData(TurretExplosion)
{
explosionShape = "effect_plasma_explosion.dts";
soundProfile = ShapeExplosionSound;
faceViewer = true;
shockwave = TurretShockwave;
};
datablock ExplosionData(SmallTurretExplosion)
{
soundProfile = DeployablesExplosionSound;
faceViewer = true;
explosionShape = "effect_plasma_explosion.dts";
sizes[0] = "0.3 0.3 0.3";
sizes[1] = "0.3 0.3 0.3";
times[0] = 0;
times[1] = 1;
};
//--------------------------------------------------------------------------
// Turret Debris
//--------------------------------------------------------------------------
datablock DebrisData( TurretDebris )
{
explodeOnMaxBounce = false;
elasticity = 0.20;
friction = 0.5;
lifetime = 17.0;
lifetimeVariance = 0.0;
minSpinSpeed = 60;
maxSpinSpeed = 600;
numBounces = 10;
bounceVariance = 0;
staticOnMaxBounce = true;
useRadiusMass = true;
baseRadius = 0.4;
velocity = 9.0;
velocityVariance = 4.5;
};
datablock DebrisData( TurretDebrisSmall )
{
explodeOnMaxBounce = false;
elasticity = 0.20;
friction = 0.5;
lifetime = 17.0;
lifetimeVariance = 0.0;
minSpinSpeed = 60;
maxSpinSpeed = 600;
numBounces = 10;
bounceVariance = 0;
staticOnMaxBounce = true;
useRadiusMass = true;
baseRadius = 0.2;
velocity = 5.0;
velocityVariance = 2.5;
};
//--------------------------------------------------------------------------
// Turret base class functionality. Barrels are in scripts/weapons/*.cs
//
//
//--------------------------------------------------------------------------
function TurretData::create(%block)
{
%obj = new Turret() {
dataBlock = %block;
};
return %obj;
}
datablock SensorData(TurretBaseSensorObj)
{
detects = true;
detectsUsingLOS = true;
detectsPassiveJammed = false;
detectsActiveJammed = false;
detectsCloaked = false;
detectionPings = true;
detectRadius = 80;
};
datablock TurretData(TurretBaseLarge) : TurretDamageProfile
{
className = TurretBase;
catagory = "Turrets";
shapeFile = "turret_base_large.dts";
preload = true;
mass = 1.0; // Not really relevant
maxDamage = 2.25;
destroyedLevel = 2.25;
disabledLevel = 1.35;
explosion = TurretExplosion;
expDmgRadius = 15.0;
expDamage = 0.7;
expImpulse = 2000.0;
repairRate = 0;
emap = true;
thetaMin = 15;
thetaMax = 140;
isShielded = true;
energyPerDamagePoint = 50;
maxEnergy = 150;
rechargeRate = 0.31;
humSound = SensorHumSound;
pausePowerThread = true;
canControl = true;
cmdCategory = "Tactical";
cmdIcon = CMDTurretIcon;
cmdMiniIconName = "commander/MiniIcons/com_turretbase_grey";
targetNameTag = 'Base';
targetTypeTag = 'Turret';
sensorData = TurretBaseSensorObj;
sensorRadius = TurretBaseSensorObj.detectRadius;
sensorColor = "0 212 45";
firstPersonOnly = true;
debrisShapeName = "debris_generic.dts";
debris = TurretDebris;
};
function TurretData::onGainPowerEnabled(%data, %obj)
{
Parent::onGainPowerEnabled(%data, %obj);
setTargetSensorData(%obj.target, %data.sensorData);
}
function TurretData::onLosePowerDisabled(%data, %obj)
{
// Must kick players out of turret
Parent::onLosePowerDisabled(%data, %obj);
%obj.clearTarget();
setTargetSensorData(%obj.target, 0);
}
function TurretData::selectTarget(%this, %turret)
{
%turretTarg = %turret.getTarget();
if(%turretTarg == -1)
return;
// if the turret isn't on a team, don't fire at anyone
if(getTargetSensorGroup(%turretTarg) == 0)
{
%turret.clearTarget();
return;
}
// stop firing if turret is disabled or if it needs power and isn't powered
if((!%turret.isPowered()) && (!%turret.needsNoPower))
{
%turret.clearTarget();
return;
}
%TargetSearchMask = $TypeMasks::PlayerObjectType | $TypeMasks::VehicleObjectType;
InitContainerRadiusSearch(%turret.getMuzzlePoint(0),
%turret.getMountedImage(0).attackRadius,
%TargetSearchMask);
while ((%potentialTarget = ContainerSearchNext()) != 0)
{
%potTargTarg = %potentialTarget.getTarget();
if (%turret.isValidTarget(%potentialTarget) && (getTargetSensorGroup(%turretTarg) != getTargetSensorGroup(%potTargTarg)))
{
%turret.setTargetObject(%potentialTarget);
return;
}
}
}
function TurretData::replaceCallback(%this, %turret, %engineer)
{
// First, is the player in range?
%pos = %turret.getWorldBoxCenter();
%engineerPos = %engineer.getWorldBoxCenter();
%len = VectorLen(VectorSub(%pos, %engineerPos));
if (%len < 5)
{
// This is a valid replacement. First, let's see if the engineer
// still has the correct pack in place...
if (%engineer.getMountedImage($BackPackSlot) != 0)
{
%barrel = %engineer.getMountedImage($BackPackSlot).turretBarrel;
if (%barrel !$= "")
{
// if there was a barrel there before, get rid of it
%turret.unmountImage(0);
// remove the turret barrel pack
%engineer.setInventory(%engineer.getMountedImage($BackPackSlot).item, 0);
// mount new barrel on base
%turret.mountImage(%barrel, 0, false);
}
else
{
// Player doesn't have the correct pack on...
}
}
else
{
// Player doesn't have any pack on...
}
}
else
{
// Player is too far away to replace the barrel...
}
}
function TurretData::onDestroyed(%this, %turret, %prevState)
{
if( isObject( %turret.lastProjectile ) )
%turret.lastProjectile.delete();
Parent::onDestroyed(%this, %turret, %prevState);
}
function checkTurretMount(%data, %obj, %slot)
{
// search for a turret base in player's LOS
%eyeVec = VectorNormalize(%obj.getEyeVector());
%srchRange = VectorScale(%eyeVec, 5.0); // look 5m for a turret base
%plTm = %obj.getEyeTransform();
%plyrLoc = firstWord(%plTm) @ " " @ getWord(%plTm, 1) @ " " @ getWord(%plTm, 2);
%srchEnd = VectorAdd(%plyrLoc, %srchRange);
%potTurret = ContainerRayCast(%obj.getEyeTransform(), %srchEnd, $TypeMasks::TurretObjectType);
if(%potTurret != 0)
{
if(%potTurret.getDatablock().getName() $= "TurretBaseLarge")
{
// found a turret base, what team is it on?
if(%potTurret.team == %obj.client.team)
{
if(%potTurret.getDamageState() !$= "Enabled")
{
// the base is destroyed
messageClient(%obj.client, 'MsgBaseDestroyed', "\c2Turret base is disabled, cannot mount barrel.");
%obj.setImageTrigger($BackpackSlot, false);
}
else
{
// it's a functional turret base on our team! stick the barrel on it
messageClient(%obj.client, 'MsgTurretMount', "\c2Mounting barrel pack on turret base.");
serverPlay3D(TurretPackActivateSound, %potTurret.getTransform());
%potTurret.initiateBarrelSwap(%obj);
}
}
else
{
// whoops, wrong team
messageClient(%obj.client, 'MsgTryEnemyTurretMount', "\c2Cannot mount a barrel on an enemy turret base!");
%obj.setImageTrigger($BackpackSlot, false);
}
}
else
{
// tried to mount barrel on some other turret type
messageClient(%obj.client, 'MsgNotTurretBase', "\c2Can only mount a barrel on a turret base.");
%obj.setImageTrigger($BackpackSlot, false);
}
}
else
{
// I don't see any turret
messageClient(%obj.client, 'MsgNoTurretBase', "\c2No turret within range.");
%obj.setImageTrigger($BackpackSlot, false);
}
}
//-------------------------------------- Load Barrel Images
//
exec("scripts/turrets/mortarBarrelLarge.cs");
exec("scripts/turrets/aaBarrelLarge.cs");
exec("scripts/turrets/missileBarrelLarge.cs");
exec("scripts/turrets/plasmaBarrelLarge.cs");
exec("scripts/turrets/ELFBarrelLarge.cs");
exec("scripts/turrets/outdoorDeployableBarrel.cs");
exec("scripts/turrets/indoorDeployableBarrel.cs");
exec("scripts/turrets/sentryTurret.cs");