sorry i forgeted to post what i have! it fires flares on deploy every 10 seconds... it gave me and ue once and never more... what need to do: spawn a invisible shape (turret_muzlepoint.dts) and set it as the target to make turret fire up and not in straight line... here it goes: //-------------------------------------------------------------------------- // Deployable Flare Turret - by Founder and ZOD modyfied by Child_Killer // Please credit the authors if you use this in your mod. //-------------------------------------------------------------------------- $TeamDeployableMax[TurretFlareDeployable] = 6; $TeamDeployableMin[TurretFlareDeployable] = 3; // This stuff goes in inventoryHud.cs //$InvPack[27] = "Flare Turret"; //$NameToInv["Flare Turret"] = "TurretFlareDeployable"; // This stuff goes in hud.cs //$BackpackHudData[20, itemDataName] = "TurretFlareDeployable"; //$BackpackHudData[20, bitmapName] = "gui/hud_new_packturret"; //$ControlObjectReticle[DeployableFlareBarrel, bitmap] = "hud_ret_sniper"; //$ControlObjectReticle[DeployableFlareBarrel, frame] = false; // Don't forget to put this in your armors datablock // max[TurretFlareDeployable] = 1; // Find function ShapeBaseImageData::testInvalidDeployConditions(%item, %plyr, %slot) // in deployables.cs // Locate the lines in that function that read: // if (!%item.deployed.checkDeployPos(%xform)) // { // %disqualified = $NotDeployableReason::ObjectTooClose; // } // Replace them with the following: // if (!%item.deployed.checkDeployPos(%xform)) { // // Edit for certain items - ZOD/Founder // if(%item.item $= "TurretFlareDeployable") { // %disqualified = $NotDeployableReason::None; // } // else { // %disqualified = $NotDeployableReason::ObjectTooClose; // } // } // This goes as the last line in deployables.cs // exec("scripts/turrets/FlareTurret.cs"); // Don't forget to reset the deploy count in defaultGame.cs - // Add to function DefaultGame::clearDeployableMaxes(%game) // $TeamDeployedCount[%i, TurretFlareDeployable] = 0; //-------------------------------------------------------------------------- // Datablocks //-------------------------------------- datablock SensorData(FlareTurretSensor) { detects = true; detectsUsingLOS = true; detectsPassiveJammed = false; detectsActiveJammed = false; detectsCloaked = false; detectionPings = true; detectRadius = 100; }; datablock TurretData(FlareDeployed) : TurretDamageProfile { className = DeployedTurret; shapeFile = "turret_outdoor_deploy.dts"; mass = 5.0; maxDamage = 0.5; destroyedLevel = 0.5; disabledLevel = 0.21; explosion = SmallTurretExplosion; expDmgRadius = 5.0; expDamage = 0.25; expImpulse = 500.0; repairRate = 0; heatSignature = 0.0; deployedObject = true; thetaMin = 5; thetaMax = 145; thetaNull = 90; primaryAxis = zaxis; isShielded = true; energyPerDamagePoint = 30; maxEnergy = 30; rechargeRate = 0.10; barrel = DeployableFlareBarrel; canControl = true; cmdCategory = "DTactical"; cmdIcon = CMDTurretIcon; cmdMiniIconName = "commander/MiniIcons/com_turret_grey"; targetNameTag = 'Flare'; targetTypeTag = 'Turret'; sensorData = FlareTurretSensor; sensorRadius = FlareTurretSensor.detectRadius; sensorColor = "191 0 226"; firstPersonOnly = true; renderWhenDestroyed = false; debrisShapeName = "debris_generic_small.dts"; debris = TurretDebrisSmall; }; datablock AudioProfile(FlareTurretGrenadeBurnSound) { filename = "fx/weapons/grenade_flare_burn.wav"; description = CloseLooping3d; preload = true; }; datablock AudioProfile(FlareTurretGrenadeExplosionSound) { filename = "fx/weapons/grenade_flare_burn.wav"; description = CloseLooping3d; preload = true; }; //-------------------------------------------------------------------------- // Particle effects //-------------------------------------- datablock ParticleData(FlareTurretParticle) { dragCoeffiecient = 0.0; gravityCoefficient = 0.15; inheritedVelFactor = 0.5; lifetimeMS = 1800; lifetimeVarianceMS = 200; textureName = "special/flareSpark"; colors[0] = "1.0 1.0 1.0 1.0"; colors[1] = "1.0 1.0 1.0 1.0"; colors[2] = "1.0 1.0 1.0 0.0"; sizes[0] = 0.6; sizes[1] = 0.3; sizes[2] = 0.1; times[0] = 0.0; times[1] = 0.5; times[2] = 1.0; }; datablock ParticleEmitterData(FlareTurretEmitter) { ejectionPeriodMS = 10; periodVarianceMS = 0; ejectionVelocity = 1.0; velocityVariance = 0.0; thetaMin = 0.0; thetaMax = 90.0; orientParticles = true; orientOnVelocity = false; particles = "FlareTurretParticle"; }; //-------------------------------------------------------------------------- // Explosion - Flare Grenade //-------------------------------------- datablock ExplosionData(FlareTurretGrenadeExplosion) { explosionShape = "energy_explosion.dts"; soundProfile = FlareTurretGrenadeExplosionSound; faceViewer = true; explosionScale = "0.1 0.1 0.1"; }; //-------------------------------------------------------------------------- // Projectile - Flare Grenade //-------------------------------------- datablock FlareProjectileData(FlareTurretGrenadeProj) { projectileShapeName = "grenade_projectile.dts"; emitterDelay = -1; directDamage = 0.0; hasDamageRadius = false; kickBackStrength = 1500; useLensFlare = false; sound = FlareTurretGrenadeBurnSound; explosion = FlareTurretGrenadeExplosion; velInheritFactor = 0.5; texture[0] = "special/flare3"; texture[1] = "special/LensFlare/flare00"; size = 4.0; baseEmitter = FlareTurretEmitter; grenadeElasticity = 0.35; grenadeFriction = 0.2; armingDelayMS = 6000; muzzleVelocity = 15.0; drag = 0.1; gravityMod = 0.15; }; datablock TurretImageData(DeployableFlareBarrel) { shapeFile = "weapon_plasma.dts"; item = FlareTurretBarrel; rotation = "0 0 0 0"; offset = "0 0 0"; projectile = FlareTurretGranadeProj; projectileType = FlareProjectile; usesEnergy = true; fireEnergy = 20; minEnergy = 20; lightType = "WeaponFireLight"; lightColor = "0.25 0.15 0.15 1.0"; lightTime = "1000"; lightRadius = "2"; muzzleFlash = IndoorTurretMuzzleFlash; // Turret parameters activationMS = 150; deactivateDelayMS = 300; thinkTimeMS = 150; degPerSecTheta = 580; degPerSecPhi = 960; attackRadius = 100; // State transitions // stateName[0] = "idle"; stateName[0] = "Fire"; stateTimeoutValue[0] = 3; stateTransitionOnTimeout[0] = "Fire"; stateFire[0] = true; stateSequence[0] = "Fire"; stateScript[0] = "onFire"; stateSound[0] = IBLFireSound; stateAllowImageChange[0] = false; // stateName[0] = "Activate"; // stateTransitionOnNotLoaded[0] = "Dead"; // stateTransitionOnLoaded[0] = "ActivateReady"; // // stateName[1] = "ActivateReady"; // stateSequence[1] = "Activate"; // stateSound[1] = IBLSwitchSound; // stateTimeoutValue[1] = 1; // stateTransitionOnTimeout[1] = "Ready"; // stateTransitionOnNotLoaded[1] = "Deactivate"; // stateTransitionOnNoAmmo[1] = "NoAmmo"; // // stateName[2] = "Ready"; // stateTransitionOnNotLoaded[2] = "Deactivate"; // //stateTimeoutValue[2] = 3; // //stateTransitionOnTimeout[2] = "Fire"; // stateTransitionOnTriggerDown[2] = "Fire"; // stateTransitionOnNoAmmo[2] = "NoAmmo"; // // stateName[3] = "Fire"; // stateTransitionOnTimeout[3] = "Reload"; // stateTimeoutValue[3] = 0.3; // stateFire[3] = true; // stateShockwave[3] = true; // stateRecoil[3] = LightRecoil; // stateAllowImageChange[3] = false; // stateSequence[3] = "Fire"; // stateSound[3] = IBLFireSound; // stateScript[3] = "onFire"; // // stateName[4] = "Reload"; // stateTimeoutValue[4] = 0.8; // stateAllowImageChange[4] = false; // stateSequence[4] = "Reload"; // stateTransitionOnTimeout[4] = "Ready"; // stateTransitionOnNotLoaded[4] = "Deactivate"; // stateTransitionOnNoAmmo[4] = "NoAmmo"; // // stateName[5] = "Deactivate"; // stateSequence[5] = "Activate"; // stateDirection[5] = false; // stateTimeoutValue[5] = 1; // stateTransitionOnLoaded[5] = "ActivateReady"; // stateTransitionOnTimeout[5] = "Dead"; // // stateName[6] = "Dead"; // stateTransitionOnLoaded[6] = "ActivateReady"; // // stateName[7] = "NoAmmo"; // stateTransitionOnAmmo[7] = "Reload"; // stateSequence[7] = "NoAmmo"; }; datablock ShapeBaseImageData(TurretFlareDeployableImage) { mass = 15; shapeFile = "pack_deploy_turreti.dts"; item = TurretFlareDeployable; mountPoint = 1; offset = "0 0 0"; deployed = FlareDeployed; stateName[0] = "Idle"; stateTransitionOnTriggerDown[0] = "Activate"; stateName[1] = "Activate"; stateScript[1] = "onActivate"; stateTransitionOnTriggerUp[1] = "Idle"; isLarge = true; emap = true; maxDepSlope = 360; deploySound = TurretDeploySound; minDeployDis = 0.5; maxDeployDis = 5.0; }; datablock ItemData(TurretFlareDeployable) { className = Pack; catagory = "Deployables"; shapeFile = "pack_deploy_turreti.dts"; mass = 3.0; elasticity = 0.2; friction = 0.6; pickupRadius = 1; rotate = false; image = "TurretFlareDeployableImage"; pickUpName = "a flare turret pack"; emap = true; }; //-------------------------------------------------------------------------- // Functions //-------------------------------------- function TurretFlareDeployableImage::testObjectTooClose(%item) { %mask = ($TypeMasks::VehicleObjectType | $TypeMasks::MoveableObjectType | $TypeMasks::ForceFieldObjectType | $TypeMasks::ItemObjectType | $TypeMasks::PlayerObjectType); InitContainerRadiusSearch( %item.surfacePt, $MinDeployDistance, %mask ); %test = containerSearchNext(); return %test; } function TurretFlareDeployableImage::testNoTerrainFound(%item) { // created to prevent console errors } function TurretFlareDeployableImage::testNoInteriorFound(%item) { // created to prevent console errors } function TurretFlareDeployableImage::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 $= FlareDeployed)) if (%found.team == %plyr.team) { %turretInRange = true; break; } } return %turretInRange; } function TurretFlareDeployableImage::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 $= FlareDeployed)) { //found one %numTurretsNearby++; %nearbyDensity = testNearbyDensity(%found, $TurretIndoorSphereRadius); if (%nearbyDensity > %highestDensity) %highestDensity = %nearbyDensity; } %found = containerSearchNext(); } if (%numTurretsNearby > %highestDensity) %highestDensity = %numTurretsNearby; return %highestDensity > $TurretIndoorMaxPerSphere; } function TurretFlareDeployableImage::onDeploy(%item, %plyr, %slot) { %searchRange = 5.0; %mask = $TypeMasks::TerrainObjectType | $TypeMasks::InteriorObjectType; %eyeVec = %plyr.getEyeVector(); %eyeTrans = %plyr.getEyeTransform(); %eyePos = posFromTransform(%eyeTrans); %nEyeVec = VectorNormalize(%eyeVec); %scEyeVec = VectorScale(%nEyeVec, %searchRange); %eyeEnd = VectorAdd(%eyePos, %scEyeVec); %searchResult = containerRayCast(%eyePos, %eyeEnd, %mask, 0); if(!%searchResult ) { messageClient(%plyr.client, 'MsgBeaconNoSurface', 'c2Cannot place turret. You are too far from surface.'); return 0; } %terrPt = posFromRaycast(%searchResult); %terrNrm = normalFromRaycast(%searchResult); %intAngle = getTerrainAngle(%terrNrm); %rotAxis = vectorNormalize(vectorCross(%terrNrm, "0 0 1")); if (getWord(%terrNrm, 2) == 1 || getWord(%terrNrm, 2) == -1) %rotAxis = vectorNormalize(vectorCross(%terrNrm, "0 1 0")); %rotation = %rotAxis @ " " @ %intAngle; %plyr.unmountImage(%slot); %plyr.decInventory(%item.item, 1); %deplObj = new Turret() { dataBlock = %item.deployed; position = VectorAdd(%terrPt, VectorScale(%terrNrm, 0.03)); rotation = %rotation; }; %deplObj.setRechargeRate(%deplObj.getDatablock().rechargeRate); %deplObj.team = %plyr.client.team; %deplObj.owner = %plyr.client; %deplObj.setOwnerClient(%plyr.client); if(%deplObj.getTarget() != -1) setTargetSensorGroup(%deplObj.getTarget(), %plyr.client.team); addToDeployGroup(%deplObj); AIDeployObject(%plyr.client, %deplObj); serverPlay3D(%item.deploySound, %deplObj.getTransform()); $TeamDeployedCount[%plyr.team, %item.item]++; %deplObj.deploy(); %deplObj.playThread($AmbientThread, "ambient"); return %deplObj; } function TurretFlareDeployable::onPickup(%this, %obj, %shape, %amount) { // created to prevent console errors } function DeployableFlareBarrel::onFire( %data, %obj, %slot ) { //%energy = %obj.getEnergyLevel(); %p = new (FlareProjectile)() { dataBlock = FlareGrenadeProj; initialDirection = %obj.getMuzzleVector(%slot); initialPosition = %obj.getMuzzlePoint(%slot); sourceObject = %obj; damageFactor = 1; sourceSlot = %slot; }; FlareSet.add(%p); %p.schedule(10000, "delete"); //%p.setEnergyPercentage(1); %obj.lastProjectile = %p; MissionCleanup.add(%p); //%obj.setEnergyLevel(%energy - %data.fireEnergy); } function FlareDeployed::onDestroyed(%this, %obj, %prevState) { Parent::onDestroyed(%this, %obj, %prevState); $TeamDeployedCount[%obj.team, TurretFlareDeployable]--; %obj.schedule(500, "delete"); } //function FlareTurretStart(%data, %obj, %slot) //{ // return DeployableFlareBarrel::onFire(DeployableFlareBarrel,%obj,%slot); // %obj.schedule(2000, "FlareTurretLoop"); //} //function FlareTurretLoop(%data, %obj, %slot) //{ // %obj.schedule(2000, "FlareTurretStart"); //}