TribesReplay/base/scripts/deployables.cs
Robert MacGregor b58ea2862a v22755 (05/11/01):
- (optimization) Damage Decal toggle applies to ALL damage decals now. This improves performance on video cards with lower VRAM. Those cards should turn this feature OFF for best gameplay.

- (optimization) Dynamic lighting now fades with distance so that systems do less calculations on lights that make little or no difference anyway.

- (optimization) The following missions were edited/revised in order to achieve much higher framerates in-game. They are:
	Death Birds Fly
	Dust to Dust
	Recalascence
	Reversion
	Riverdance

- (optimization) There is now a PARTICLE DENSITY slider on the GRAPHICS menu that allows you to turn down the number of particles used in explosions and weapon effects. Systems with low VRAM should turn this down as low as possible. The effects will still look good, but will use many less polygons and alpha translucencies.

- (optimization) The force shield effect on players and objects has been greatly simplified. The old effect was hammering the frame rates on older video cards when played. This new effect greatly speeds gameplay on all cards, and particularly on Voodoo cards.

- (memory leak) Memory leaks were located and eradicated. This most likely was the cause of the "degradation over time" that folks were experiencing on their servers.

- (bug fix) "Vote Spamming" has been prevented in-game.

- (bug fix) Moved some of the CD check from script into code, where it should be.

- (bug fix) The "sticking" mouse button problem is now fixed.

- (bug fix) Deployables are now easier to place on walls and other surfaces. There were some inconsistencies on which surfaces could be placed upon and those are now resolved.

- (bug fix) There was a bug that prevented users from deleting some Server Filters. That is resolved now.

- (bug fix) There was a Siege bug where a base item (like a turret) could be destroyed, and then repaired, but it would no longer receive power after being repaired. That is now fixed. The items will receive power correctly after being repaired.

- (bug fix) Resolved the Team Damage OFF situation where friendly troops could destroy permanent "base" objects.

- (bug fix) Removed a packet overrun in the net code that *could* have allowed hackers to bring down servers. This had not occurred to date and is now prevented.

- (bug fix) Deployable inventory stations can no longer be deployed directly next to each other. They must be at least 20 meters apart in order to be deployed properly.

- (bug fix) Ejection speed increased slightly to more easily accomodate jumping out of moving vehicles.

- (bug fix) Many team damage fixes occurred. When Team Damage is OFF the following are now true: Friendly teammates are no longer prevented from destroying deployables. The ELF will no longer drain energy from friendly players. If a friendly player blinds another friendly player with Whiteout grenades, then a message is displayed in the Chat HUD so that the blinded person knows who did it. (There are more Team Damage changes coming in the next patch.)

- (bug fix) Medium now has a standard loadout of 12 grenades in the grenade launcher instead of 10. Light: 10; Medium: 12; Heavy: 15.

- (bug fix) Deployable pulse sensors now have a range of 150m instead of 120m to make them a more attractive option to deploy.

- (bug fix) Fixed an indoor turret proximity bug introduced in the last patch.

- (improvement) Flag captures are now worth 100 points (for the team), instead of 1 point. Additionally, each time someone grabs the flag *from the enemy flag stand* they will gain 1 point (for the team), regardless of whether they actually capture it or not. You will ONLY get this single point if the flag was actually on the flagstand. You will NOT get the point by touching the flag anywhere else on the field. This change will help prevent tie situations and will reward aggressive offensive play.
NOTE: The "touch" point can only be gained once every 20 seconds...so a "scrum" around the flag base will not result in a large group of points being gained.

- (improvement) Siege: Alcatraz. The generators have been moved around a bit. There are two entrances to that base. One is the "front door" and the other is the "back door". (The back door is the one that has a team-pass-only force field blocking enemies from the switch room.) There is now an upper generator down the chute from the "front door" that powers the "back door" force field. Additionally, there is a solar panel outside that powers the base turrets and sentry turrets. None of these generators have to be destroyed to get to the switch, but their destruction makes it MUCH easier to do so. There are four generators total on this map (all are waypointed now), and the destruction of all four is necessary before the base power will go down.

- (improvement) Siege: Caldera. The generator has been moved out of the switch room and into the very big main room that has the inventory stations in it. It is no longer necessary to destroy the generators in a particular sequence. Destroying the two main generators (Primary and Secondary) will drop the force field that protects the switch. Both gens must be down in order for the switch force field to drop.

- (improvement) Added "quickbuy" keyboard shortcuts to use at vehicle station. (Default keys are the 1-6 number keys. 1 is the top vehicle on the list, 6 is the bottom vehicle on the list).
NOTE: These key bindings are not currently editable. However, since you are on the vehicle purchase pad when they are in effect, they cannot interfere with any custom keys you've created, so you should have no problems.

- (improvement) Team Damage ON/OFF can be changed by Admins/SuperAdmins as well as being voted on by players. If you are an Admin or SuperAdmin, then just go to Lobby and look up where the "Vote" options are listed. There are options there to toggle the Team Damage flag. Regular players can also Vote to Enable/Disable Team Damage in the same spot.

- (improvement) Default server prefs have been changed so that the default time limit is now 30 minutes (instead of 20) and Team Damage is OFF.

- (improvement) Fixed buddy filter. You can now use the Filter option on the JOIN screen to find games that have players in them that are listed on your buddy list. (Use the Email or Warrior Browser functions to add/remove people from your buddy list.)
NOTE: We feel that there is an issue that may be related to NAT (Network Address Translation). Sierra QA uses public IP addresses on it's internal network that are not routable on the Internet.  They experience a problem that occurs when anyone inside their firewall uses the Internet for anything, their internal address is "changed" to a legal external address. In their case, they use "many to one" NAT, so everyone appears to be the same address outside our walls. This issue prevents Sierra QA from seeing "buddies" that are on systems *inside* their firewall (they can see "buddies" on external servers just fine). We are hypothesizing that it is NAT that is causing the buddy list lookup to fail internally. We are continuing to work on this.
ALSO NOTE: This feature works correctly for everyone else.

- (improvement) You can now add a player to your server admin lists (so that server admins can auto-admin players when they join a server, if desired). How this is done: If you are a SuperAdmin (owner of the server), you can go into the lobby and right-click on a player's name. You will then have the ability to add them to your Admin or SuperAdmin lists.

- (improvement) Master Server list no longer insists on keeping your current game highlighted while refreshing a query. This allows you to page up and down more easily on the list while it is refreshing.

- (improvement) Added "Team Damage ON/OFF" and "Windows/Linux" as options for creating new Server Filters.

- (improvement) Missile reticle is improved aesthetically. This is part 1 of 2 of the missile reticle changes. The second part will be in the next patch.

- (community) Made changes to Tribe Forums to make posting new topics work better with the current cache architecture.

- (community) Fixed buttons on Tribe/Warrior Browser to reflect visitors membership in tribe

- (community) Changed NEWS button on Tribe page to OPTIONS, added links to Tribe Forum, Tribe Public Chat and Tribe Private Chat.

- (community) Added "EMail" and "Add To Buddylist" options into the right click menu in the Chat Channel member list.

- (community) Changed layout of right click menu's in the Community for easier understandability.

- (community) Added Moderator functions to the T2 Community - allows post removal, ability to send warnings and execute ban's to the perp.

- (community) Added confirmation box to the News page on Submit News - explains purpose and requires yes/no.

- (community) Upgraded Forum Cache version

- (community) Added ability to Lock Topic for Moderators

- (community) Added locking for posts where Topic is already in cache.

- (community) Implemented a ban structure on the Database

- (community) Fixed DBProxy thread disconnections - removed blank error boxes.

- (community) Fixed bug in Blocking Email Senders
2017-07-17 23:17:32 -04:00

1289 lines
40 KiB
C#

// deployable objects script
//
// remote pulse sensor, remote motion sensor, remote turrets (indoor
// and outdoor), remote inventory station, remote ammo station
// Note: cameras are treated as grenades, not "regular" deployables
$TurretIndoorSpaceRadius = 20; // deployed turrets must be this many meters apart
$InventorySpaceRadius = 20; // deployed inventory must be this many meters apart
$TurretIndoorSphereRadius = 50; // radius for turret frequency check
$TurretIndoorMaxPerSphere = 4; // # of turrets allowed in above radius
$TurretOutdoorSpaceRadius = 25; // deployed turrets must be this many meters apart
$TurretOutdoorSphereRadius = 60; // radius for turret frequency check
$TurretOutdoorMaxPerSphere = 4; // # of turrets allowed in above radius
$TeamDeployableMax[InventoryDeployable] = 5;
$TeamDeployableMax[TurretIndoorDeployable] = 10;
$TeamDeployableMax[TurretOutdoorDeployable] = 10;
$TeamDeployableMax[PulseSensorDeployable] = 15;
$TeamDeployableMax[MotionSensorDeployable] = 15;
$TeamDeployableMin[TurretIndoorDeployable] = 4;
$TeamDeployableMin[TurretOutdoorDeployable] = 4;
$NotDeployableReason::None = 0;
$NotDeployableReason::MaxDeployed = 1;
$NotDeployableReason::NoSurfaceFound = 2;
$NotDeployableReason::SlopeTooGreat = 3;
$NotDeployableReason::SelfTooClose = 4;
$NotDeployableReason::ObjectTooClose = 5;
$NotDeployableReason::NoTerrainFound = 6;
$NotDeployableReason::NoInteriorFound = 7;
$NotDeployableReason::TurretTooClose = 8;
$NotDeployableReason::TurretSaturation = 9;
$NotDeployableReason::SurfaceTooNarrow = 10;
$NotDeployableReason::InventoryTooClose = 11;
$MinDeployableDistance = 0.5;
$MaxDeployableDistance = 4.0; //meters from body
// --------------------------------------------
// sound datablocks
// --------------------------------------------
datablock AudioProfile(TurretDeploySound)
{
fileName = "fx/packs/turret_place.wav";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(SensorDeploySound)
{
fileName = "fx/powered/sensor_activate.wav";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(MotionSensorDeploySound)
{
fileName = "fx/powered/motion_sensor_activate.wav";
description = AudioClose3d;
preload = true;
};
datablock AudioProfile(StationDeploySound)
{
fileName = "fx/packs/inventory_deploy.wav";
description = AudioClose3d;
preload = true;
};
// --------------------------------------------
// deployable debris definition
datablock DebrisData( DeployableDebris )
{
explodeOnMaxBounce = false;
elasticity = 0.40;
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;
};
// --------------------------------------------
// deployable inventory station
datablock StaticShapeData(DeployedStationInventory) : StaticShapeDamageProfile
{
className = Station;
shapeFile = "deploy_inventory.dts";
maxDamage = 0.70;
destroyedLevel = 0.70;
disabledLevel = 0.42;
explosion = DeployablesExplosion;
dynamicType = $TypeMasks::StationObjectType;
isShielded = true;
energyPerDamagePoint = 110;
maxEnergy = 50;
rechargeRate = 0.20;
renderWhenDestroyed = false;
doesRepair = true;
deployedObject = true;
cmdCategory = "DSupport";
cmdIcon = CMDStationIcon;
cmdMiniIconName = "commander/MiniIcons/com_inventory_grey";
targetNameTag = 'Deployable';
targetTypeTag = 'Station';
debrisShapeName = "debris_generic_small.dts";
debris = DeployableDebris;
heatSignature = 0;
};
datablock ShapeBaseImageData(InventoryDeployableImage)
{
mass = 15;
emap = true;
shapeFile = "pack_deploy_inventory.dts";
item = InventoryDeployable;
mountPoint = 1;
offset = "0 0 0";
deployed = DeployedStationInventory;
heatSignature = 0;
stateName[0] = "Idle";
stateTransitionOnTriggerDown[0] = "Activate";
stateName[1] = "Activate";
stateScript[1] = "onActivate";
stateTransitionOnTriggerUp[1] = "Idle";
isLarge = true;
maxDepSlope = 30;
deploySound = StationDeploySound;
};
datablock ItemData(InventoryDeployable)
{
className = Pack;
catagory = "Deployables";
shapeFile = "pack_deploy_inventory.dts";
mass = 3.0;
elasticity = 0.2;
friction = 0.6;
pickupRadius = 1;
rotate = false;
image = "InventoryDeployableImage";
pickUpName = "an inventory pack";
heatSignature = 0;
computeCRC = true;
emap = true;
};
// --------------------------------------------
// deployable motion sensor
datablock SensorData(DeployMotionSensorObj)
{
detects = true;
detectsUsingLOS = true;
detectsActiveJammed = false;
detectsPassiveJammed = true;
detectsCloaked = true;
detectionPings = false;
detectMinVelocity = 2;
detectRadius = 60;
};
datablock StaticShapeData(DeployedMotionSensor) : StaticShapeDamageProfile
{
className = Sensor;
shapeFile = "deploy_sensor_motion.dts";
maxDamage = 0.6;
destroyedLevel = 0.6;
disabledLevel = 0.4;
explosion = DeployablesExplosion;
dynamicType = $TypeMasks::SensorObjectType;
deployedObject = true;
cmdCategory = "DSupport";
cmdIcon = CMDSensorIcon;
cmdMiniIconName = "commander/MiniIcons/com_deploymotionsensor";
targetNameTag = 'Deployable Motion';
targetTypeTag = 'Sensor';
sensorData = DeployMotionSensorObj;
sensorRadius = DeployMotionSensorObj.detectRadius;
sensorColor = "9 136 255";
deployAmbientThread = true;
debrisShapeName = "debris_generic_small.dts";
debris = DeployableDebris;
heatSignature = 0;
};
datablock ShapeBaseImageData(MotionSensorDeployableImage)
{
shapeFile = "pack_deploy_sensor_motion.dts";
item = MotionSensorDeployable;
mountPoint = 1;
offset = "0 0 0";
deployed = DeployedMotionSensor;
stateName[0] = "Idle";
stateTransitionOnTriggerDown[0] = "Activate";
stateName[1] = "Activate";
stateScript[1] = "onActivate";
stateTransitionOnTriggerUp[1] = "Idle";
maxDepSlope = 360;
deploySound = MotionSensorDeploySound;
emap = true;
heatSignature = 1;
};
datablock ItemData(MotionSensorDeployable)
{
className = Pack;
catagory = "Deployables";
shapeFile = "pack_deploy_sensor_motion.dts";
mass = 2.0;
elasticity = 0.2;
friction = 0.6;
pickupRadius = 1;
rotate = false;
image = "MotionSensorDeployableImage";
pickUpName = "a motion sensor pack";
computeCRC = true;
emap = true;
heatSignature = 0;
//maxSensors = 3;
maxSensors = 2;
};
// --------------------------------------------
// deployable pulse sensor
datablock SensorData(DeployPulseSensorObj)
{
detects = true;
detectsUsingLOS = true;
detectsPassiveJammed = false;
detectsCloaked = false;
detectionPings = true;
detectRadius = 150;
};
datablock StaticShapeData(DeployedPulseSensor) : StaticShapeDamageProfile
{
className = Sensor;
shapeFile = "deploy_sensor_pulse.dts";
maxDamage = 0.6;
destroyedLevel = 0.6;
disabledLevel = 0.4;
explosion = DeployablesExplosion;
dynamicType = $TypeMasks::SensorObjectType;
deployedObject = true;
cmdCategory = "DSupport";
cmdIcon = CMDSensorIcon;
cmdMiniIconName = "commander/MiniIcons/com_deploypulsesensor";
targetNameTag = 'Deployable';
targetTypeTag = 'Pulse Sensor';
sensorData = DeployPulseSensorObj;
sensorRadius = DeployPulseSensorObj.detectRadius;
sensorColor = "255 194 9";
deployAmbientThread = true;
debrisShapeName = "debris_generic_small.dts";
debris = DeployableDebris;
heatSignature = 0;
};
datablock ShapeBaseImageData(PulseSensorDeployableImage)
{
shapeFile = "pack_deploy_sensor_pulse.dts";
item = PulseSensorDeployable;
mountPoint = 1;
offset = "0 0 0";
deployed = DeployedPulseSensor;
stateName[0] = "Idle";
stateTransitionOnTriggerDown[0] = "Activate";
stateName[1] = "Activate";
stateScript[1] = "onActivate";
stateTransitionOnTriggerUp[1] = "Idle";
deploySound = SensorDeploySound;
maxDepSlope = 40;
emap = true;
heatSignature = 0;
};
datablock ItemData(PulseSensorDeployable)
{
className = Pack;
catagory = "Deployables";
shapeFile = "pack_deploy_sensor_pulse.dts";
mass = 2.0;
elasticity = 0.2;
friction = 0.6;
pickupRadius = 1;
rotate = false;
image = "PulseSensorDeployableImage";
pickUpName = "a pulse sensor pack";
computeCRC = true;
emap = true;
maxSensors = 2;
};
// --------------------------------------------
// deployable outdoor turret
datablock ShapeBaseImageData(TurretOutdoorDeployableImage)
{
mass = 15;
shapeFile = "pack_deploy_turreto.dts";
item = TurretOutdoorDeployable;
mountPoint = 1;
offset = "0 0 0";
deployed = TurretDeployedOutdoor;
stateName[0] = "Idle";
stateTransitionOnTriggerDown[0] = "Activate";
stateName[1] = "Activate";
stateScript[1] = "onActivate";
stateTransitionOnTriggerUp[1] = "Idle";
maxDamage = 4.5;
destroyedLevel = 4.5;
disabledLevel = 4.0;
isLarge = true;
emap = true;
maxDepSlope = 40;
deploySound = TurretDeploySound;
};
datablock ItemData(TurretOutdoorDeployable)
{
className = Pack;
catagory = "Deployables";
shapeFile = "pack_deploy_turreto.dts";
mass = 3.0;
elasticity = 0.2;
friction = 0.6;
pickupRadius = 1;
rotate = false;
image = "TurretOutdoorDeployableImage";
pickUpName = "a landspike turret pack";
computeCRC = true;
emap = true;
};
// --------------------------------------------
// deployable indoor turret (3 varieties -- floor, wall and ceiling)
datablock ShapeBaseImageData(TurretIndoorDeployableImage)
{
mass = 15;
shapeFile = "pack_deploy_turreti.dts";
item = TurretIndoorDeployable;
mountPoint = 1;
offset = "0 0 0";
stateName[0] = "Idle";
stateTransitionOnTriggerDown[0] = "Activate";
stateName[1] = "Activate";
stateScript[1] = "onActivate";
stateTransitionOnTriggerUp[1] = "Idle";
isLarge = true;
emap = true;
maxDepSlope = 360;
deploySound = TurretDeploySound;
};
datablock ItemData(TurretIndoorDeployable)
{
className = Pack;
catagory = "Deployables";
shapeFile = "pack_deploy_turreti.dts";
mass = 3.0;
elasticity = 0.2;
friction = 0.6;
pickupRadius = 1;
rotate = false;
image = "TurretIndoorDeployableImage";
pickUpName = "a spider clamp turret pack";
computeCRC = true;
emap = true;
};
// --------------------------------------------
// miscellaneous yet handy functions
function posFromTransform(%transform)
{
// the first three words of an object's transform are the object's position
%position = getWord(%transform, 0) @ " " @ getWord(%transform, 1) @ " " @ getWord(%transform, 2);
return %position;
}
function rotFromTransform(%transform)
{
// the last four words of an object's transform are the object's rotation
%rotation = getWord(%transform, 3) @ " " @ getWord(%transform, 4) @ " " @ getWord(%transform, 5) @ " " @ getWord(%transform, 6);
return %rotation;
}
function posFromRaycast(%transform)
{
// the 2nd, 3rd, and 4th words returned from a successful raycast call are the position of the point
%position = getWord(%transform, 1) @ " " @ getWord(%transform, 2) @ " " @ getWord(%transform, 3);
return %position;
}
function normalFromRaycast(%transform)
{
// the 5th, 6th and 7th words returned from a successful raycast call are the normal of the surface
%norm = getWord(%transform, 4) @ " " @ getWord(%transform, 5) @ " " @ getWord(%transform, 6);
return %norm;
}
function addToDeployGroup(%object)
{
// all deployables should go into a special group for AI purposes
%depGroup = nameToID("MissionCleanup/Deployables");
if(%depGroup <= 0) {
%depGroup = new SimGroup("Deployables");
MissionCleanup.add(%depGroup);
}
%depGroup.add(%object);
}
function Deployables::searchView(%obj, %searchRange, %mask)
{
// get the eye vector and eye transform of the player
%eyeVec = %obj.getEyeVector();
%eyeTrans = %obj.getEyeTransform();
// extract the position of the player's camera from the eye transform (first 3 words)
%eyePos = posFromTransform(%eyeTrans);
// normalize the eye vector
%nEyeVec = VectorNormalize(%eyeVec);
// scale (lengthen) the normalized eye vector according to the search range
%scEyeVec = VectorScale(%nEyeVec, %searchRange);
// add the scaled & normalized eye vector to the position of the camera
%eyeEnd = VectorAdd(%eyePos, %scEyeVec);
// see if anything gets hit
%searchResult = containerRayCast(%eyePos, %eyeEnd, %mask, 0);
return %searchResult;
}
//-----------------------//
// Deployable Procedures //
//-----------------------//
//-------------------------------------------------
function ShapeBaseImageData::testMaxDeployed(%item, %plyr)
{
if(%item.item $= TurretOutdoorDeployable || %item.item $= TurretIndoorDeployable)
%itemCount = countTurretsAllowed(%item.item);
else
%itemCount = $TeamDeployableMax[%item.item];
return $TeamDeployedCount[%plyr.team, %item.item] >= %itemCount;
}
//-------------------------------------------------
function ShapeBaseImageData::testNoSurfaceInRange(%item, %plyr)
{
return ! Deployables::searchView(%plyr, $MaxDeployableDistance, $TypeMasks::TerrainObjectType | $TypeMasks::InteriorObjectType);
}
//-------------------------------------------------
function ShapeBaseImageData::testSlopeTooGreat(%item)
{
if (%item.surface)
{
return getTerrainAngle(%item.surfaceNrm) > %item.maxDepSlope;
}
}
//-------------------------------------------------
function ShapeBaseImageData::testSelfTooClose(%item, %plyr)
{
InitContainerRadiusSearch(%item.surfacePt, $MinDeployableDistance, $TypeMasks::PlayerObjectType);
return containerSearchNext() == %plyr;
}
//-------------------------------------------------
function ShapeBaseImageData::testObjectTooClose(%item)
{
return !ContainerBoxEmpty (
$TypeMasks::VehicleObjectType | $TypeMasks::MoveableObjectType |
$TypeMasks::StaticShapeObjectType | $TypeMasks::StaticTSObjectType |
$TypeMasks::ForceFieldObjectType | $TypeMasks::ItemObjectType |
$TypeMasks::PlayerObjectType | $TypeMasks::TurretObjectType,
%item.surfacePt, $MinDeployableDistance);
}
//-------------------------------------------------
function TurretOutdoorDeployableImage::testNoTerrainFound(%item)
{
return %item.surface.getClassName() !$= TerrainBlock;
}
function ShapeBaseImageData::testNoTerrainFound(%item, %surface)
{
//don't check this for non-Landspike turret deployables
}
//-------------------------------------------------
function TurretIndoorDeployableImage::testNoInteriorFound(%item)
{
return %item.surface.getClassName() !$= InteriorInstance;
}
function ShapeBaseImageData::testNoInteriorFound(%item, %surface)
{
//don't check this for non-Clasping turret deployables
}
//-------------------------------------------------
function TurretIndoorDeployableImage::testHavePurchase(%item, %xform)
{
%footprintRadius = 0.34;
%collMask = $TypeMasks::InteriorObjectType;
return %item.deployed.checkDeployPurchase(%xform, %footprintRadius, %collMask);
}
function ShapeBaseImageData::testHavePurchase(%item, %xform)
{
//don't check this for non-Clasping turret deployables
return true;
}
//-------------------------------------------------
function ShapeBaseImageData::testInventoryTooClose(%item, %plyr)
{
return false;
}
function InventoryDeployableImage::testInventoryTooClose(%item, %plyr)
{
InitContainerRadiusSearch(%item.surfacePt, $InventorySpaceRadius, $TypeMasks::StaticShapeObjectType);
// old function was only checking whether the first object found was a turret -- also wasn't checking
// which team the object was on
%turretInRange = false;
while((%found = containerSearchNext()) != 0)
{
%foundName = %found.getDataBlock().getName();
if( (%foundName $= DeployedStationInventory) )
if (%found.team == %plyr.team)
{
%turretInRange = true;
break;
}
}
return %turretInRange;
}
function TurretIndoorDeployableImage::testTurretTooClose(%item, %plyr)
{
InitContainerRadiusSearch(%item.surfacePt, $TurretIndoorSpaceRadius, $TypeMasks::StaticShapeObjectType);
// old function was only checking whether the first object found was a turret -- also wasn't checking
// which team the object was on
%turretInRange = false;
while((%found = containerSearchNext()) != 0)
{
%foundName = %found.getDataBlock().getName();
if((%foundname $= TurretDeployedFloorIndoor) || (%foundName $= TurretDeployedWallIndoor) || (%foundName $= TurretDeployedCeilingIndoor) || (%foundName $= TurretDeployedOutdoor) || (%foundName $= DeployedStationInventory))
if (%found.team == %plyr.team)
{
%turretInRange = true;
break;
}
}
return %turretInRange;
}
function TurretOutdoorDeployableImage::testTurretTooClose(%item, %plyr)
{
InitContainerRadiusSearch(%item.surfacePt, $TurretOutdoorSpaceRadius, $TypeMasks::StaticShapeObjectType);
// old function was only checking whether the first object found was a turret -- also wasn't checking
// which team the object was on
%turretInRange = false;
while((%found = containerSearchNext()) != 0)
{
%foundName = %found.getDataBlock().getName();
if((%foundname $= TurretDeployedFloorIndoor) || (%foundName $= TurretDeployedWallIndoor) || (%foundName $= TurretDeployedCeilingIndoor) || (%foundName $= TurretDeployedOutdoor) || (%foundName $= DeployedStationInventory))
if (%found.team == %plyr.team)
{
%turretInRange = true;
break;
}
}
return %turretInRange;
}
function ShapeBaseImageData::testTurretTooClose(%item, %plyr)
{
//don't check this for non-turret deployables
}
//-------------------------------------------------
function TurretIndoorDeployableImage::testTurretSaturation(%item)
{
%highestDensity = 0;
InitContainerRadiusSearch(%item.surfacePt, $TurretIndoorSphereRadius, $TypeMasks::StaticShapeObjectType);
%found = containerSearchNext();
while(%found)
{
%foundName = %found.getDataBlock().getName();
if((%foundname $= TurretDeployedFloorIndoor) || (%foundName $= TurretDeployedWallIndoor) || (%foundName $= TurretDeployedCeilingIndoor) || (%foundName $= TurretDeployedOutdoor) || (%foundName $= DeployedStationInventory))
{
//found one
%numTurretsNearby++;
%nearbyDensity = testNearbyDensity(%found, $TurretIndoorSphereRadius);
if (%nearbyDensity > %highestDensity)
%highestDensity = %nearbyDensity;
}
%found = containerSearchNext();
}
if (%numTurretsNearby > %highestDensity)
%highestDensity = %numTurretsNearby;
return %highestDensity > $TurretIndoorMaxPerSphere;
}
function TurretOutdoorDeployableImage::testTurretSaturation(%item)
{
%highestDensity = 0;
InitContainerRadiusSearch(%item.surfacePt, $TurretOutdoorSphereRadius, $TypeMasks::StaticShapeObjectType);
%found = containerSearchNext();
while(%found)
{
%foundName = %found.getDataBlock().getName();
if((%foundname $= TurretDeployedFloorIndoor) || (%foundName $= TurretDeployedWallIndoor) || (%foundName $= TurretDeployedCeilingIndoor) || (%foundName $= TurretDeployedOutdoor) || (%foundName $= DeployedStationInventory))
{
//found one
%numTurretsNearby++;
%nearbyDensity = testNearbyDensity(%found, $TurretOutdoorSphereRadius);
if (%nearbyDensity > %highestDensity)
%highestDensity = %nearbyDensity;
}
%found = containerSearchNext();
}
if (%numTurretsNearby > %highestDensity)
%highestDensity = %numTurretsNearby;
return %highestDensity > $TurretOutdoorMaxPerSphere;
}
function ShapeBaseImageData::testTurretSaturation(%item, %surfacePt)
{
//don't check this for non-turret deployables
}
function testNearbyDensity(%item, %radius)
{
//this checks how many turrets are in adjacent spheres in case placing a new one overloads them.
%surfacePt = posFromTransform(%item.getTransform());
%turretCount = 0;
InitContainerRadiusSearch(%surfacePt, %radius, $TypeMasks::StaticShapeObjectType);
%found = containerSearchNext();
while(%found)
{
%foundName = %found.getDataBlock().getName();
if((%foundname $= TurretDeployedFloorIndoor) || (%foundName $= TurretDeployedWallIndoor) || (%foundName $= TurretDeployedCeilingIndoor) || (%foundName $= TurretDeployedOutdoor) || (%foundName $= DeployedStationInventory))
%turretCount++;
%found = containerSearchNext();
}
return %turretCount;
}
//-------------------------------------------------
//if this function, or any of the included tests are changed, those changes need to be reflected in function:
//AIODeployEquipment::weight(%this, %client, %level), found in aiObjectives.cs --tinman
function ShapeBaseImageData::testInvalidDeployConditions(%item, %plyr, %slot)
{
cancel(%plyr.deployCheckThread);
%disqualified = $NotDeployableReason::None; //default
%surface = Deployables::searchView(%plyr,
$MaxDeployableDistance,
($TypeMasks::TerrainObjectType |
$TypeMasks::InteriorObjectType));
if (%surface)
{
%surfacePt = posFromRaycast(%surface);
%surfaceNrm = normalFromRaycast(%surface);
// Check that point to see if anything is objstructing it...
%eyeTrans = %plyr.getEyeTransform();
%eyePos = posFromTransform(%eyeTrans);
%searchResult = containerRayCast(%eyePos, %surfacePt, -1, %plyr);
if (!%searchResult)
{
%item.surface = %surface;
%item.surfacePt = %surfacePt;
%item.surfaceNrm = %surfaceNrm;
}
else
{
if (%surfacePt $= posFromRaycast(%searchResult))
{
%item.surface = %surface;
%item.surfacePt = %surfacePt;
%item.surfaceNrm = %surfaceNrm;
}
else
{
// Don't set the item
%disqualified = $NotDeployableReason::ObjectTooClose;
}
}
}
if (%item.testMaxDeployed(%plyr))
%disqualified = $NotDeployableReason::MaxDeployed;
else if (%item.testNoSurfaceInRange(%plyr))
%disqualified = $NotDeployableReason::NoSurfaceFound;
else if (%item.testNoTerrainFound(%surface))
%disqualified = $NotDeployableReason::NoTerrainFound;
else if (%item.testNoInteriorFound())
%disqualified = $NotDeployableReason::NoInteriorFound;
else if (%item.testSlopeTooGreat(%surface, %surfaceNrm))
%disqualified = $NotDeployableReason::SlopeTooGreat;
else if (%item.testSelfTooClose(%plyr, %surfacePt))
%disqualified = $NotDeployableReason::SelfTooClose;
else if (%item.testObjectTooClose(%surfacePt))
{
%disqualified = $NotDeployableReason::ObjectTooClose;
}
else if (%item.testTurretTooClose(%plyr))
%disqualified = $NotDeployableReason::TurretTooClose;
else if (%item.testInventoryTooClose(%plyr))
{
%disqualified = $NotDeployableReason::InventoryTooClose;
}
else if (%item.testTurretSaturation())
%disqualified = $NotDeployableReason::TurretSaturation;
else if (%disqualified == $NotDeployableReason::None)
{
// Test that there are no objstructing objects that this object
// will intersect with
//
%rot = %item.getInitialRotation(%plyr);
if(%item.deployed.className $= "DeployedTurret")
%xform = %item.deployed.getDeployTransform(%item.surfacePt, %item.surfaceNrm);
else
%xform = %surfacePt SPC %rot;
if (!%item.deployed.checkDeployPos(%xform))
{
%disqualified = $NotDeployableReason::ObjectTooClose;
}
else if (!%item.testHavePurchase(%xform))
{
%disqualified = $NotDeployableReason::SurfaceTooNarrow;
}
}
if (%plyr.getMountedImage($BackpackSlot) == %item) //player still have the item?
{
if (%disqualified)
activateDeploySensorRed(%plyr);
else
activateDeploySensorGrn(%plyr);
if (%plyr.client.deployPack == true)
%item.attemptDeploy(%plyr, %slot, %disqualified);
else
%plyr.deployCheckThread = %item.schedule(50, "testInvalidDeployConditions", %plyr, %slot); //update checks every 50 milliseconds
}
else
deactivateDeploySensor(%plyr);
}
function ShapeBaseImageData::attemptDeploy(%item, %plyr, %slot, %disqualified)
{
deactivateDeploySensor(%plyr);
Deployables::displayErrorMsg(%item, %plyr, %slot, %disqualified);
}
function activateDeploySensorRed(%pl)
{
if(%pl.deploySensor !$= "red")
{
messageClient(%pl.client, 'msgDeploySensorRed', "");
%pl.deploySensor = "red";
}
}
function activateDeploySensorGrn(%pl)
{
if(%pl.deploySensor !$= "green")
{
messageClient(%pl.client, 'msgDeploySensorGrn', "");
%pl.deploySensor = "green";
}
}
function deactivateDeploySensor(%pl)
{
if (%pl.deploySensor !$= "")
{
messageClient(%pl.client, 'msgDeploySensorOff', "");
%pl.deploySensor = "";
}
}
function Deployables::displayErrorMsg(%item, %plyr, %slot, %error)
{
deactivateDeploySensor(%plyr);
%errorSnd = '~wfx/misc/misc.error.wav';
switch (%error)
{
case $NotDeployableReason::None:
%item.onDeploy(%plyr, %slot);
messageClient(%plyr.client, 'MsgTeamDeploySuccess', "");
return;
case $NotDeployableReason::NoSurfaceFound:
%msg = '\c2Item must be placed within reach.%1';
case $NotDeployableReason::MaxDeployed:
%msg = '\c2Your team\'s control network has reached its capacity for this item.%1';
case $NotDeployableReason::SlopeTooGreat:
%msg = '\c2Surface is too steep to place this item on.%1';
case $NotDeployableReason::SelfTooClose:
%msg = '\c2You are too close to the surface you are trying to place the item on.%1';
case $NotDeployableReason::ObjectTooClose:
%msg = '\c2You cannot place this item so close to another object.%1';
case $NotDeployableReason::NoTerrainFound:
%msg = '\c2You must place this on outdoor terrain.%1';
case $NotDeployableReason::NoInteriorFound:
%msg = '\c2You must place this on a solid surface.%1';
case $NotDeployableReason::TurretTooClose:
%msg = '\c2Interference from a nearby turret prevents placement here.%1';
case $NotDeployableReason::TurretSaturation:
%msg = '\c2There are too many turrets nearby.%1';
case $NotDeployableReason::SurfaceTooNarrow:
%msg = '\c2There is not adequate surface to clamp to here.%1';
case $NotDeployableReason::InventoryTooClose:
%msg = '\c2Interference from a nearby inventory prevents placement here.%1';
default:
%msg = '\c2Deploy failed.';
}
messageClient(%plyr.client, 'MsgDeployFailed', %msg, %errorSnd);
}
function ShapeBaseImageData::onActivate(%data, %obj, %slot)
{
//Tinman - apparently, anything that uses the generic onActivate() method is a deployable.
//repair packs, cloak packs, shield, etc... all overload this method...
%data.testInvalidDeployConditions(%obj, %slot);
//whether the test passed or not, reset the image trigger (deployables don't have an on/off toggleable state)
%obj.setImageTrigger(%slot, false);
}
function ShapeBaseImageData::onDeploy(%item, %plyr, %slot)
{
if(%item.item $= "MotionSensorDeployable" || %item.item $= "PulseSensorDeployable")
{
%plyr.deploySensors--;
%plyr.client.updateSensorPackText(%plyr.deploySensors);
if(%plyr.deploySensors <= 0)
{
// take the deployable off the player's back and out of inventory
%plyr.unmountImage(%slot);
%plyr.decInventory(%item.item, 1);
}
}
else
{
// take the deployable off the player's back and out of inventory
%plyr.unmountImage(%slot);
%plyr.decInventory(%item.item, 1);
}
// create the actual deployable
%rot = %item.getInitialRotation(%plyr);
if(%item.deployed.className $= "DeployedTurret")
%className = "Turret";
else
%className = "StaticShape";
%deplObj = new (%className)() {
dataBlock = %item.deployed;
};
// set orientation
if(%className $= "Turret")
%deplObj.setDeployRotation(%item.surfacePt, %item.surfaceNrm);
else
%deplObj.setTransform(%item.surfacePt SPC %rot);
// set the recharge rate right away
if(%deplObj.getDatablock().rechargeRate)
%deplObj.setRechargeRate(%deplObj.getDatablock().rechargeRate);
// set team, owner, and handle
%deplObj.team = %plyr.client.Team;
%deplObj.owner = %plyr.client;
// set the sensor group if it needs one
if(%deplObj.getTarget() != -1)
setTargetSensorGroup(%deplObj.getTarget(), %plyr.client.team);
// place the deployable in the MissionCleanup/Deployables group (AI reasons)
addToDeployGroup(%deplObj);
//let the AI know as well...
AIDeployObject(%plyr.client, %deplObj);
// play the deploy sound
serverPlay3D(%item.deploySound, %deplObj.getTransform());
// increment the team count for this deployed object
$TeamDeployedCount[%plyr.team, %item.item]++;
%deplObj.deploy();
return %deplObj;
}
function ShapeBaseImageData::getInitialRotation(%item, %plyr)
{
return rotFromTransform(%plyr.getTransform());
}
function MotionSensorDeployableImage::getInitialRotation(%item, %plyr)
{
%rotAxis = vectorNormalize(vectorCross(%item.surfaceNrm, "0 0 1"));
if (getWord(%item.surfaceNrm, 2) == 1 || getWord(%item.surfaceNrm, 2) == -1)
%rotAxis = vectorNormalize(vectorCross(%item.surfaceNrm, "0 1 0"));
return %rotAxis SPC mACos(vectorDot(%item.surfaceNrm, "0 0 1"));
}
function MotionSensorDeployable::onPickup(%this, %pack, %player, %amount)
{
// %this = Sensor pack datablock
// %pack = Sensor pack object number
// %player = player
// %amount = amount picked up (1)
if(%pack.sensors $= "")
{
// assume that this is a pack that has been placed in a mission
// this case was handled in ::onInventory below (max sensors);
}
else
{
// find out how many sensor were in the pack
%player.deploySensors = %pack.sensors;
%player.client.updateSensorPackText(%player.deploySensors);
}
}
function MotionSensorDeployable::onThrow(%this,%pack,%player)
{
// %this = Sensor pack datablock
// %pack = Sensor pack object number
// %player = player
%player.throwSensorPack = 1;
%pack.sensors = %player.deploySensors;
%player.deploySensors = 0;
%player.client.updateSensorPackText(%player.deploySensors);
// do the normal ItemData::onThrow stuff -- sound and schedule deletion
serverPlay3D(ItemThrowSound, %player.getTransform());
%pack.schedulePop();
}
function MotionSensorDeployable::onInventory(%this,%player,%value)
{
// %this = Sensor pack datablock
// %player = player
// %value = 1 if gaining a pack, 0 if losing a pack
if(%player.getClassName() $= "Player")
{
if(%value)
{
// player picked up or bought a motion sensor pack
%player.deploySensors = %this.maxSensors;
%player.client.updateSensorPackText(%player.deploySensors);
}
else
{
// player dropped or sold a motion sensor pack
if(%player.throwSensorPack)
{
// player threw the pack
%player.throwSensorPack = 0;
// everything handled in ::onThrow above
}
else
{
//the pack was sold at an inventory station, or unmounted because the player
// used all the sensors
%player.deploySensors = 0;
%player.client.updateSensorPackText(%player.deploySensors);
}
}
}
Pack::onInventory(%this,%player,%value);
}
function PulseSensorDeployable::onPickup(%this, %pack, %player, %amount)
{
// %this = Sensor pack datablock
// %pack = Sensor pack object number
// %player = player
// %amount = amount picked up (1)
if(%pack.sensors $= "")
{
// assume that this is a pack that has been placed in a mission
// this case was handled in ::onInventory below (max sensors);
}
else
{
// find out how many sensor were in the pack
%player.deploySensors = %pack.sensors;
%player.client.updateSensorPackText(%player.deploySensors);
}
}
function PulseSensorDeployable::onThrow(%this,%pack,%player)
{
// %this = Sensor pack datablock
// %pack = Sensor pack object number
// %player = player
%player.throwSensorPack = 1;
%pack.sensors = %player.deploySensors;
%player.deploySensors = 0;
%player.client.updateSensorPackText(%player.deploySensors);
// do the normal ItemData::onThrow stuff -- sound and schedule deletion
serverPlay3D(ItemThrowSound, %player.getTransform());
%pack.schedulePop();
}
function PulseSensorDeployable::onInventory(%this,%player,%value)
{
// %this = Sensor pack datablock
// %player = player
// %value = 1 if gaining a pack, 0 if losing a pack
if(%player.getClassName() $= "Player")
{
if(%value)
{
// player picked up or bought a motion sensor pack
%player.deploySensors = %this.maxSensors;
%player.client.updateSensorPackText(%player.deploySensors);
}
else
{
// player dropped or sold a motion sensor pack
if(%player.throwSensorPack)
{
// player threw the pack
%player.throwSensorPack = 0;
// everything handled in ::onThrow above
}
else
{
//the pack was sold at an inventory station, or unmounted because the player
// used all the sensors
%player.deploySensors = 0;
%player.client.updateSensorPackText(%player.deploySensors);
}
}
}
Pack::onInventory(%this,%player,%value);
}
function TurretIndoorDeployableImage::getInitialRotation(%item, %plyr)
{
%surfaceAngle = getTerrainAngle(%item.surfaceNrm);
if(%surfaceAngle > 155)
%item.deployed = TurretDeployedCeilingIndoor;
else if(%surfaceAngle > 45)
%item.deployed = TurretDeployedWallIndoor;
else
%item.deployed = TurretDeployedFloorIndoor;
}
function TurretIndoorDeployable::onPickup(%this, %obj, %shape, %amount)
{
// created to prevent console errors
}
function TurretOutdoorDeployable::onPickup(%this, %obj, %shape, %amount)
{
// created to prevent console errors
}
function InventoryDeployable::onPickup(%this, %obj, %shape, %amount)
{
// created to prevent console errors
}
// ---------------------------------------------------------------------------------------
// deployed station functions
function DeployedStationInventory::onEndSequence(%data, %obj, %thread)
{
Parent::onEndSequence(%data, %obj, %thread);
if(%thread == $DeployThread)
{
%trigger = new Trigger()
{
dataBlock = stationTrigger;
polyhedron = "-0.125 0.0 0.1 0.25 0.0 0.0 0.0 -0.7 0.0 0.0 0.0 1.0";
};
MissionCleanup.add(%trigger);
%trans = %obj.getTransform();
%vSPos = getWords(%trans,0,2);
%vRot = getWords(%trans,3,5);
%vAngle = getWord(%trans,6);
%matrix = VectorOrthoBasis(%vRot @ " " @ %vAngle + 0.0);
%yRot = getWords(%matrix, 3, 5);
%pos = vectorAdd(%vSPos, vectorScale(%yRot, -0.1));
%trigger.setTransform(%pos @ " " @ %vRot @ " " @ %vAngle);
// associate the trigger with the station
%trigger.station = %obj;
%trigger.mainObj = %obj;
%trigger.disableObj = %obj;
%obj.trigger = %trigger;
}
}
//--------------------------------------------------------------------------
//DeployedMotionSensor:
//--------------------------------------------------------------------------
function DeployedMotionSensor::onDestroyed(%this, %obj, %prevState)
{
//%obj.hide(true);
Parent::onDestroyed(%this, %obj, %prevState);
$TeamDeployedCount[%obj.team, MotionSensorDeployable]--;
%obj.schedule(500, "delete");
}
//--------------------------------------------------------------------------
//DeployedPulseSensor:
//--------------------------------------------------------------------------
function PulseSensorDeployableImage::onActivate(%data, %obj, %slot)
{
%data.testInvalidDeployConditions(%obj, %slot);
}
function DeployedPulseSensor::onDestroyed(%this, %obj, %prevState)
{
Parent::onDestroyed(%this, %obj, %prevState);
$TeamDeployedCount[%obj.team, PulseSensorDeployable]--;
%obj.schedule(300, "delete");
}
// ---------------------------------------------------------------------------------------
// deployed turret functions
function DeployedTurret::onAdd(%data, %obj)
{
Parent::onAdd(%data, %obj);
// auto-mount the barrel
%obj.mountImage(%data.barrel, 0, false);
}
function DeployedTurret::onDestroyed(%this, %obj, %prevState)
{
Parent::onDestroyed(%this, %obj, %prevState);
%turType = %this.getName();
// either it'll be an outdoor turret, or one of the three types of indoor turret
// (floor, ceiling, wall)
if(%turType $= "TurretDeployedOutdoor")
%turType = "TurretOutdoorDeployable";
else
%turType = "TurretIndoorDeployable";
// decrement team count
$TeamDeployedCount[%obj.team, %turType]--;
%obj.schedule(700, "delete");
}
function countTurretsAllowed(%type)
{
for(%j = 1; %j < Game.numTeams; %j++)
%teamPlayerCount[%j] = 0;
%numClients = ClientGroup.getCount();
for(%i = 0; %i < %numClients; %i++)
{
%cl = ClientGroup.getObject(%i);
if(%cl.team > 0)
%teamPlayerCount[%cl.team]++;
}
// the bigger team determines the number of turrets allowed
%maxPlayers = %teamPlayerCount[1] > %teamPlayerCount[2] ? %teamPlayerCount[1] : %teamPlayerCount[2];
// each team can have 1 turret of each type (indoor/outdoor) for every 2 players
// minimum and maximums are defined in deployables.cs
%teamTurretMax = mFloor(%maxPlayers / 2);
if(%teamTurretMax < $TeamDeployableMin[%type])
%teamTurretMax = $TeamDeployableMin[%type];
else if(%teamTurretMax > $TeamDeployableMax[%type])
%teamTurretMax = $TeamDeployableMax[%type];
return %teamTurretMax;
}