[CSM] [CSM] Make a Homing Missile by using Springs..

Lots of cool and useful tips to mod either serverside or clientside

Make a Homing Missile by using Springs..

Postby Dennis|8749236 » Sun Jan 08, 2012 11:46 pm

Yes, as the title said, is teaching you how to make a Homing Missile.
There is few thing i want to say before i start.
First: This is not a Homing Missile, it is "Homing" because it act like a Homing Missile, so it is not a Homing Missile at all..
Second: This method may cause lag (checkVecs 3000+ each time, maybe 10000)
Third: This method is hard to adjust, especially on a projectile with small Model.
Fourth: This method is created by Zeuser, a developer of DCX Team, so dont thank to me thank to Zeuser(<-- i would like to kill my self)
Fifth: download the attachment, it is the mesh that made by Zeuser, why i ask you to download it is because i have noidea how to make a mesh just like Zeuser made. (no collision to Static Object)
HomingMissile.rar
The Model that needed
(941 Bytes) Downloaded 343 times



First step, Creat a folder and name it whatever you want just NO space or some character that BF1942 doesn't support!!!

Second step, creat 3 txt file in that folder, change the extension to .con and name it Geometries.con, Physics.con and Weapons.con or whatever you want.

Third step, in Geometries.con you need to write the code that load the mesh in the attachment
Code: Select all
rem - You can name this Mesh to other names
GeometryTemplate.create StandardMesh DCX_Homies_Spring_M1
GeometryTemplate.file DC_Extended\Homing\missile_tri
rem *** Visual model for debugging ***
rem GeometryTemplate.file DC_Extended\Homing\missile_tri_vis


Fourth Step: in Physics.con, you need to write 4 springs' code like this:
Make sure the geometry's name are correct if you give them a new name in Geometry.con
Code: Select all
rem - you can name it to other names
ObjectTemplate.create Spring DCX_Homies_SpringL
ObjectTemplate.geometry DCX_Homies_Spring_M1
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.hasResponsePhysics 1
ObjectTemplate.Grip c_PGFDummyGrip
ObjectTemplate.setStrength 5
ObjectTemplate.setDamping 2
rem ObjectTemplate.createInvisible 1

ObjectTemplate.create Spring DCX_Homies_SpringR
ObjectTemplate.geometry DCX_Homies_Spring_M1
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.hasResponsePhysics 1
ObjectTemplate.Grip c_PGFDummyGrip
ObjectTemplate.setStrength 5
ObjectTemplate.setDamping 2
rem ObjectTemplate.createInvisible 1

ObjectTemplate.create Spring DCX_Homies_SpringU
ObjectTemplate.geometry DCX_Homies_Spring_M1
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.hasResponsePhysics 1
ObjectTemplate.Grip c_PGFDummyGrip
ObjectTemplate.setStrength 5
ObjectTemplate.setDamping 2
rem ObjectTemplate.createInvisible 1

ObjectTemplate.create Spring DCX_Homies_SpringD
ObjectTemplate.geometry DCX_Homies_Spring_M1
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.hasResponsePhysics 1
ObjectTemplate.Grip c_PGFDummyGrip
ObjectTemplate.setStrength 5
ObjectTemplate.setDamping 2
rem ObjectTemplate.createInvisible 1


Fifth Step, in Weapons.con, you need to write a bundle that include the Springs.
And one thing VERY IMPORTANT! In order to rotate the Spring, you need to add Spring to a bundle first before you add it to a bundle.
Code: Select all

rem *** Add 2 following lines to missiles to enable homing

rem ObjectTemplate.addTemplate DCX_Homies_Seeker
rem ObjectTemplate.setPosition 0/0/0

ren - You can name it to other names - Dennis
rem *** Seeker head ***
ObjectTemplate.create Bundle DCX_Homies_Seeker

rem - This code are used to make Bundle rotate, before you enable this, you need to change the Bundle to RotationalBundle - Dennis
rem ObjectTemplate.setMaxSpeed 500/500/500
rem ObjectTemplate.setContinousRotationSpeed 0/0/500
rem -------------------


rem - I think you can remove this one because it is comment out.. - Dennis
beginrem
rem -----------------------
rem - *** Springs ***     -
rem -----------------------

rem *** Top side ***
ObjectTemplate.addTemplate DCX_Homies_BundleU
ObjectTemplate.setPosition 0/0/0
ObjectTemplate.setRotation 0/0/0
rem *** Bottom side ***
ObjectTemplate.addTemplate DCX_Homies_BundleD
ObjectTemplate.setPosition 0/0/0
ObjectTemplate.setRotation 0/0/179.99
rem *** Left side ***
ObjectTemplate.addTemplate DCX_Homies_BundleR
ObjectTemplate.setPosition 0/0/0
ObjectTemplate.setRotation 0/0/90
rem *** Right side ***
ObjectTemplate.addTemplate DCX_Homies_BundleL
ObjectTemplate.setPosition 0/0/0
ObjectTemplate.setRotation 0/0/-90
endrem


rem -------------------------------
rem *** Settings for triangles ***
rem -------------------------------

rem *** Top side ***
ObjectTemplate.addTemplate DCX_Homies_BundleU
ObjectTemplate.setPosition 0/1/-5
ObjectTemplate.setRotation 0/-15/0
rem *** Bottom side ***
ObjectTemplate.addTemplate DCX_Homies_BundleD
ObjectTemplate.setPosition 0/-1/-5
ObjectTemplate.setRotation 0/15/179.99
rem *** Left side ***
ObjectTemplate.addTemplate DCX_Homies_BundleR
ObjectTemplate.setPosition 1/0/-5
ObjectTemplate.setRotation -15/0/90
rem *** Right side ***
ObjectTemplate.addTemplate DCX_Homies_BundleL
ObjectTemplate.setPosition -1/0/-5
ObjectTemplate.setRotation 15/0/-90
rem -------------------



rem ---------------------------------
rem - *** Spring bundles ***
rem ---------------------------------

rem *** Left bundle ***
ObjectTemplate.create Bundle DCX_Homies_BundleL
rem ---------------------------------
ObjectTemplate.addTemplate DCX_Homies_SpringL
rem ---------------------------------

rem *** Right bundle ***
ObjectTemplate.create Bundle DCX_Homies_BundleR
rem ---------------------------------
ObjectTemplate.addTemplate DCX_Homies_SpringR
rem ---------------------------------

rem *** Upper bundle ***
ObjectTemplate.create Bundle DCX_Homies_BundleU
rem ---------------------------------
ObjectTemplate.addTemplate DCX_Homies_SpringU
rem ---------------------------------

rem *** Lower bundle ***
ObjectTemplate.create Bundle DCX_Homies_BundleD
rem ---------------------------------
ObjectTemplate.addTemplate DCX_Homies_SpringD
rem ---------------------------------


Sixth Step, Add the Homing Seeker Head to the Projectile that you want to add.
There is some restriction to the Projectile that you want to add.
1. The Projectile must have an engine and it must Strong Enough to correct the Trajectory of Projectile
2. Place the Homing Seeker Head behind the center or Projectile else it will not working properly

Seventh Step, Infinite Debugging...
Why its Infinite? Because it is too hard to find a value that is working for all Projectiles, especially the Small one.
For Example: Magic II Missile in DCX, i tried to make it work so it can lock on target properly (Keep tracking the Target until hits), and it always over reacting and Spin like Crazy, and when i switch it to a Bigger Model or make it 5 times Scale, it will not over reacting and Spinning (Actually it still spin but that helps to track target)

To make you have less work on Debugging, i'll write out the value that may affect the Homing Effect when i was doing the Test.
The Power of Engine, if it\s weak then the Projectile cannot correct the trajectory to the Target.
The value of this, a little effect on reacting force:
Code: Select all
rem *** Top side ***
ObjectTemplate.addTemplate DCX_Homies_BundleU
ObjectTemplate.setPosition 0/1/-5    <--- The Z value -5
ObjectTemplate.setRotation 0/-15/0
rem - Also, the Angle affect the Lock Angle, maybe something else..

The value of Strength and Damping, Strength set the force of Bouncing when Spring collide with Target. Damping Set the force reducing speed. Please dont set either of them to 0. If Strength is 0 then the Homing Missile will not Work; If Damping is 0 then your eye will broken (it acts so weird..)
The Wing of Projectile, the Wing will Stablize the Trajectory of Projetile, it will turn the missile to the opposite direction a bit (depend on the value of winglift) after the Springs collide with the Target.
The Size of Projectile's Model, the Bigger Model seems have higher Air Resistance and Inertia, and Higher Inertia = More easier to adjust, dont Spin like Crazy, Easier to Track the Target.


How Does Homing Missile Works?
It is VERY simple, just a spring collide with Target and bounce to move the Projectile.
Just like when you are Driving the Jeep and Falling from high, but your wheels land first you may bounce into air a little bit.
Or another example, you land a Mig-29 in DC with the front wheel first and very hard. The Head of Mig-29 will bounce back into air. Just like that.
The only problem is finding an Approriate value for the missile is very HARD, especially for ALL..

A SA-3 Rocket that looks working fine(It can lock on a target for a few second, also it have Shaking problem)..
In DCX 0.9..
Physics.con
Code: Select all
ObjectTemplate.create Spring DCX_HomiesGen2_SpringU
ObjectTemplate.geometry DCX_Homies_Spring_M1
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.hasResponsePhysics 1
ObjectTemplate.Grip c_PGFDummyGrip
rem ---------------------------
rem ObjectTemplate.addTemplate DCX_Homies_WingHorizontal
rem ObjectTemplate.setRotation 0/15/0
rem ---------------------------
rem ObjectTemplate.setStrength 5
rem ObjectTemplate.setDamping 2
ObjectTemplate.setStrength 6
ObjectTemplate.setDamping 4
rem ObjectTemplate.createInvisible 1

ObjectTemplate.addToCollisionGroup c_CGLandscape
ObjectTemplate.addToCollisionGroup c_CGStaticObjects


ObjectTemplate.create Spring DCX_HomiesGen2_SpringD
ObjectTemplate.geometry DCX_Homies_Spring_M1
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.hasResponsePhysics 1
ObjectTemplate.Grip c_PGFDummyGrip
rem ---------------------------
rem ObjectTemplate.addTemplate DCX_Homies_WingHorizontal
rem ObjectTemplate.setRotation 0/-15/0
rem ---------------------------
ObjectTemplate.setStrength 6
ObjectTemplate.setDamping 4
rem ObjectTemplate.createInvisible 1

ObjectTemplate.addToCollisionGroup c_CGLandscape
ObjectTemplate.addToCollisionGroup c_CGStaticObjects


ObjectTemplate.create Spring DCX_HomiesGen2_SpringR
ObjectTemplate.geometry DCX_Homies_Spring_M1
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.hasResponsePhysics 1
ObjectTemplate.Grip c_PGFDummyGrip
rem ---------------------------
rem ObjectTemplate.addTemplate DCX_Homies_WingVertical
rem ObjectTemplate.setRotation 15/0/0
rem ---------------------------
ObjectTemplate.setStrength 6
ObjectTemplate.setDamping 4
rem ObjectTemplate.createInvisible 1

ObjectTemplate.addToCollisionGroup c_CGLandscape
ObjectTemplate.addToCollisionGroup c_CGStaticObjects


ObjectTemplate.create Spring DCX_HomiesGen2_SpringL
ObjectTemplate.geometry DCX_Homies_Spring_M1
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.hasResponsePhysics 1
ObjectTemplate.Grip c_PGFDummyGrip
rem ---------------------------
rem ObjectTemplate.addTemplate DCX_Homies_WingVertical
rem ObjectTemplate.setRotation -15/0/0
rem ---------------------------
ObjectTemplate.setStrength 6
ObjectTemplate.setDamping 4
rem ObjectTemplate.createInvisible 1

ObjectTemplate.addToCollisionGroup c_CGLandscape
ObjectTemplate.addToCollisionGroup c_CGStaticObjects



ObjectTemplate.create Wing DCX_Homies_WingVertical
ObjectTemplate.setPitchOffset 0
ObjectTemplate.setPositionOffset 0/0/0
rem ObjectTemplate.setWingLift 0.1
ObjectTemplate.setWingLift 0.1
ObjectTemplate.setFlapLift 0

ObjectTemplate.create Wing DCX_Homies_WingHorizontal
ObjectTemplate.setPitchOffset 0
ObjectTemplate.setPositionOffset 0/0/0
rem ObjectTemplate.setWingLift 0.1
ObjectTemplate.setWingLift 0.1
ObjectTemplate.setFlapLift 0


Weapons.con
Code: Select all
rem *** Seeker head ***
ObjectTemplate.create Bundle DCX_HomiesGen2_Seeker
rem -------------------

rem -----------------------
rem - *** Springs ***     -
rem -----------------------

beginrem
rem *** Top side ***
ObjectTemplate.addTemplate DCX_HomiesGen2_SpringU
ObjectTemplate.setPosition 0/1/0
ObjectTemplate.setRotation 0/-15/0
rem *** Bottom side ***
ObjectTemplate.addTemplate DCX_HomiesGen2_SpringD
ObjectTemplate.setPosition 0/-1/0
ObjectTemplate.setRotation 0/15/179.99
rem *** Left side ***
ObjectTemplate.addTemplate DCX_HomiesGen2_SpringR
ObjectTemplate.setPosition 1/0/0
ObjectTemplate.setRotation -15/0/90
rem *** Right side ***
ObjectTemplate.addTemplate DCX_HomiesGen2_SpringL
ObjectTemplate.setPosition -1/0/0
ObjectTemplate.setRotation 15/0/-90
endrem


rem -------------------


rem *** My Settings for Trapezoid ***
rem *** Top side ***
ObjectTemplate.addTemplate DCX_HomiesGen2_BundleU
ObjectTemplate.setPosition 0/1/0
ObjectTemplate.setRotation 0/-7.5/0
rem *** Bottom side ***
ObjectTemplate.addTemplate DCX_HomiesGen2_BundleD
ObjectTemplate.setPosition 0/-1/0
ObjectTemplate.setRotation 0/7.5/179.99
rem *** Left side ***
ObjectTemplate.addTemplate DCX_HomiesGen2_BundleR
ObjectTemplate.setPosition 1/0/0
ObjectTemplate.setRotation 7.5/0/-90
rem *** Right side ***
ObjectTemplate.addTemplate DCX_HomiesGen2_BundleL
ObjectTemplate.setPosition -1/0/0
ObjectTemplate.setRotation -7.5/0/90


rem -------------------


rem - I add the Springs to the Bundles so they can be rotate..
rem ---------------------------------
rem - *** Spring bundles ***
rem ---------------------------------

rem *** Left bundle ***
ObjectTemplate.create Bundle DCX_HomiesGen2_BundleL
rem ---------------------------------
ObjectTemplate.addTemplate DCX_HomiesGen2_SpringL
rem ---------------------------------

rem *** Right bundle ***
ObjectTemplate.create Bundle DCX_HomiesGen2_BundleR
rem ---------------------------------
ObjectTemplate.addTemplate DCX_HomiesGen2_SpringR
rem ---------------------------------

rem *** Upper bundle ***
ObjectTemplate.create Bundle DCX_HomiesGen2_BundleU
rem ---------------------------------
ObjectTemplate.addTemplate DCX_HomiesGen2_SpringU
rem ---------------------------------

rem *** Lower bundle ***
ObjectTemplate.create Bundle DCX_HomiesGen2_BundleD
rem ---------------------------------
ObjectTemplate.addTemplate DCX_HomiesGen2_SpringD
rem ---------------------------------


SA-3's Physics.con
Code: Select all
ObjectTemplate.create Engine DCX_SA3Rocket_Engine
ObjectTemplate.hasMobilePhysics 1
ObjectTemplate.setMinRotation 0/0/0
rem ObjectTemplate.setMaxRotation 0/0/10
ObjectTemplate.setMaxRotation 0/0/100
ObjectTemplate.setMaxSpeed 0/0/8000
ObjectTemplate.setAcceleration 0/0/10000
ObjectTemplate.setInputToRoll c_PIThrottle
ObjectTemplate.setEngineType c_ETRocket
rem ObjectTemplate.setEngineType c_ETPlane
rem *** Slow Mode ***
rem ObjectTemplate.setTorque 150.0
rem ObjectTemplate.setNoPropellerEffectAtSpeed 200
rem ObjectTemplate.setDifferential 150.0
rem *** Fast Mode ***
ObjectTemplate.setTorque 3000.0
ObjectTemplate.setNoPropellerEffectAtSpeed 4000
ObjectTemplate.setDifferential 3000.0
ObjectTemplate.loadSoundScript Sounds/DCX_SA3RocketEngine.ssc

ObjectTemplate.create Wing DCX_SA3Rocket_Wing
ObjectTemplate.setPitchOffset 0
ObjectTemplate.setPositionOffset 0/0/0
ObjectTemplate.setWingLift 0.1
ObjectTemplate.setFlapLift 0


SA-3's Weapons.con
Code: Select all
rem ******************************************
rem - DesertCombat
rem - Version .4a
rem - July 30th
rem - Revision 1
rem ******************************************
rem created. -MuRa 7/30/2003


rem *** Shaking Problem Detected
rem *** Reason: Unknown

ObjectTemplate.create Projectile DCX_SA-3Rocket
ObjectTemplate.saveInSeparateFile 1
ObjectTemplate.geometry SA3_missile_dummy_m1
ObjectTemplate.timeToLive CRD_UNIFORM/3/4/0
rem ObjectTemplate.timeToLive CRD_UNIFORM/10/11/0
ObjectTemplate.hasCollisionPhysics 1
ObjectTemplate.setHasPointPhysics 0
ObjectTemplate.gravityModifier 0.0
ObjectTemplate.drag 0.02
rem ObjectTemplate.mass 0.1
ObjectTemplate.mass 950
ObjectTemplate.startEffectTemplate e_TomahawkFume
ObjectTemplate.endEffectTemplate e_ExplGranade
ObjectTemplate.hasCollisionEffect 1
ObjectTemplate.hasOnTimeEffect 1
ObjectTemplate.invisibleAtEndEffect 1
ObjectTemplate.stopAtEndEffect 1
ObjectTemplate.dieAfterColl 1
ObjectTemplate.invisible 0
ObjectTemplate.damageType 1
ObjectTemplate.radius 30
ObjectTemplate.ForceOnExplosion 35
rem ---------------------------------
ObjectTemplate.material 851
ObjectTemplate.material2 850
ObjectTemplate.ProximityFusePrimer 0.25
rem ObjectTemplate.explodeNearEnemyDistance 15
ObjectTemplate.explodeNearEnemyDistance 7
rem ---------------------------------

ObjectTemplate.addTemplate DCX_SA3Rocket_Wing
ObjectTemplate.setPosition 0/0/-2.5
ObjectTemplate.setRotation 0/0/0

ObjectTemplate.addTemplate DCX_SA3Rocket_Engine
ObjectTemplate.setPosition 0/0/-3
ObjectTemplate.setRotation 0/0/0

rem ObjectTemplate.addTemplate DCX_Homies_Seeker
ObjectTemplate.addTemplate DCX_HomiesGen2_Seeker
rem ObjectTemplate.setPosition 0/0/-6
rem *** Settings when Triangle
rem ObjectTemplate.setPosition 0/0/-24
rem *** Settings when Trapezoid
rem ObjectTemplate.setPosition 0/0/-6
ObjectTemplate.setPosition 0/0/-6



rem *** SA3_RocketDummy ***
ObjectTemplate.create SimpleObject DCX_SA3_RocketDummy
ObjectTemplate.geometry SA3_missile_dummy_m1

ObjectTemplate.create SimpleObject DCX_SA-3TruckRocketDummy
rem ObjectTemplate.geometry DCX_GuidedSAM_Model
ObjectTemplate.geometry SA3_missile_dummy_m1










---------- Add ----------
The springs act in exactly same way as the spring that used to be wheel.
Actually I'm being really stupid on this problem, i took 2 years to understand it >.<
Last edited by Dennis|8749236 on Mon Feb 20, 2012 5:49 pm, edited 2 times in total.
What is the meaning of Life?? (Don't think about it!)
User avatar
Dennis|8749236
 
Posts: 239
Joined: Sun Nov 29, 2009 6:02 am
Location: Earth

Re: Make a Homing Missile by using Springs..

Postby Dennis|8749236 » Sun Jan 08, 2012 11:47 pm

How come it have 2 Prefixes!?
And i can't fix it >.<
What is the meaning of Life?? (Don't think about it!)
User avatar
Dennis|8749236
 
Posts: 239
Joined: Sun Nov 29, 2009 6:02 am
Location: Earth

Re: Make a Homing Missile by using Springs..

Postby fo0k » Mon Jan 09, 2012 2:51 am

heheh not sure bout 2 prefixes :/ maybe a bug has come up after the last site update,

great work on this tut though. cant try it anytime soon but cool it can be done :)
User avatar
fo0k
 
Posts: 1411
Joined: Fri Oct 16, 2009 4:21 pm
Location: UK

Re: Make a Homing Missile by using Springs..

Postby Dennis|8749236 » Mon Jan 09, 2012 2:34 pm

Thank you f0k.
I suggest you try it on the projectile that have bigger model first.
In my experience, they are easier to control than smaller one = )
What is the meaning of Life?? (Don't think about it!)
User avatar
Dennis|8749236
 
Posts: 239
Joined: Sun Nov 29, 2009 6:02 am
Location: Earth


Return to General Modding Tutorials

Who is online

Users browsing this forum: No registered users and 2 guests