Missiles fly off in random directions, then go after target.
aka http://tvtropes.org/pmwiki/pmwiki.php/M ... leMassacre
This is not something finished, just result of testing "new" functions of 93.0
Have not seen those used so much, maybe it is useful as tutorial or start point in some way.
More example usage:
1) after launch missiles fly downwards, then fly towards target in low altitude along the ground
2) missiles do a loop over the shooter (why not)
3) missiles fly away to side before going after target
4) missiles fly normally towards target, then split up, then go after target
5) missiles go after target, after short time fly up higher than launch altitude, then go after target again.
7) -----v
Missiles wiggle around, then raise up high to hit target from above
How:
Usually targeted projectiles in Spring only aim towards one target.
So if target is stationary that means they either fly
a) in a straight line towards target
b) in some arc towards target
(unless wibble, wobble and wabble tags are used which gives some randomness)
Make all projectiles target towards coordinate 0,0,0:
Code: Select all
function gadget:ProjectileCreated(proID, proOwnerID)
Spring.SetProjectileTarget (proID, 0, 0, 0)
The last "waypoint" should be the original target: This way one can make missiles that do all sort of random flying but in the end still precisely hit the target.
Not that complicated really. Slight difficulty: projectiles can target units, features,coordinates (in air or on ground) and other projectiles.
That is the reason for the targetTable blablabla because those cases need to be handled.
This way one can do like this:
Code: Select all
local originalTarget = getTargetTable (proID)
...funny missile madness here...
addProjectileRedirect (proID, originalTarget, 150)
How to use:
Set up the WatchWeapon blablub, then do:
addProjectileRedirect (projectileID, targetTable, delayInFrames)
(chain as many as you want)
delayInFrames is delay in frames until the projectile goes towards this target.
The targetTable can be made with function makeTargetTable() or read it from a projectile with getTargetTable()
Note:
-function makeTargetTable only works for ground targets, lazy.
-SetProjectileCEG to change effect of projectile is useful for testing.
Best CEGs that leave loooong smoke trails.
-Testing is easier with missiles that have long flightime and decent speed/turnrates so they can actually follow the waypoints.
-The redirects should be tweaked to work with the weaponDef: If the missile is so fast that it reaches target in 0.1 seconds then no use to try to give it new course after 2 seconds etc.