FAForever Forums
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Login

    Effects / Emiters cleanup question

    Scheduled Pinned Locked Moved Modding & Tools
    14 Posts 3 Posters 783 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • R
      Resin_Smoker
      last edited by Resin_Smoker

      Been going around in circles with emitters recently and unable to come to a definitive answer. Case in point, I've a unit that creates an attached emitter like so. Saving it to a table "self.ThrasherFXBag" for later use...

      table.insert(self.ThrasherFXBag, CreateAttachedEmitter(self, 'exhaust', self:GetArmy(), '/effects/emitters/missile_smoke_exhaust_02_emit.bp'):ScaleEmitter(0.5))
      
      self.Trash:Add(self.ThrasherFXBag)
      

      Later I want to destroy the emitter and call this function...

      FXCleanUp = function(self, whocalled)
      	local myDebug = true	
      	if myDebug or mainDebug then WARN('UEA0206 FX Clean Up: ', whocalled) end
      
      	--Destroy Afterburner FX
      	if self.ThrasherFXBag and table.getn(self.ThrasherFXBag) > 0 then
      		if myDebug or mainDebug then WARN('self.ThrasherFXBag > 0 ') end
      		for k, v in self.ThrasherFXBag do
      			if myDebug or mainDebug then WARN('Destroying v') end
      			v:Destroy()
      		end
      	end
      	if myDebug or mainDebug then WARN('self.ThrasherFXBag size after destroy: ', table.getn(self.ThrasherFXBag)) end		
      end,
      

      My log is showing...

      WARNING: UEA0206 FX Clean Up: 	Afterburner 1
      WARNING: self.ThrasherFXBag > 0 
      WARNING: Destroying v
      WARNING: self.ThrasherFXBag size after destroy: 	1
      

      So based on the log someone could assume that nothing is being destroyed?

      or

      Is the emitter being destroyed, but the table is not cleared after each instance is removed?

      Side note: I've also notice that not all emitters are capable of be scaled. No idea why this is or what criteria determine this. By chance anyone know?

      -Resin

      Kykhu Oss https://youtu.be/JUgyGTgeZb8
      Unit Thrower https://youtu.be/iV8YBXVxxeI
      Beam Tentacle https://youtu.be/le5SNwHvC4c
      Blackhole https://www.youtube.com/watch?v=D9NGQC5rr0c
      Resurection https://www.youtube.com/watch?v=WdbIQ4vHkMs

      JipJ 1 Reply Last reply Reply Quote 0
      • speed2S
        speed2
        last edited by

        Calling Destroy method on it will destroy it, but it wont remove it from a table you've added it to. Its gonna be there, just destroyed.

        R 1 Reply Last reply Reply Quote 0
        • R
          Resin_Smoker @speed2
          last edited by

          @speed2 Awesome, thank you !

          Kykhu Oss https://youtu.be/JUgyGTgeZb8
          Unit Thrower https://youtu.be/iV8YBXVxxeI
          Beam Tentacle https://youtu.be/le5SNwHvC4c
          Blackhole https://www.youtube.com/watch?v=D9NGQC5rr0c
          Resurection https://www.youtube.com/watch?v=WdbIQ4vHkMs

          1 Reply Last reply Reply Quote 0
          • JipJ
            Jip
            last edited by

            If ThrasherFXBag is of type TrashBag then the reference is, eventually, also removed from the table by the garbage collector.

            A work of art is never finished, merely abandoned

            1 Reply Last reply Reply Quote 0
            • JipJ
              Jip @Resin_Smoker
              last edited by

              @resin_smoker said in Effects / Emiters cleanup question:

              Side note: I've also notice that not all emitters are capable of be scaled. No idea why this is or what criteria determine this. By chance anyone know?

              All emitters can be scaled, do you have a concrete snippet that can not scale according to you?

              A work of art is never finished, merely abandoned

              R 1 Reply Last reply Reply Quote 0
              • R
                Resin_Smoker
                last edited by Resin_Smoker

                Was attempting to scale simple beam emitter. I believe it was with CreateAttachedBeamEmitter(). Meanwhile, I could alter the beamFX lifetime and a few other things, just couldn't not use SetScale().

                Edit: Will post a code snippet next time I'm using the computer.

                Kykhu Oss https://youtu.be/JUgyGTgeZb8
                Unit Thrower https://youtu.be/iV8YBXVxxeI
                Beam Tentacle https://youtu.be/le5SNwHvC4c
                Blackhole https://www.youtube.com/watch?v=D9NGQC5rr0c
                Resurection https://www.youtube.com/watch?v=WdbIQ4vHkMs

                1 Reply Last reply Reply Quote 0
                • R
                  Resin_Smoker @Jip
                  last edited by Resin_Smoker

                  uea0206_Script.zip @jip

                  table.insert(self.ThrasherFXBag, CreateBeamEmitterOnEntity( self, 'afterburner', self:GetArmy(), '/mods/4DFAF/effects/emitters/uea0202_afterburner_fire_beam_01/uea0202_afterburner_fire_beam_01_emit.bp'):SetEmitterParam('Lifetime', burnTime))
                  

                  Above is what I'm currently using, which works, minus being able to re-scale it. However, please note that I'm currently using a custom file so i can manually change the scale.

                  Using :SetScale(Value) doesn't appear to change anything. Neither does :SetEmitterParam('Thickness', value) or :SetEmitterParam('length', value), which "Thickness" and "Length" are BeamBluePrint values that can be seen via a repr() of the emitter file.

                  (Effect file shown below, length and thicknesses are half the original files values)

                  -----------------------------------------------------------------------------
                  --	File		: /4DFAF/effects/emitters/uea0202_afterburner_fire_beam_01/uea0202_afterburner_fire_beam_01_emit.bp
                  --
                  --	Author(s)	: EbolaSoup, Resin Smoker, Optimus Prime, Vissroid
                  --
                  --	Summary		: Special FX for use with Thrasher multirole fighter
                  --
                  --	Note		: This file is needed as the default GPG beam effect can not be rescaled via :ScaleEmitter()	
                  --
                  --	Copyright © 2024 4DFAF, All rights reserved.
                  -----------------------------------------------------------------------------
                  
                  BeamBlueprint {
                  	Lifetime = 3.0,
                  	TextureName = '/textures/particles/missile_exhaust_fire_01.dds',
                  	Thickness = 0.05,
                  	StartColor = {x=1,y=1,z=1,w=0.2}, -- R,G,B,A
                  	EndColor = {x=0.0,y=0.0,z=0,w=0}, -- R,G,B,A
                  	Length = -1.4,
                  	UShift = 0.0,
                  	VShift = -0.65,
                  }
                  

                  If your iterested or need to see the units complete .lua for context, Ive included it below. The script does run as intended, which is pretty good for a guy who hasn't scripted in 10 years.

                  uea0206_Script.zip

                  Kykhu Oss https://youtu.be/JUgyGTgeZb8
                  Unit Thrower https://youtu.be/iV8YBXVxxeI
                  Beam Tentacle https://youtu.be/le5SNwHvC4c
                  Blackhole https://www.youtube.com/watch?v=D9NGQC5rr0c
                  Resurection https://www.youtube.com/watch?v=WdbIQ4vHkMs

                  1 Reply Last reply Reply Quote 0
                  • JipJ
                    Jip
                    last edited by

                    Ah, I understand now. Not all emitters are alike, in Supreme Commander we have:

                    • (1) Actual emitters
                    • (2) Trails
                    • (3) Beams

                    You can scale (1) just fine. But (2) and (3) have a similar class, but not everything works on that class. It never did, that's not something we changed. For more information, see also:

                    • https://github.com/FAForever/fa/blob/develop/engine/Sim/IEffect.lua

                    And specifically SetBeamParam for beams. I'm not sure how to adjust trails in Lua.

                    A work of art is never finished, merely abandoned

                    R 1 Reply Last reply Reply Quote 0
                    • R
                      Resin_Smoker @Jip
                      last edited by Resin_Smoker

                      @jip ahh that Github helps clarity things... What I noticed right off is that I used "Length" where the Github has "LENGTH" with all capitals. Will attempt this later and post back the results.

                      Which, looking (again) at the emitter blueprint, it doesn't say specifically which type of emitter it is. (It's name does but not within the BP) Thus, its likely being defaulted by the effects Lua some where down the pipe. Figuring out which type is it, will help provide a solution or a possible path to one.

                      Side note: Would be helpful to be able to update the Lua Wiki to reflect this. As is the reference has a few holes.

                      Kykhu Oss https://youtu.be/JUgyGTgeZb8
                      Unit Thrower https://youtu.be/iV8YBXVxxeI
                      Beam Tentacle https://youtu.be/le5SNwHvC4c
                      Blackhole https://www.youtube.com/watch?v=D9NGQC5rr0c
                      Resurection https://www.youtube.com/watch?v=WdbIQ4vHkMs

                      JipJ 1 Reply Last reply Reply Quote 0
                      • R
                        Resin_Smoker
                        last edited by

                        I'm wondering is changing from "CreateBeamEmitterOnEntity()" to "CreateEmitterOnEntity()" would work using the same file. (Or is it CreateAttachedEmitter ? )

                        Kykhu Oss https://youtu.be/JUgyGTgeZb8
                        Unit Thrower https://youtu.be/iV8YBXVxxeI
                        Beam Tentacle https://youtu.be/le5SNwHvC4c
                        Blackhole https://www.youtube.com/watch?v=D9NGQC5rr0c
                        Resurection https://www.youtube.com/watch?v=WdbIQ4vHkMs

                        1 Reply Last reply Reply Quote 0
                        • JipJ
                          Jip @Resin_Smoker
                          last edited by

                          @resin_smoker said in Effects / Emiters cleanup question:

                          Side note: Would be helpful to be able to update the Lua Wiki to reflect this. As is the reference has a few holes.

                          What Lua Wiki?

                          It's best to use the references and documentation in the repository directly, the annotations have been in the works for the past two to three years and is still being improved occasionally 🙂

                          A work of art is never finished, merely abandoned

                          R 1 Reply Last reply Reply Quote 0
                          • R
                            Resin_Smoker @Jip
                            last edited by

                            @jip

                            https://wiki.faforever.com/en/Development/Modding/LUADOC

                            https://wiki.faforever.com/en/Development/Modding/LUAGLOBALS

                            Kykhu Oss https://youtu.be/JUgyGTgeZb8
                            Unit Thrower https://youtu.be/iV8YBXVxxeI
                            Beam Tentacle https://youtu.be/le5SNwHvC4c
                            Blackhole https://www.youtube.com/watch?v=D9NGQC5rr0c
                            Resurection https://www.youtube.com/watch?v=WdbIQ4vHkMs

                            1 Reply Last reply Reply Quote 0
                            • R
                              Resin_Smoker
                              last edited by

                              "LENGTH" results in... "WARNING: Error running lua script: Invalid Effect Parameter LENGTH"

                              "Length" results in... "WARNING: Error running lua script: Invalid Effect Parameter Length"

                              Using "CreateAttachedEmitter" with the Beam blueprint results in... "WARNING: Failed to create emitter as you passed in an invalid blueprint name /effects/emitters/missile_exhaust_fire_beam_01_emit.bp."

                              Kinda figured that would happen, but was worth trying it just to know for sure.

                              -Resin

                              Kykhu Oss https://youtu.be/JUgyGTgeZb8
                              Unit Thrower https://youtu.be/iV8YBXVxxeI
                              Beam Tentacle https://youtu.be/le5SNwHvC4c
                              Blackhole https://www.youtube.com/watch?v=D9NGQC5rr0c
                              Resurection https://www.youtube.com/watch?v=WdbIQ4vHkMs

                              1 Reply Last reply Reply Quote 1
                              • JipJ
                                Jip
                                last edited by

                                @Resin_Smoker better to review this folder:

                                • https://github.com/FAForever/fa/blob/develop/engine

                                It has all the information on the wiki and more 🙂 . We should probably link the Wiki to that

                                A work of art is never finished, merely abandoned

                                1 Reply Last reply Reply Quote 0
                                • First post
                                  Last post