==================================================================================== This is a modified version of Micromitch's tut with help from Liquid and nick418. Thanks and credit go to them. Modified to rotate turret to player and mount a plasma turret by default. ==================================================================================== Step #1: Make a file called turret.cs in your packs directory and place this code in the file: Code: //----------------------------------------------------- // Deployable Base Turret (Micromitch, Liquid, Nick418) //----------------------------------------------------- datablock ShapeBaseImageData(TurretDeployableImage) { mass = 15; emap = true; shapeFile = "stackable1s.dts"; item = TurretBasePack; mountPoint = 1; offset = "0 -0.2 0"; minDeployDis = 0.5; maxDeployDis = 5.0; deployed = TurretDeployedBase; 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(TurretBasePack) { className = Pack; catagory = "Deployables"; shapeFile = "stackable1s.dts"; origBarrel = "PlasmaBarrelLarge"; //added by nick418 mass = 3.0; elasticity = 0.2; friction = 0.6; pickupRadius = 1; rotate = false; image = "TurretDeployableImage"; pickUpName = "a deployable base turret"; heatSignature = 0; computeCRC = true; emap = true; }; datablock TurretData(TurretDeployedBase) : TurretDamageProfile { className = DeployedTurret; shapeFile = "turret_base_large.dts"; isGrounded = true; // Added per Liquid (set rotation) deployedFrom = TurretBasePack; // Added per BadShot (undeploy) rechargeRate = 0.31; selfPower = true; needsNoPower = true; mass = 5.0; maxDamage = 2.25; destroyedLevel = 2.25; disabledLevel = 1.35; repairRate = 0; explosion = TurretExplosion; expDmgRadius = 15.0; expDamage = 0.7; expImpulse = 2000.0; deployedObject = true; thetaMin = 15; thetaMax = 140; //thetaNull = 90; isShielded = true; energyPerDamagePoint = 50; maxEnergy = 150; humSound = SensorHumSound; heatSignature = 0; pausePowerThread = true; canControl = true; cmdCategory = "DTactical"; cmdIcon = CMDTurretIcon; cmdMiniIconName = "commander/MiniIcons/com_turret_grey"; targetNameTag = 'Deployed Base'; targetTypeTag = 'Turret'; sensorData = TurretBaseSensorObj; sensorRadius = TurretBaseSensorObj.detectRadius; sensorColor = "0 212 45"; firstPersonOnly = true; debrisShapeName = "debris_generic.dts"; debris = TurretDebris; }; function TurretBasePack::onPickup(%this, %obj, %shape, %amount) { // created to prevent console errors } function TurretDeployableImage::onDeploy(%item, %plyr, %slot) { %deplObj = Parent::onDeploy(%item, %plyr, %slot); %origBarrel = %item.item.origBarrel; if(%origBarrel !$= "") { %deplObj.mountImage(%origBarrel, 0, false); %item.item.origBarrel = "PlasmaBarrelLarge"; // Set the default here, too. } %deplObj.setSelfPowered(); %deplObj.playThread($PowerThread,"Power"); } function TurretDeployedBase::disassemble(%data, %plyr, %hTgt) { %plyr.getMountedImage($BackpackSlot).item.origBarrel = %hTgt.getMountedImage(0); } Step #2: Once in your deployables.cs set your TeamDeployableMax and TeamDeployableMin Code: $TeamDeployableMax[TurretBasePack] = 4; //Feel Free to change the number $TeamDeployableMin[TurretBasePack] = 4; //Feel Free to change the number Step #3: Still in deployables.cs (going to be here for awhile) Find the function ShapeBaseImageData::testMaxDeployed(%item, %plyr) Whenever you see this, you will see: Code: if(%item.item $= TurretOutdoorDeployable || %item.item $= TurretIndoorDeployable )..... Add the ItemData for the turret into there, so it should like something like this: Code: if(%item.item $= TurretOutdoorDeployable || %item.item $= TurretIndoorDeployable || %item.item $= TurretBasePack ) Step #4: Find function testNearbyDensity(%item, %radius) When you find that function you'll see this under it: Code: if((%foundname $= TurretDeployedFloorIndoor) || (%foundName $= TurretDeployedWallIndoor) || (%foundName $= TurretDeployedCeilingIndoor) || (%foundName $= TurretDeployedOutdoor) ) Add the TurretData (DATABLOCK) to it, so it should read: Code: if((%foundname $= TurretDeployedFloorIndoor) || (%foundName $= TurretDeployedWallIndoor) || (%foundName $= TurretDeployedCeilingIndoor) || (%foundName $= TurretDeployedOutdoor) || (%foundname $= TurretDeployedBase) ) Step #5: Locate function TurretOutdoorDeployableImage::testTurretSaturation(%item) Right BELOW that function add this: Code: function TurretDeployableImage::testTurretSaturation(%item) { %highestDensity = 0; InitContainerRadiusSearch(%item.surfacePt, $TurretOutdoorSphereRadius, $TypeMasks::StaticShapeObjectType); %found = containerSearchNext(); while(%found) { %foundName = %found.getDataBlock().getName(); if((%foundname $= TurretBasePack) ) { //found one %numTurretsNearby++; %nearbyDensity = testNearbyDensity(%found, $TurretOutdoorSphereRadius); if (%nearbyDensity > %highestDensity) %highestDensity = %nearbyDensity; } %found = containerSearchNext(); } if (%numTurretsNearby > %highestDensity) %highestDensity = %numTurretsNearby; return %highestDensity > $TurretOutdoorMaxPerSphere; } Step #6: in function ShapeBaseImageData::onDeploy in deployables.cs (this part by Liquid) Replace this... Code: // set orientation if(%className $= "Turret") %deplObj.setDeployRotation(%item.surfacePt, %item.surfaceNrm); else %deplObj.setTransform(%item.surfacePt SPC %rot); With this... Code: // set orientation if(%className $= "Turret") { if(%item.deployed.isGrounded) { %turretTrf = %plyr.getTransform(); %turretRot = getWords(%turretTrf, 3, 6); %deplObj.setTransform(%item.surfacePt SPC %turretRot); } else { %deplObj.setDeployRotation(%item.surfacePt, %item.surfaceNrm); } } else { %deplObj.setTransform(%item.surfacePt SPC %rot); } Note: The "isGrounded" part is so it doesn't screw up the clamping turrets rotation, the code is for ground based turrets only, so make sure the turrets ItemData() datablock contains "isGrounded = true;" Step #7: Ok, now we gotta do a little hackish thing (lovely) Find the function DeployedTurret::onDestroyed(%this, %obj, %prevState) Ok, now you should see this UNLESS you previously edited it: Code: 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"); } Delete that function and all its contents and replace it with the following: Code: 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 if(%turType $= "TurretDeployedBase") %turType = "TurretBasePack"; else %turType = "TurretIndoorDeployable"; // decrement team count $TeamDeployedCount[%obj.team, %turType]--; %obj.schedule(700, "delete"); } Step #8: Ok last step for this file, thank god... At the very bottom of pack.cs add: Code: exec("scripts/packs/turret.cs"); Step #9: Ok, going to QUICKLY cover this subject....Adding the turret to inventoryHUD.cs Once in inventoryHud.cs we are going to add these to their appropiate places: Code: $InvPack[17] = "Deployable Turret Base"; //Fix number for yourself $NameToInv["Deployable Turret Base"] = "TurretBasePack"; Ok, good, we got it showing in the inventory =) Now, we gotta set which armors can purchase this item...Open player.cs Now for the armors that we want to have this so it can be deployed, add this to its appropriate place: Code: max[TurretBasePack] = 1; And for the armors that are not permitted to carry this pack add: Code: max[TurretBasePack] = 0; Step #10: Find function checkTurretMount(%data, %obj, %slot) in turret.cs Note: not under your packs/ directory but in scripts/ Under that will be an that looks like this: Code: if((%potTurret.getDatablock().getName() $= "TurretBaseLarge" ) || %potTurret.getDatablock().getName() $= %otherMountObj) Change it to this: Code: if((%potTurret.getDatablock().getName() $= "TurretBaseLarge" || %potTurret.getDatablock().getName() $= "TurretDeployedBase") || %potTurret.getDatablock().getName() $= %otherMountObj) Step #11: Paste this into function clearDeployableMaxes in defaultGame.cs (added by Southtown) Code: $TeamDeployedCount[%i, TurretBasePack] = 0; Step #12: In inventoryHud.cs find this in BuyFavorites(): Code: if(%pCh $= "TurretIndoorDeployable" || %pCh $= "TurretOutdoorDeployable") %maxDep = countTurretsAllowed(%pCh); else %maxDep = $TeamDeployableMax[%pCh]; and change it to this: Code: if(%pCh $= "TurretIndoorDeployable" || %pCh $= "TurretOutdoorDeployable" || %pCh $= "TurretBasePack") %maxDep = countTurretsAllowed(%pCh); else %maxDep = $TeamDeployableMax[%pCh]; Also in inventoryHud.cs find this in function BuyDeployableFavorites() : Code: if(%packChoice $= "TurretIndoorDeployable" || %packChoice $= "TurretOutdoorDeployable") %maxDep = countTurretsAllowed(%packChoice); else %maxDep = $TeamDeployableMax[%packChoice]; and change it to this: Code: if(%packChoice $= "TurretIndoorDeployable" || %packChoice $= "TurretOutdoorDeployable" || %packChoice $= "TurretBasePack") %maxDep = countTurretsAllowed(%packChoice); else %maxDep = $TeamDeployableMax[%packChoice]; There you go, now you have a deployable turret base.