mirror of
https://github.com/mostlikely4r/construction-mod.git
synced 2026-01-19 19:24:44 +00:00
128 lines
3.3 KiB
C#
128 lines
3.3 KiB
C#
//--------------------------------------------------------------------------
|
|
// Medium Pulse Sensor
|
|
//--------------------------------------------------------------------------
|
|
|
|
datablock ShapeBaseImageData(MediumSensorDeployableImage) {
|
|
mass = 1;
|
|
emap = true;
|
|
shapeFile = "stackable1s.dts";
|
|
item = MediumSensorDeployable;
|
|
mountPoint = 1;
|
|
offset = "0 0 0";
|
|
deployed = SensorMediumPulse;
|
|
heatSignature = 0;
|
|
|
|
stateName[0] = "Idle";
|
|
stateTransitionOnTriggerDown[0] = "Activate";
|
|
|
|
stateName[1] = "Activate";
|
|
stateScript[1] = "onActivate";
|
|
stateTransitionOnTriggerUp[1] = "Idle";
|
|
|
|
isLarge = true;
|
|
maxDepSlope = 360;
|
|
deploySound = ItemPickupSound;
|
|
|
|
minDeployDis = 0.5;
|
|
maxDeployDis = 5.0;
|
|
};
|
|
|
|
datablock ItemData(MediumSensorDeployable) {
|
|
className = Pack;
|
|
catagory = "Deployables";
|
|
shapeFile = "stackable1s.dts";
|
|
mass = 1;
|
|
elasticity = 0.2;
|
|
friction = 0.6;
|
|
pickupRadius = 1;
|
|
rotate = true;
|
|
image = "MediumSensorDeployableImage";
|
|
joint = "4.5 4.5 4.5";
|
|
pickUpName = "a medium pulse sensor pack";
|
|
heatSignature = 0;
|
|
emap = true;
|
|
};
|
|
|
|
function MediumSensorDeployable::onPickup(%this, %obj, %shape, %amount) {
|
|
// created to prevent console errors
|
|
}
|
|
|
|
function MediumSensorDeployableImage::testNoTerrainFound(%item) {
|
|
// don't check this for non-Landspike turret deployables
|
|
}
|
|
|
|
function MediumSensorDeployableImage::onDeploy(%item, %plyr, %slot) {
|
|
%className = "StaticShape";
|
|
|
|
%playerVector = vectorNormalize(getWord(%plyr.getEyeVector(),1) SPC -1 * getWord(%plyr.getEyeVector(),0) SPC "0");
|
|
%item.surfaceNrm2 = %playerVector;
|
|
|
|
if (vAbs(floorVec(%item.surfaceNrm,100)) $= "0 0 1")
|
|
%item.surfaceNrm2 = %playerVector;
|
|
else
|
|
%item.surfaceNrm2 = vectorNormalize(vectorCross(%item.surfaceNrm,"0 0 -1"));
|
|
|
|
%rot = fullRot(%item.surfaceNrm,%item.surfaceNrm2);
|
|
|
|
%deplObj = new (%className)() {
|
|
dataBlock = SensorMediumPulse;
|
|
deployed = true;
|
|
};
|
|
|
|
// set orientation
|
|
%deplObj.setTransform(%item.surfacePt SPC %rot);
|
|
|
|
// set team, owner, and handle
|
|
%deplObj.team = %plyr.client.Team;
|
|
%deplObj.setOwner(%plyr);
|
|
|
|
// set power frequency
|
|
%deplObj.powerFreq = %plyr.powerFreq;
|
|
// setTargetName(%deplObj.target,addTaggedString("Frequency" SPC %deplObj.powerFreq));
|
|
|
|
// 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]++;
|
|
|
|
addDSurface(%item.surface,%deplObj);
|
|
|
|
// %deplObj.playThread($PowerThread,"Power");
|
|
|
|
// take the deployable off the player's back and out of inventory
|
|
%plyr.unmountImage(%slot);
|
|
%plyr.decInventory(%item.item, 1);
|
|
|
|
// Power object
|
|
checkPowerObject(%deplObj);
|
|
|
|
return %deplObj;
|
|
}
|
|
|
|
function SensorMediumPulse::onDestroyed(%data,%obj,%prevState) {
|
|
if (%obj.isRemoved)
|
|
return;
|
|
if (%obj.deployed) {
|
|
%obj.isRemoved = true;
|
|
$TeamDeployedCount[%obj.team,MediumSensorDeployable]--;
|
|
remDSurface(%obj);
|
|
%obj.schedule(500,"delete");
|
|
}
|
|
Parent::onDestroyed(%data,%obj,%prevState);
|
|
}
|
|
|
|
function MediumSensorDeployableImage::onMount(%data, %obj, %node) {
|
|
displayPowerFreq(%obj);
|
|
}
|