funny dance missiles with SetProjectileTarget

funny dance missiles with SetProjectileTarget

Discuss Lua based Spring scripts (LuaUI widgets, mission scripts, gaia scripts, mod-rules scripts, scripted keybindings, etc...)

Moderator: Moderators

Locked
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

funny dance missiles with SetProjectileTarget

Post by knorke »

tl;dr: SetProjectileTarget to make projectiles fly elsewhere

Image
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:
Image

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
Image
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)
So one can aim the projectile towards x,y,z and some time later make it aim towards x2,y2,z2 then again bit later towards x3,y3,z3 etc. and the projectile will fly along those "waypoints."
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)
without worry whether the original target was unit, feature,etc

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()


Image

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.
Attachments
tp_projectile_test.lua
(4.55 KiB) Downloaded 27 times
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: funny dance missiles with SetProjectileTarget

Post by PicassoCT »

Awesome and not rocketsience.. or wait awesome and rocketsience..
Now we all can go vonBraun into every direction..

weee... ccomender has macross missiles now
User avatar
jK
Spring Developer
Posts: 2299
Joined: 28 Jun 2007, 07:30

Re: funny dance missiles with SetProjectileTarget

Post by jK »

Spring.SetProjectileTarget isn't needed for the most important effects. Missiles follow the emitdir of their emit piece (iirc depending on turret tag), so just rotate that piece and the missiles will fly in all directions.
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: funny dance missiles with SetProjectileTarget

Post by smoth »

I am not sure what is different between here and kdr's loli mod with the bunny. I don't even know where to begin to hunt it down but he added a bunch of tags for macross style stuff.

did you try combining them with your current work for even more bizarre patterns?
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: funny dance missiles with SetProjectileTarget

Post by PicassoCT »

inb4 insult writing rocket ..
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: funny dance missiles with SetProjectileTarget

Post by knorke »

jK:
Think you mean fixedlauncher = true.
With fixedlauncher=true tag the missiles launch in the direction of their emit-piece and then instantly start turning towards the target.
Normal missiles always do an arc towards target then once lined up with target they continue in straight line. Even if the arc starts starts of in a funny direction the possible flight paths are still somewhat limited.

For most launchers fixedlauncher=true would also result in unrealistic looking sideways starting, with SetProjectileTarget the missiles can launch normal and then do the wiggling, instead of launching "sideways":
Image
red line shows orientation of missile.
Also makes it bit easier to get the wanted radius of arc, how far away from launcher the missile is at the apex etc.
See the other examples too.
User avatar
Karl
Panzerstahl Developer
Posts: 746
Joined: 01 Apr 2010, 21:05

Re: funny dance missiles with SetProjectileTarget

Post by Karl »

hmm It looks interesting... Might be useful for something
maybe it is possible to fake "crazy" electronic cannon or some sort like with that


But is it possible to have such kind of rocket arc for (Starburst-)Missiles?
Currently the default Starburst-missile arc sucks balls and you need to add insanely huge rate thing (cba too look up it up) so that it wont collide with hills
Image
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: funny dance missiles with SetProjectileTarget

Post by PicassoCT »

Yes you can..

even cooler, you can make cruise missile kind rockets, that adapt to terrain..
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: funny dance missiles with SetProjectileTarget

Post by smoth »

PicassoCT wrote:even cooler, you can make cruise missile kind rockets, that adapt to terrain..
knorke said nothing of the sort and even aircraft in spring run through mountains sometimes
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: funny dance missiles with SetProjectileTarget

Post by knorke »

Karl:
yes, flight paths like these pictures are possible.
No idea how good Starburst-missiles can be redirected, but afaik they always launch vertically straight up? So they could not work either way like in these pictures.
PicassoCT wrote:even cooler, you can make cruise missile kind rockets, that adapt to terrain..
yes. The first example "after launch missiles fly downwards, then fly towards target in low altitude along the ground" is like that a bit.
See the commented out line:
addProjectileRedirect (proID, makeTargetTable(tx,Spring.GetGroundHeight (tx,tz)+100,tz), 10)
Makes the missile fly 100 elmo above ground.
To do similiar with just fixedLauncher=true one would have to carefully tweak turnrate,speed, acceleration etc of missile. And then if the aircraft flies a bit too low it might still bam the missile into ground.
With more waypoints it might give pretty cool results when the missile actually follows the terrain slopes...

Another thing:
One could use different flight paths according to circumstances.
For example if the target is close then just attack it normal.
If the target is far away then do the wiggling.
If the target is a tank attack it from above.
If the target is a ship attack it in low-altitude flight etc.
User avatar
Karl
Panzerstahl Developer
Posts: 746
Joined: 01 Apr 2010, 21:05

Re: funny dance missiles with SetProjectileTarget

Post by Karl »

knorke wrote:Karl:
yes, flight paths like these pictures are possible.
No idea how good Starburst-missiles can be redirected, but afaik they always launch vertically straight up? So they could not work either way like in these pictures.
.
That sounds good then, I might toy around that soon.
Yes they do after the Flighttime ends up they fly straight to the target
which is imo the most retarded thing ever.

The workaround for this would be to add insanely large Flighttime and aswell the missile speed to make it up

> http://i.imgur.com/t7btwCx.jpg I think to add compatibility for Starburst you would need to add something for the script to wait thill it's flighttime is done
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: funny dance missiles with SetProjectileTarget

Post by smoth »

I thought we had a tag to delay when tracking becomes active?
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: funny dance missiles with SetProjectileTarget

Post by Forboding Angel »

PicassoCT wrote:inb4 insult writing rocket ..
A nuke that writes FU in the sky before hitting?
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: funny dance missiles with SetProjectileTarget

Post by PicassoCT »

the prophet emanuel all saw it coming.. and you cast him out, the reckoning is near..

All praise be upon the Fuck in the sky, let us sing the hymn composed by Elton John:
Rocketman
User avatar
Forboding Angel
Evolution RTS Developer
Posts: 14673
Joined: 17 Nov 2005, 02:43

Re: funny dance missiles with SetProjectileTarget

Post by Forboding Angel »

Fucking thread necro.
User avatar
PicassoCT
Journeywar Developer & Mapper
Posts: 10450
Joined: 24 Jan 2006, 21:12

Re: funny dance missiles with SetProjectileTarget

Post by PicassoCT »

I distinctly remember that pinguins fuck there frozzen stiff dead. And what is the masscott of linux? Exactly.
With the magotts wriggling it almost feels like the real thing.
Locked

Return to “Lua Scripts”