CEG Muzzle flare... how the hell do you add one.

CEG Muzzle flare... how the hell do you add one.

Discuss game development here, from a distinct game project to an accessible third-party mutator, down to the interaction and design of individual units if you like.

Moderator: Moderators

User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

CEG Muzzle flare... how the hell do you add one.

Post by aGorm »

OK, can someone link me to how you use CEG's? More specificaly, for a muzzle flare? In Lua? Maybe I just sux, but I can't seem to piece together the workings from what I can find here.

aGorm
User avatar
smoth
Posts: 22309
Joined: 13 Jan 2005, 00:46

Re: CEG Muzzle flare... how the hell do you add one.

Post by smoth »

In the lua scripts forum I posted a directly converted unit for code review. That unit (iirc) the rgm has a muzzle flare emit in the fire weapon 1 block of code.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: CEG Muzzle flare... how the hell do you add one.

Post by FLOZi »

Do you intend for each weapon to always have the same muzzleFX? If so, I can make your life much easier.
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: CEG Muzzle flare... how the hell do you add one.

Post by knorke »

to teh nubmod!!

I added a muzzle flash effect to the attackvehiclemultimissile unit.
(only in SVN version so far)

click "diff" in this commit:
http://code.google.com/p/springtutorial ... etail?r=64
to see what got changed in both unitDef & script to add the CEG.
If you ignore the comments, it just needs 2 lines in the script.
User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Re: CEG Muzzle flare... how the hell do you add one.

Post by aGorm »

Thanks guys... knorke you are legend.

FLOZi, nope this is a one of flare. Why what were you going to suggest? (As I may still need a default one for some guns I expect...)
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: CEG Muzzle flare... how the hell do you add one.

Post by FLOZi »

Well in the battletech mod, we associate a particular flare with a particular weapondef.

Then we automagically add them to all unitdefs using that weapondef such that in the script you can just do:

Code: Select all

EmitSFX(thePiece, SFX.CEG + weaponID)
User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Re: CEG Muzzle flare... how the hell do you add one.

Post by aGorm »

error.jpg
(133.58 KiB) Downloaded 2 times
Hmmm... one problem, the "dir" the effect gets fed seems to be off to one side. How do you change that?

aGorm
User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Re: CEG Muzzle flare... how the hell do you add one.

Post by aGorm »

I guess the silence means no one knows an answer... :-(
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: CEG Muzzle flare... how the hell do you add one.

Post by FLOZi »

Try rotating the emitting piece to the direction of the weapon
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: CEG Muzzle flare... how the hell do you add one.

Post by knorke »

I had this too sometimes, no idea why it happens.
Had it happen too if the emit point was an empty piece at the end of a barrel and rotating the empty piece did nothing. I have no idea what is going on but it it involves randomly rotating the emit pieces in both script and upspring, deleting it and adding it again and eventually it will work. :?
User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Re: CEG Muzzle flare... how the hell do you add one.

Post by aGorm »

I noticed rotating the emit peice gave no joy... :-( hence the post. I shall try re-adding/rotating the point in upspring to see what happens.

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

Re: CEG Muzzle flare... how the hell do you add one.

Post by knorke »

if you get it almost correct by having a muzzle flash that goes 180┬░ in the wrong direction, you can also edit the effect:
length = -35,
or
size = -2
to flip it around.
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: CEG Muzzle flare... how the hell do you add one.

Post by FLOZi »

Never am sure on this but some fx (used to?) use direction between vertex 1 and vertex 2 of the emitting piece rather than it's script rotation
User avatar
knorke
Posts: 7971
Joined: 22 Feb 2006, 01:02

Re: CEG Muzzle flare... how the hell do you add one.

Post by knorke »

yes, might be something like this:
Spring.GetUnitPiecePosDir:

Returns piece position and direction in world space.[...]The position is defined as the position of the first vertex of the piece and it defines direction as the direction in which the line from the first vertex to the second vertex points.


how that matters for empty pieces, I dont know but seems it somehow does.
Tobi
Spring Developer
Posts: 4598
Joined: 01 Jun 2005, 11:36

Re: CEG Muzzle flare... how the hell do you add one.

Post by Tobi »

I think it uses an internal function LocalModelPiece::GetEmitDirPos, which uses a vector in the +z direction in piece space if the piece has no vertices, or the vector from (0, 0, 0) to the vertex if the piece has one vertex, or the vector from vertex 1 to vertex 2 if the piece has two vertices.

In other words, a piece with zero vertices should give the same result as a piece with one vertex (0, 0, z) with z > 0, and as a piece with two vertices (0, 0, 0) and (0, 0, z) with z > 0.

(Or in the last case: two vertices (x, y, z) and (x, y, z2) with z2 > z for the same emit direction, but an emit position of (x, y, z) instead of (0, 0, 0).)
User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Re: CEG Muzzle flare... how the hell do you add one.

Post by aGorm »

After a lot of faf I got it to point in the right direction... (put the flare inside another empty object and rotated that parent... only way it seemed to work!)

Now I'm wondering... anyone have an example of how you use "CExpGenSpawner" to que up several effects
# You can animate an explosion flip-book style using delays and several bitmaps.
I think I'm using them wrong... each of the two parts work fin if called, but I don't see how the CExpGenSpawner bit works so thatwas my best guess (IE, they will all be called as they have the same name, and the delays wil cause the other effects to start at stagurd times...)

http://pastebin.com/MyjETL2w

aGorm
User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Re: CEG Muzzle flare... how the hell do you add one.

Post by aGorm »

http://pastebin.com/nPEN65kh

OK, having looked through more examples (namely:
http://code.google.com/p/zero-k/source/ ... barney.lua
http://code.google.com/p/zero-k/source/ ... abelle.lua) I thought maybe I was on teh right track, but I still can't get anything to happen the second I try calling one CEG from a CExpGenSpawner... Anyone able to take a look? Please?

aGorm
User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Re: CEG Muzzle flare... how the hell do you add one.

Post by aGorm »

Thats one of the threads I was looking at yes... (I do use the forum search you know... :P ). I can't spot what I've done differently from anyone elses...

aGorm
User avatar
FLOZi
MC: Legacy & Spring 1944 Developer
Posts: 6240
Joined: 29 Apr 2005, 01:14

Re: CEG Muzzle flare... how the hell do you add one.

Post by FLOZi »

Nor can I. Sorry, CEG is one area I am really clueless about. :(
User avatar
aGorm
Posts: 2928
Joined: 12 Jan 2005, 10:25

Re: CEG Muzzle flare... how the hell do you add one.

Post by aGorm »

http://pastebin.com/rQDqyDtB

Succses! Not the final effect, but I atleast got it to work as expected! Have to remember that when using CExpGenSpawner you have to pass on things like "dir" into the ceg your calling... or it wont work and will bug you for days...

aGorm
Post Reply

Return to “Game Development”