HowTo: Attach an Effect to an Object W/O Hardpoints (FAQ)

In this forum you will find and post information regarding the modding of Star Wars Battlefront 2. DO NOT POST MOD IDEAS/REQUESTS.

Moderator: Moderators

Post Reply
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

HowTo: Attach an Effect to an Object W/O Hardpoints (FAQ)

Post by Ace_Azzameen_5 »

Ever wanted to attach an effect to an object, but it didn't have a hard point, or hard point where you wanted it to be? Just want the effect on one object?
Don't want to mass with effect spawner mshs?

Well, here's a solution using some of the games lua commands an the particle editor.
Its all based on these two simple lines of code:

Code: Select all

FecLoc = GetEntityMatrix("bes2_bldg_street_lamp17")
AttachEffectToMatrix(CreateEffect("blue_light"), FecLoc)
This is my code to attach a custom effect to the Bespin street lantern.
Obviously "bes2_bldg_street_lamp" is the ODF and "blue_light" is the FX file.
Note the LUA specifies an instance of the object, in ZE, and not just the ODF.


Get your own effect and Object, place this in your LUA under ScriptPostLoad, and you'd be done...but the problem is, the game isn't loading your effect. Check, and you'll see it is munged, but still not in game. For some reason, you have to create an object - odf and msh - that references your effect. It has to have hard points. Sneak it somewhere in your map. The effects will then be loaded.
Heres an example of 'REQ Object'
EffectReq.odf
Hidden/Spoiler:
[code]
[GameObjectClass]

ClassLabel = "prop"
GeometryName = "dag1_prop_grandtree_4.msh"


[Properties]

GeometryName = "dag1_prop_grandtree_4"

AttachToHardPoint = "hp_branch"

AttachOdf = "dag1_prop_leafpatch"

AttachEffect = "blue_light"

AttachToHardPoint = "hp_dryice1"

AttachEffect = "yellow_light"

AttachToHardPoint = "hp_fireflies1"

AttachEffect = "fireflies"

AttachToHardPoint = "hp_fireflies2"

AttachEffect = "fireflies"

AttachToHardPoint = "hp_fireflies3"

FoleyFXGroup = "wood_foley"
[/code]
O.K. Now you're effect is in game and attached to the object. Just one problem....its in the totally wrong place. Now, their are two ways to fix this, editing the FX's offests using particle editor, and using the Effect Path method.

1. Particle Editor:
Follow the Particle Editor Tutorial, and then open your effect. Expand each section of the effect, and repeat these steps: Click on 'Spawner'. Alter the series of boxes under 'Offset' to your preference. To stop the effect from 'wobbling' keep the min and max values the same.
Particle Editor Reference ScreenShot
Hidden/Spoiler:
Image
What are your preferences? Just mess around in here until effect is where you want it in game.

2. The effect Path Method.
Place a path, with one node, in ZE where you want the Effect to originate. Then, use this code instead of the above.

Code: Select all

FecLoc = GetPathPoint("Effect_Path", "node 0")
AttachEffectToMatrix(CreateEffect("Effect_Name"), FecLoc)
Note: FecLoc is just a chosen variable name, you could call them both "CheeseCube", as long as they were the same and not already being used.
Note2: Unfortunately, in trying to loop through an entire path, adding an effect to each node, I noticed that it looks like the "node_#" info is sort of...ignored.

And that concludes this tutorial. I hope this is useful to someone and hasn't already been mentioned (or tut-ified at least) on GT.

Feed back welcome, be specific.
t551
General
General
Posts: 791
Joined: Sat Jul 16, 2005 3:23 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: HowTo: Attach an Effect to an Object W/O Hardpoints

Post by t551 »

Can't you just use an .odf to attach the effect to the DummyRoot, and then offset it?

Although with this method, you could turn the effect on and off, and move it around, so that's cool.
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: HowTo: Attach an Effect to an Object W/O Hardpoints

Post by Ace_Azzameen_5 »

Yes, without using separate objects, objects which are annoyingly limited in number.
User avatar
trainmaster611
Sith Lord
Sith Lord
Posts: 1779
Joined: Thu Aug 24, 2006 5:22 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set
Location: Building a railway to Coruscant
Contact:

Re: HowTo: Attach an Effect to an Object W/O Hardpoints

Post by trainmaster611 »

Very interesting discovery, I might have to use it.
wazmol
High General
High General
Posts: 892
Joined: Sat Sep 02, 2006 6:47 pm
Projects :: Thinking...
Games I'm Playing :: Black Ops
Location: London
Contact:

Re: HowTo: Attach an Effect to an Object W/O Hardpoints

Post by wazmol »

thanks ace for the tutorail!

-Wmol
User avatar
Frisbeetarian
Jedi
Jedi
Posts: 1233
Joined: Wed Sep 12, 2007 3:13 pm

Re: HowTo: Attach an Effect to an Object W/O Hardpoints

Post by Frisbeetarian »

In both instances, couldn't you combine the lines of code into one and skip using "fecloc" altogehter?
Ace_Azzameen_5
Jedi
Jedi
Posts: 1119
Joined: Sat Apr 23, 2005 8:52 pm
Projects :: No Mod project currently.
Games I'm Playing :: I have not listed any games yet
xbox live or psn: No gamertag set

Re: HowTo: Attach an Effect to an Object W/O Hardpoints

Post by Ace_Azzameen_5 »

That didn't work for me, but I haven't tried it now that I got the system working completely. It may have been another bug.
So

Code: Select all

AttachEffectToMatrix(CreateEffect("Effect_Name"), GetPathPoint("Effect_Path", "node 0"))
--or
AttachEffectToMatrix(CreateEffect("Effect_Name"), GetEntityMatrix("LOLanOBJECT"))
User avatar
GAB
1st Lieutenant
1st Lieutenant
Posts: 431
Joined: Sun Jul 03, 2011 8:56 pm
Location: Somewhere around the world
Contact:

Re: HowTo: Attach an Effect to an Object W/O Hardpoints (FAQ

Post by GAB »

Bumping to contribuite with something...
Ace_Azzameen_5 wrote:Note2: Unfortunately, in trying to loop through an entire path, adding an effect to each node, I noticed that it looks like the "node_#" info is sort of...ignored.
It is actually possible to loop through an entire path and add an effect to each node. If you use the following command,

Code: Select all

AttachEffectToMatrix(CreateEffect("effect_name"),GetPathPoint("path_name", X))
where the X in the end of the command is the number of the node, you can attach an effect to any node within a path.

So, for example, you have a path with 5 nodes, going from Node 0 to Node 4, and want to attach an effect to Node 1, Node 2 and Node 4 (the 2nd, 3rd and 5th nodes respectively) you'd have:

Code: Select all

AttachEffectToMatrix(CreateEffect("effect_name"),GetPathPoint("path_name", 1)) 
AttachEffectToMatrix(CreateEffect("effect_name"),GetPathPoint("path_name", 2))
AttachEffectToMatrix(CreateEffect("effect_name"),GetPathPoint("path_name", 4))
And remember, the first node in a path is always named Node 0 (not Node 1).
Post Reply