AttachEffectToObject [Solved]

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
MetalcoreRancor
Brigadier General
Brigadier General
Posts: 628
Joined: Thu Jun 07, 2007 11:13 am
Projects :: No Mod project currently.
Games I'm Playing :: swbf origin
xbox live or psn: No gamertag set

AttachEffectToObject [Solved]

Post by MetalcoreRancor »

I looked using the swbf2 script finder, and used search on GT, only to find nothing helpful on this.

I need to know how to use this lua function so I can attach an effect to tomb stones to visually mark progress of waves in my zombie mod. So I would insert AttachEffectToObject(objectname, effectname)? into each wave to mark them? Any help would be appreciated.
Last edited by MetalcoreRancor on Fri Jan 22, 2010 5:59 pm, edited 1 time in total.
genaral_mitch
Jedi
Jedi
Posts: 1056
Joined: Fri Aug 14, 2009 12:32 am

Re: AttachEffectToObject

Post by genaral_mitch »

Can't you just have a changing msh that changes to one with more marks according to the waves that have past?
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: AttachEffectToObject

Post by Ace_Azzameen_5 »

Hmmm, that command might also need a hard point on the msh...but AttachEffectToMatrix works well"

Code: Select all

AttachEffectToMatrix(CreateEffect("fel_sfx_springmist"), GetEntityMatrix("Tombstone"))
You will have to modify the effect's position in the effects editor, or shift the matrix's location (geometrically 'translate' it) on the matrix as such:

Code: Select all

MatrixData = GetEntityMatrix("TombStone") --Grab and store Tombstones location (matrix) in "MatrixData"
MatrixData = CreateMatrix("0,0,0,0,0,0,2, MatrixData")  -- Reset Matrix data to be old Matrix Data but 2 world units higher.
as shown in this thread:
2D Level - Turning Fixed, Camera Placement Still An Issue
MetalcoreRancor
Brigadier General
Brigadier General
Posts: 628
Joined: Thu Jun 07, 2007 11:13 am
Projects :: No Mod project currently.
Games I'm Playing :: swbf origin
xbox live or psn: No gamertag set

Re: AttachEffectToObject

Post by MetalcoreRancor »

So I place
AttachEffectToMatrix(CreateEffect("com_sfx_wavecomplete"), GetEntityMatrix("neu_bldg_luatomb"))
MatrixData = GetEntityMatrix("neu_bldg_luatomb")
MatrixData = CreateMatrix("0,0,0,0,0,0,2, MatrixData")

In each wave, replacing luatomb with the various object numbers, and it should work each time a wave starts?

-Edit-

I'd really appreciate a response, because this coding did not work.
Last edited by MetalcoreRancor on Thu Jan 21, 2010 5:32 pm, edited 1 time in total.
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: AttachEffectToObject

Post by Ace_Azzameen_5 »

Something like that, though I'm not familiar with your code, and if you want to use the second to lines instead of editing the effect, then you need to change the first line to have "MatrixData" instead of "GetEntity Matrix", employed in this order:

MatrixData = GetEntityMatrix("neu_bldg_luatomb")
MatrixData = CreateMatrix("0, 0, 0, 0, 0, 0, 2, MatrixData")
AttachEffectToMatrix(CreateEffect("com_sfx_wavecomplete"), MatrixData)

Oh, and you'll need to toy with the numbers in Create Matrix. Start with smaller values I think, like 0.5...
MetalcoreRancor
Brigadier General
Brigadier General
Posts: 628
Joined: Thu Jun 07, 2007 11:13 am
Projects :: No Mod project currently.
Games I'm Playing :: swbf origin
xbox live or psn: No gamertag set

Re: AttachEffectToObject

Post by MetalcoreRancor »

Thanks for the quick response. Ill try to incorporate that, but what do the numbers mean? Is it coordinates or the number of times used? I'm going to be copying this set of lines 30 times, 1 for each wave.
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: AttachEffectToObject

Post by Ace_Azzameen_5 »

I dun linked that thing up - thread linked in my first post, but its basically Create(Rotate X*, Rotate X, Rotate Y, Rotate Z, Move X, Move Y, Move Z, StartingPointMatrix) from what I understand.
MetalcoreRancor
Brigadier General
Brigadier General
Posts: 628
Joined: Thu Jun 07, 2007 11:13 am
Projects :: No Mod project currently.
Games I'm Playing :: swbf origin
xbox live or psn: No gamertag set

Re: AttachEffectToObject

Post by MetalcoreRancor »

It still did not work, so Ill post a reference sample of one wave.

Code: Select all

  
    wtime0 = OnTimerElapse(                
    	function(timer)
    		StartTimer(wavetimer0)
    		ShowTimer(nil)
    		ShowTimer(wavetimer0)
    		ShowMessageText("level.dea1.zombie") 
zombiehorde = math.random(3)
			if zombiehorde == 1 then    
    		Ambush("CP5Spawn", 2, 6)
    		Ambush("CP5Spawn", 2, 6)
    		Ambush("CP5Spawn", 2, 6)
    		Ambush("CP5Spawn", 2, 6)
    		Ambush("CP5Spawn", 2, 6)
    		Ambush("CP5Spawn", 2, 6)
    		Ambush("CP5Spawn", 2, 6) 
    		Ambush("CP5Spawn", 2, 6)
    		Ambush("CP5Spawn", 2, 6)
    		Ambush("CP5Spawn", 2, 6)
    		Ambush("CP5Spawn", 2, 6)
    		Ambush("CP5Spawn", 2, 6)
    		Ambush("CP5Spawn", 2, 6)
			 elseif zombiehorde == 2 then
    		Ambush("CP1Spawn", 2, 6)
    		Ambush("CP1Spawn", 2, 6)
    		Ambush("CP1Spawn", 2, 6)
    		Ambush("CP1Spawn", 2, 6)
    		Ambush("CP1Spawn", 2, 6)
    		Ambush("CP1Spawn", 2, 6)
    		Ambush("CP1Spawn", 2, 6) 
    		Ambush("CP1Spawn", 2, 6)
    		Ambush("CP1Spawn", 2, 6)
    		Ambush("CP1Spawn", 2, 6)
    		Ambush("CP1Spawn", 2, 6)
    		Ambush("CP1Spawn", 2, 6)
    		Ambush("CP1Spawn", 2, 6)
			 elseif zombiehorde == 3 then
    		Ambush("CP4Spawn", 2, 6)
    		Ambush("CP4Spawn", 2, 6)
    		Ambush("CP4Spawn", 2, 6)
    		Ambush("CP4Spawn", 2, 6)
    		Ambush("CP4Spawn", 2, 6)
    		Ambush("CP4Spawn", 2, 6)
    		Ambush("CP4Spawn", 2, 6) 
    		Ambush("CP4Spawn", 2, 6)
    		Ambush("CP4Spawn", 2, 6)
    		Ambush("CP4Spawn", 2, 6)
    		Ambush("CP4Spawn", 2, 6)
    		Ambush("CP4Spawn", 2, 6)
    		Ambush("CP4Spawn", 2, 6)
           end	--neu_bldg_luatomb
   MatrixData = GetEntityMatrix("neu_bldg_luatomb")
    MatrixData = CreateMatrix("0, 0, 0, 0, 0, 0, 1.0, MatrixData")
      AttachEffectToMatrix(CreateEffect("com_sfx_wavecomplete"), MatrixData)

			DestroyTimer(timer)	
            end,
        wavetimer
        )
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: AttachEffectToObject

Post by Ace_Azzameen_5 »

I should admit now that I'm rusty with LUA and SWBF2 in general but:
First of all, check BF2log for references to the effect (maybe its not being found...
***I just remembered, it seems that an effect must be loaded up using and odf with a hitpoint, like some of the foggy dagobah trees etc. This must be done or else they aren't loaded for use. Might be a better way, but on my map I just placed a hidden object - a tree with a bunch of light effects on it as well as a giant plume of starship exhaust blasting it out from it lmao) Failing that ***
....make sure that its not just being placed below the map or something, and add a
print("Effect code ran")
command beside the effects stuff, so that the log file will print it out if the code in the area of the lua is even running.

But I'm pretty sure its that the fx file needs to be attached to an object via its odf file, then the effect can be added to random tombstones.

BTW, I've never had success removing or moving an effect. It might be able to be done but IDK.
MetalcoreRancor
Brigadier General
Brigadier General
Posts: 628
Joined: Thu Jun 07, 2007 11:13 am
Projects :: No Mod project currently.
Games I'm Playing :: swbf origin
xbox live or psn: No gamertag set

Re: AttachEffectToObject

Post by MetalcoreRancor »

Sure enough

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(635)
Entity "neu_bldg_luatomb" not found

Now.. I wonder how to work this >.<

-edit-

After talking to Fiodis, he showed me the FAQ topic you made on this ages ago, and Ive encorporated a similiar system, but I still have:

Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(635)
Entity "neu_bldg_luatomb" not found


and each wave has:


Message Severity: 2
.\Source\LuaCallbacks_Mission.cpp(4519)
Effect class "com_sfx_wavecomplete" not found

-edit-

works now. Luatomb was supposed to be luatomb1.
Post Reply