Page 1 of 1

Arcing Lightning effect.

Posted: 25 Oct 2011, 12:55
by Lord Juzza
I'm looking to add Arcing lightning to lightningcannons in my mod PA. I'd like Lightning Cannons to hit their targets and then for another effect to be drawn(probably with lups) to the next closest unit in range as it also takes damage through a gadget and then continues the arc. I don't have any idea how to approach this however.

I only need help with actually drawing the effect. Has anyone done anything like this before that I could use or alternatively could anyone offer me some advice as to how to approach it.

Thanks.

Re: Arcing Lightning effect.

Posted: 25 Oct 2011, 13:59
by knorke
do you need help with just the gfx effect or the logic?
For the graphic effect I would use a ceg with SpawnCEG, maybe spawn them in a line towards other units or something.

Re: Arcing Lightning effect.

Posted: 25 Oct 2011, 16:28
by maackey
I know it can be done, CarRepairer made a pretty cool chain lightning spell for my wizzard a while back. Might want to ask him.

Re: Arcing Lightning effect.

Posted: 25 Oct 2011, 17:06
by knorke
just quickly did this as a demo:
Image
http://pastebin.com/J9GdtMpS

The idea is that when a unit is hit by a specfiy weapon, you get the units that are near the hit unit. Then you loop through those units and deal damage to them. And draw some effects with gl or by spamming cegs.

of course endless possibilies to customize that...
ie change the -1 to weaponID in
Spring.AddUnitDamage (nearUnits, damage/2, 0, attackerID, -1)
and you get damage that jumps from unit to unit to unit to unit...
will need some condition to jump that or its endless recursion=spring hangs.

local nearUnits = Spring.GetUnitsInCylinder (x,z, 500, unitTeam)
500=range
change the team to make it also deal damage to allies.
Or spells like in DOTA etc where damaging an enemy heals near allies or whatever.

Re: Arcing Lightning effect.

Posted: 26 Oct 2011, 08:43
by Niobium
knorke wrote:just quickly did this as a demo:
Is there a way to have the 'arcs' between units as a single textured "beam" (i.e. the lightning weapon in the screenshot) as opposed to a line of discrete CEGs?

Generalizing it, how would one go about drawing a flat 2D texture (i.e. the lightning weapon texture) between two points in world coords, with the texture always 'facing' the camera?

Re: Arcing Lightning effect.

Posted: 26 Oct 2011, 21:01
by MidKnight
Niobium wrote:
knorke wrote:just quickly did this as a demo:
Is there a way to have the 'arcs' between units as a single textured "beam" (i.e. the lightning weapon in the screenshot) as opposed to a line of discrete CEGs?
Yes!
Get the nearest unit, arc to it, and iterate! Make sure you don't arc back to a unit you've already shocked, though!

Alternatively, you could get a list of units near the first shocked unit and do some kind of weird traveling salesman thing, but that's not as nice as the first way, IMO.
Generalizing it, how would one go about drawing a flat 2D texture (i.e. the lightning weapon texture) between two points in world coords, with the texture always 'facing' the camera?
That's called a billboard! Look it up! You can draw them with CEGs (probably -- don't take my word for it), but they likely won't scale the way you want them to.

You can also draw them using Lua.

PS: You should figure out a way to draw your lightening procedurally. It'd look a lot better than a prenade texture.

Best of luck! :-)

Re: Arcing Lightning effect.

Posted: 27 Oct 2011, 14:17
by Lord Juzza
As interesting as all this input has been what we really need answered is this is this...
Niobium wrote:
knorke wrote:just quickly did this as a demo:
Is there a way to have the 'arcs' between units as a single textured "beam" (i.e. the lightning weapon in the screenshot) as opposed to a line of discrete CEGs?

Generalizing it, how would one go about drawing a flat 2D texture (i.e. the lightning weapon texture) between two points in world coords, with the texture always 'facing' the camera?

Re: Arcing Lightning effect.

Posted: 27 Oct 2011, 16:04
by knorke
get some simple spring gl example ie http://answers.springlobby.info/questio ... game-world and replace the coordinates with whatever you need. ie here it is the same code but now vertical.
Instead of billboards I would try a technic like used in old new games for trees:
Image
2 planes that are stacked into each other, read more about it at this blog.
For the laserthing it would be horinzontal of course.
some more examples:
The shields in zeroK draw lines to other shields to show linkage.
math can be stolen here for curved arcs:
The bases in some kernel panic mode are linked with funky arcs iirc.
zeroK jumpsets show a 3d arc preview of the flightpath.