Re: My Flettners wont fly :(
Posted: Wed Jan 27, 2010 6:32 am
This might help you. I found this a while ago. Ive never messed with environmental vehicles myself. The bottom of the document should give you a good idea of how they work tho. Also, Apache has some environmental vehicles in his DC Unauthorized mod you can check out. I'm sure his mod is in the "Mod Download" section of the forum. Credit goes to Zeuser[RET]
Environmental vehicles
By: Zeuser[RET]
Back when I was coding for DCX I put forward the term "Environmental vehicles" which simply means that a vehicle is just part of the environement to enahnce how a map feels and can't be flown by either bots or humans.
If you try the latest DCX (0.9) you'll find environmental vehicles on the Sniperfest, Lost village, Lost village Brit and Paintball maps.
A few types of environmental vehicles include:
1 - A pair of Medivac blackhawk helicopters that simply do a fly-by
2 - The same pair of Medivac Blackhawks but are used by the Bots as airborne spawnpoints. They will then parachute out of the heli when flying over landing zones.
3 - Save as above but with Chinooks for the British maps.
4 - A C-130 that swoops down and flies away.
And another type I just coded yesterday:
5 - A pair of SU-25s that fly-by and drop bombs.
Cool factor
What's cool about the environmental vehicles is that they spawn and simply fly straight on their own. They're not attached to a rotational bundle or anything. So this means you can shoot them down or even bump into them. And sometimes they can even run into a hill or building on their own. Pretty cool!
How it's done
Lets take the SU-25 and convert it to "environmental". We'll just make a copy of the SU-25 and make it environmental. Here's the code:
Objects.con:
rem ******************************************
rem - DesertCombat
rem - Version .39j
rem - August 12th
rem - Revision 2
rem ******************************************
rem raised to 200 hitpoints
rem ***************************************
rem *** DCX_SU-25BM / With bombs missiles ***
rem ***************************************
ObjectTemplate.create PlayerControlObject env_SU-25
ObjectTemplate.setNetworkableInfo DCX_SU-25_body_info
ObjectTemplate.saveInSeparateFile 1
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasDynamicShadow 1
ObjectTemplate.drag 0.061
ObjectTemplate.mass 3000
ObjectTemplate.inertiaModifier 0.95/0.943/0.968
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.hasResponsePhysics 1
ObjectTemplate.explosionRadius 8
ObjectTemplate.explosionDamage 5
ObjectTemplate.hasArmor 1
ObjectTemplate.angleMod 1
ObjectTemplate.speedMod 1
ObjectTemplate.hitpoints 200
ObjectTemplate.maxhitpoints 200
ObjectTemplate.material 63
ObjectTemplate.criticalDamage 20
ObjectTemplate.hpLostWhileCriticalDamage 1.5
ObjectTemplate.explosionForceMod 15
ObjectTemplate.hpLostWhileUpSideDown 10
ObjectTemplate.hpLostWhileDamageFromWater 10
ObjectTemplate.addArmorEffect 100 em_PlaneDamage -1.8/1.4/-4
ObjectTemplate.addArmorEffect 100 em_PlaneDamage 1.8/1.4/-4
ObjectTemplate.addArmorEffect 50 e_StukaFire 1.8/1.4/-4
ObjectTemplate.addArmorEffect 50 e_warning_jet_iraqi 0/.92/3
ObjectTemplate.addArmorEffect 20 e_StukaFire -1.8/1.4/-4
ObjectTemplate.addArmorEffect 20 e_StukaFire 1.8/1.4/-4
ObjectTemplate.addArmorEffect 20 e_warning_jet_iraqi 0/.92/3
ObjectTemplate.addArmorEffect 0 e_StukaFire -1/1/-4
ObjectTemplate.addArmorEffect 0 e_StukaFire 1/1/-4
ObjectTemplate.addArmorEffect 0 e_ExplGas_air 0/0/0
ObjectTemplate.addArmorEffect 0 e_scrapmetal_Plane 0/0/0
ObjectTemplate.addArmorEffect 0 e_ScrapDCX_SU25 0/0/0
ObjectTemplate.addArmorEffect -1 WaterWaterExplosion 0/0/0
ObjectTemplate.damageFromWater 1
ObjectTemplate.aiTemplate DCX_SU-25
rem -------------------------------------
ObjectTemplate.addTemplate env_lodSU-25
rem -------------------------------------
ObjectTemplate.setSoldierExitLocation -3/0.1/2.8 0/0/0
ObjectTemplate.GUIIndex 101
ObjectTemplate.setVehicleIcon "Vehicle/Icon_SU-25.dds"
ObjectTemplate.setVehicleIconPos 62/101
ObjectTemplate.setNumberOfWeaponIcons 2
ObjectTemplate.setPrimaryAmmoIcon "Ammo/Icon_bullet.tga"
rem *** Tan added heat ***
rem ObjectTemplate.setPrimaryAmmoBar ABAmmoBar
ObjectTemplate.setPrimaryAmmoBar ABAmmoBarHeatBar
ObjectTemplate.setSecondaryAmmoIcon "Ammo/icon_bomb.dds"
ObjectTemplate.setSecondaryAmmoBar ABAmmoBarReloadBar
ObjectTemplate.setCrossHairType CHTIcon
ObjectTemplate.setVehicleCategory VCAir
ObjectTemplate.setVehicleType VTDiveBomber
ObjectTemplate.setToolTipType TTDiveBomber
ObjectTemplate.setMinimapIcon "Minimap/minimap_icon_plane3_16x16.tga"
rem *** lodDCX_SU-25 ***
ObjectTemplate.create LodObject env_lodSU-25
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.hasResponsePhysics 1
rem -------------------------------------
ObjectTemplate.addTemplate env_SU-25Complex
ObjectTemplate.addTemplate DCX_SU-25Simple
ObjectTemplate.addTemplate DCX_SU-25Wreck
rem -------------------------------------
ObjectTemplate.lodSelector DCX_SU-25LodSelector
rem *** DCX_SU-25Complex ***
ObjectTemplate.create Bundle env_SU-25Complex
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.hasResponsePhysics 1
rem -------------------------------------
ObjectTemplate.addTemplate lodDCX_SU-25Cockpit
ObjectTemplate.addTemplate DCX_SU-25Camera
ObjectTemplate.setPosition 0/1/1.2
rem ObjectTemplate.addTemplate DCX_SU-25Seat
rem ObjectTemplate.setPosition 0/.92/1.8
ObjectTemplate.addTemplate env_SU-25Engine
ObjectTemplate.setPosition -1/0/0
ObjectTemplate.addTemplate env_SU-25EngineR
ObjectTemplate.setPosition 1/0/0
rem --- N/A ---
ObjectTemplate.addTemplate DCX_SU-25FlapLeftInner
ObjectTemplate.setPosition -0.945/-0.32/-1.141
ObjectTemplate.setRotation 15.5/0/12.5
ObjectTemplate.addTemplate DCX_SU-25FlapRightInner
ObjectTemplate.setPosition 0.95/-0.32/-1.141
ObjectTemplate.setRotation -15.498/0/-12.498
rem --- Flaps ---
ObjectTemplate.addTemplate DCX_SU-25FlapLeftMiddle
ObjectTemplate.setPosition -2.736/-0.216/-0.699
ObjectTemplate.setRotation 13/0/-9.498
ObjectTemplate.addTemplate DCX_SU-25FlapRightMiddle
ObjectTemplate.setPosition 2.741/-0.216/-0.699
ObjectTemplate.setRotation -12.998/0/9
rem --- Roll ---
ObjectTemplate.addTemplate DCX_SU-25FlapLeftOuter
ObjectTemplate.setPosition -4.9/.937/-3.71
ObjectTemplate.setRotation -.42/0/0
ObjectTemplate.addTemplate DCX_SU-25FlapRightOuter
ObjectTemplate.setPosition 4.9/.937/-3.71
ObjectTemplate.setRotation -.42/0/0
rem --- Elevators (preset at x trim) ---
ObjectTemplate.addTemplate DCX_SU-25FlapTailLeft
ObjectTemplate.setPosition -1.33/1.71/-8.54
rem ObjectTemplate.setRotation -.42/0/0
ObjectTemplate.setRotation -.42/-5/0
ObjectTemplate.addTemplate DCX_SU-25FlapTailRight
ObjectTemplate.setPosition 1.33/1.71/-8.54
rem ObjectTemplate.setRotation -.42/0/0
ObjectTemplate.setRotation -.42/-5/0
rem --- Rudder ---
ObjectTemplate.addTemplate DCX_SU-25Rudder
ObjectTemplate.setPosition 0/2.8/-7.88
ObjectTemplate.setRotation 0/0/-89.998
rem --- Lift ---
ObjectTemplate.addTemplate DCX_SU-25BodyWingVertical
ObjectTemplate.setRotation 0/0/-89.999
rem --- Weapons ---
ObjectTemplate.addTemplate env_SU-25_BombRack
rem -------------------------------------
Physics.con:
rem *** DCX_SU-25Engine ***
ObjectTemplate.create Engine env_SU-25Engine
ObjectTemplate.setNetworkableInfo DCX_SU-25_engine_info
ObjectTemplate.loadSoundScript Sounds/DCX_SU-25Engine.ssc
rem -------------------------------------
ObjectTemplate.addTemplate lodDCX_SU-25Propeller
ObjectTemplate.setPosition 0.2/.7/-3.5
rem -------------------------------------
ObjectTemplate.setMinRotation -0.3/0/-1
ObjectTemplate.setMaxRotation 0.3/0/1
ObjectTemplate.setMaxSpeed 800/0/1000
ObjectTemplate.setAcceleration 99999/0/99999
ObjectTemplate.setInputToRoll c_PIThrottle
ObjectTemplate.setAutomaticReset 1
ObjectTemplate.setEngineType c_ETRocket
ObjectTemplate.setTorque 40
ObjectTemplate.setDifferential 10
ObjectTemplate.setGearUp 0.2
ObjectTemplate.setGearDown 0.2
ObjectTemplate.setNoPropellerEffectAtSpeed 70
rem -------------------------------------
ObjectTemplate.addTemplate DCX_SU-25_Gear_Front
ObjectTemplate.setPosition 1/0/1.3
ObjectTemplate.setRotation 0/0/0
rem -------------------------------------
rem -------------------------------------
ObjectTemplate.addTemplate DCX_SU-25_Gear_BR
ObjectTemplate.setPosition .60/0/-2.3
ObjectTemplate.setRotation -30/0/0
rem -------------------------------------
rem -------------------------------------
ObjectTemplate.addTemplate DCX_SU-25_Gear_BL
ObjectTemplate.setPosition 1.40/0/-2.3
ObjectTemplate.setRotation 0/0/0
rem -------------------------------------
rem *** DCX_SU-25Engine Right ***
ObjectTemplate.create Engine env_SU-25Engine2
ObjectTemplate.setNetworkableInfo DCX_SU-25_engine2_info
rem *** Tan removed the second engine sound ***
rem ObjectTemplate.loadSoundScript Sounds/DCX_SU-25Engine.ssc
rem -------------------------------------
ObjectTemplate.addTemplate lodDCX_SU-25PropellerR
ObjectTemplate.setPosition -0.2/.7/-3.5
rem -------------------------------------
ObjectTemplate.setMinRotation -0.3/0/-1
ObjectTemplate.setMaxRotation 0.3/0/1
ObjectTemplate.setMaxSpeed 800/0/1000
ObjectTemplate.setAcceleration 99999/0/99999
ObjectTemplate.setInputToRoll c_PIThrottle
ObjectTemplate.setAutomaticReset 1
ObjectTemplate.setEngineType c_ETRocket
ObjectTemplate.setTorque 40
ObjectTemplate.setDifferential 10
ObjectTemplate.setGearUp 0.2
ObjectTemplate.setGearDown 0.2
ObjectTemplate.setNoPropellerEffectAtSpeed 70
Weapons.con:
rem *** DCX_SU-25_BombRack ***
ObjectTemplate.create FireArms env_SU-25_BombRack
ObjectTemplate.setNetworkableInfo DCX_PlaneFireArmInfo
ObjectTemplate.setAsynchronyFire 1
ObjectTemplate.aiTemplate DCX_SU-25_Missiles
ObjectTemplate.projectileTemplate MK83Bomb
ObjectTemplate.projectilePosition 0/-1/0
ObjectTemplate.visibleDummyProjectileTemplate DCX_AV8MK83Dummy
ObjectTemplate.magSize 8
ObjectTemplate.numOfMag 1
ObjectTemplate.velocity 0
ObjectTemplate.autoReload 1
ObjectTemplate.reloadtime 5
ObjectTemplate.roundOfFire 3
ObjectTemplate.fireingForce 0
ObjectTemplate.setInputFire c_PIAltFire
ObjectTemplate.rotationalSpeed 0/0/0
ObjectTemplate.AmmoType 8
rem --- Enhancments to drop bombs automatically ---
ObjectTemplate.DelayToUse 1
ObjectTemplate.FireDelay 2
ObjectTemplate.autoFire 1
ObjectTemplate.addFireArmsPosition 4.29/.423/-2.9 -0.487588/-0.065582/0
ObjectTemplate.addFireArmsPosition -4.29/.423/-2.9 .487588/-0.065582/0
Rem ---
ObjectTemplate.addFireArmsPosition 3.51/.5/-2.64 -0.399144/-0.056859/0
ObjectTemplate.addFireArmsPosition -3.51/.5/-2.64 .399144/-0.056859/0
Rem ---
ObjectTemplate.addFireArmsPosition 2.8/.57/-2.43 -0.31854/-0.048919/0
ObjectTemplate.addFireArmsPosition -2.8/.57/-2.43 .31854/-0.048919/0
Rem ---
ObjectTemplate.addFireArmsPosition 1.97/.66/-2.17 -0.224233/-0.0387/0
ObjectTemplate.addFireArmsPosition -1.97/.66/-2.17 .224233/-0.0387/0
Notice all the bolded parts.
The idea is to use the SU-25 almost as-is. But you must remove the entry to prevent a player or bot from entering the vehicle. Of course the camera, seat and a few other objects can also be removed. but it does work in its current form.
Then you'll noticed that I jammed the elevators at 5 degrees up rotation so the SU-25 has a tendency ot nose up a bit. This prevents it from crashing into the ground on take-off.
The important part ot make this work is to use the "Rocket" type of engine so it'll instantly go on as soon as it spawns. And then adjust the minroation, maxrotation and acceleration in such a way that the engine gets max thrust ASAP! I also double the engine power to make sure it flies forward soon as it spawns.
You'll notice the weapon changes as well. it's set to drop bombs a few seconds after it spawns. I'll try to get that thing to randomize as well.
Use on a map
What I usually do is put a spawner in the air on the edge of a map pointing inwards towards the center of the map. On certain maps like Lost village I point them towards the landing zones. So unless they're shot down or bumped into, the helis fly over the landing zones.
I usually set the spawn times as random so it doesn't become too predicatble.
On some maps, like Bulge, I put the spawners on rotational bundles. Combined with the random spawn times, the vehicles are hard to predict. You never know when they'll come and from where they'll come.
Experiment with the concept a bit and be creative. Add spawn points, make the vehicle go round and round, add bot gunners etc.
The important part is that the vehicle is autonomous and can react to weapons and collisions. It looks more natural that way.