Arcing Lightning effect.

Arcing Lightning effect.

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

Moderator: Moderators

Post Reply
User avatar
Lord Juzza
Posts: 60
Joined: 20 Jan 2009, 11:50

Arcing Lightning effect.

Post 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.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Arcing Lightning effect.

Post 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.
User avatar
maackey
Posts: 490
Joined: 02 Jul 2008, 07:11

Re: Arcing Lightning effect.

Post 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.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Arcing Lightning effect.

Post 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.
User avatar
Niobium
Posts: 456
Joined: 07 Dec 2008, 02:35

Re: Arcing Lightning effect.

Post 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?
User avatar
MidKnight
Posts: 2652
Joined: 10 Sep 2008, 03:11

Re: Arcing Lightning effect.

Post 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! :-)
User avatar
Lord Juzza
Posts: 60
Joined: 20 Jan 2009, 11:50

Re: Arcing Lightning effect.

Post 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?
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: Arcing Lightning effect.

Post 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.
Post Reply

Return to “Lua Scripts”