Hard Light Productions Forums

Modding, Mission Design, and Coding => The Modding Workshop => Topic started by: Talon 1024 on May 11, 2008, 04:01:31 pm

Title: Particle Emitters?
Post by: Talon 1024 on May 11, 2008, 04:01:31 pm
Well, I'm working on my own campaign for Wing Commander Saga, and I want to add a new ship with smoke coming out of it like a smokestack, since it is a factory ship. :)

Is there any way you can force particles to be emitted from a specific point on the ship without shooting at it?
Title: Re: Particle Emitters?
Post by: Solatar on May 11, 2008, 04:13:46 pm
I know the SCP engine is capable of having particles emit from engines. Maybe you could fool around with using a glowpoint/whatever they used in BSG:BTRL/.ani file and seeing what you could come up with?

Title: Re: Particle Emitters?
Post by: Talon 1024 on May 11, 2008, 04:17:32 pm
I'm not really sure if I want an engine flame coming out of a smokestack... :P

I was thinking of using glowpoints, but...  Are they capable of emitting particles?
Title: Re: Particle Emitters?
Post by: Nuke on May 11, 2008, 04:25:52 pm
could probibly script it.
Title: Re: Particle Emitters?
Post by: Warp Shadow on May 11, 2008, 04:39:57 pm
You could just make a separate engine set and have the glowpoint be an incredibly small radius (or 0 radius) or even make it like a secondary or tertiary thruster and have the corresponding bitmap be invisible.
Title: Re: Particle Emitters?
Post by: Nuke on May 12, 2008, 09:59:58 pm
you know what, the glowpoint chunk has a numeric type field i think. there are really only two possibilities to set it to, 0 and 1 which is sprite and beam, respectively. what about a type 2, which could be set to be a particle spewer. just an idea for the engine.
Title: Re: Particle Emitters?
Post by: Talon 1024 on May 13, 2008, 03:29:39 pm
Excellent idea. :pimp:
Title: Re: Particle Emitters?
Post by: Colonol Dekker on May 13, 2008, 03:32:14 pm
Post sreenies when done :nod:........
Title: Re: Particle Emitters?
Post by: Nuke on May 13, 2008, 04:02:56 pm
im still working on pspew types, which has about a snowballs chance in hell of getting into the engine
Title: Re: Particle Emitters?
Post by: Galemp on November 20, 2015, 10:29:08 am
:bump:

Anyone have ideas on this? Particle emitters on ships have some interesting possibilities.
Title: Re: Particle Emitters?
Post by: DahBlount on November 20, 2015, 11:11:44 am
$PSpew: is a thing. That's about as good as it gets at this point in time. There was also a particle script laying around somewhere but I haven't been able to find it in a few months.
Title: Re: Particle Emitters?
Post by: zookeeper on November 20, 2015, 01:26:00 pm
As said previously, it can be scripted. Shouldn't be anything particularly tricky about it.
Title: Re: Particle Emitters?
Post by: m!m on November 20, 2015, 01:56:22 pm
I have been working on implementing generic particle effects for some time now and adding particle emitters on a ship is something it can do. It's working pretty well and should be ready to be tested soonTM. Until then a script based solution is probably the best you can do (but don't use my particle script, it's horribly inefficient).
Title: Re: Particle Emitters?
Post by: Galemp on November 20, 2015, 05:56:34 pm
Guess I better head to the "introduction to scripting" page on the Wiki, seeing as I've never done anything like that before...
Title: Re: Particle Emitters?
Post by: zookeeper on November 20, 2015, 06:18:38 pm
Well it would be simple enough that someone (such as myself) could probably easily write one for you if you specified exactly what it should do.
Title: Re: Particle Emitters?
Post by: Galemp on November 23, 2015, 03:42:41 pm
OK, here's a test case for you then: let's say we wanted to make a ship act like the Reavers (http://firefly.wikia.com/wiki/Reaver) from Firefly.

Say there's a modified Fenris that's dangerously overpowered their reactor to fire BGreen from its main turret, maybe the NTF crew has committed themselves to a slow death from radiation poisoning rather than a dishonorable death at the hands of the Vasudans.

It's simple enough to swap the weapon in FRED, maybe a texture-replace too. But if we really wanted to sell this, let's add some billowing smoke venting from the exposed sides of the ship. Something similar to the MediaVPs pspew from the exit wound of a beam impact. Is this doable? If so, would it be built into the model, the table, or the mission?
Title: Re: Particle Emitters?
Post by: zookeeper on November 23, 2015, 04:28:02 pm
OK, here's a test case for you then: let's say we wanted to make a ship act like the Reavers (http://firefly.wikia.com/wiki/Reaver) from Firefly.

Say there's a modified Fenris that's dangerously overpowered their reactor to fire BGreen from its main turret, maybe the NTF crew has committed themselves to a slow death from radiation poisoning rather than a dishonorable death at the hands of the Vasudans.

It's simple enough to swap the weapon in FRED, maybe a texture-replace too. But if we really wanted to sell this, let's add some billowing smoke venting from the exposed sides of the ship. Something similar to the MediaVPs pspew from the exit wound of a beam impact. Is this doable? If so, would it be built into the model, the table, or the mission?

Okay... well, basically I'd write that so that it'd be built into a script, which would run during that particular mission and keep picking random locations on the hull of that particular ship (or fixed locations, if that'd be better) to spew streams of particles from every couple of seconds in an $On Frame hook. However, it wouldn't be much harder to generalize it so that any mission could just use the script-eval SEXP to call a Lua function which would trigger the effect on any ship, if needed.

I can try writing at least a prototype of that tomorrow, shouldn't be anything awfully tricky about it.
Title: Re: Particle Emitters?
Post by: Galemp on November 23, 2015, 06:27:25 pm
Let's say there's fixed locations: those two big, red bullseyes centered on each side of the hull.

Suppose NTC Fenris#reaver is a ship class that's used enough in the campaign to warrant its own table entry. Does this mean all we need is to include the script with the modpack, and then use the script-eval sexp in each mission? Forgive me, I'm totally unfamiliar with scripting.
Title: Re: Particle Emitters?
Post by: zookeeper on November 24, 2015, 05:29:50 am
All you need to do is include the script in a -sct.tbm. The script-eval SEXP would only need to be used if the effect needed to be triggerable per-ship, rather than automatically affecting all occurrences of the ship class.

Anyway, here's the simplest kind of version of it:

Code: [Select]
#Conditional Hooks

$Application: FS2_Open

$On Game Init: [

    last_particle_time = 0
    next_particle_time = -1

]

$State: GS_STATE_GAME_PLAY

$On Frame: [

    local currenttime = mn.getMissionTime()

    if currenttime > 0.1 then
        local num = #mn.Ships

        for i=1,num do
            local ship = mn.Ships[i]

            if ship.Class.Name == "GTC Fenris" then
                if currenttime > next_particle_time then
                    local ppos, pdir, pvel, plife, prad

                    ppos = ship.Position + ship.Orientation:unrotateVector(ba.createVector(35, 0, 0))
                    pdir = ba.createVector(10.0 + math.random() * 5.0, math.random() * 3.0 - 1.5, math.random() * 3.0 - 1.5)
                    pvel = ship.Physics.Velocity + ship.Orientation:unrotateVector(pdir)
                    plife = 1.0 + math.random() * 2.0
                    prad = 5.0 + math.random() * 5.0
                    ts.createParticle(ppos, pvel, plife, prad, PARTICLE_SMOKE)
                    -- Use PARTICLE_SMOKE, PARTICLE_SMOKE2 or PARTICLE_FIRE

                    ppos = ship.Position + ship.Orientation:unrotateVector(ba.createVector(-35, 0, 0))
                    pdir = ba.createVector(-10.0 - math.random() * 5.0, math.random() * 3.0 - 1.5, math.random() * 3.0 - 1.5)
                    pvel = ship.Physics.Velocity + ship.Orientation:unrotateVector(pdir)
                    plife = 1.0 + math.random() * 2.0
                    prad = 5.0 + math.random() * 5.0
                    ts.createParticle(ppos, pvel, plife, prad, PARTICLE_SMOKE2)
                    -- Use PARTICLE_SMOKE, PARTICLE_SMOKE2 or PARTICLE_FIRE

                    last_particle_time = currenttime
                    next_particle_time = currenttime + 0.1 + math.random() * 0.1
                end
            end
        end
    else
        next_particle_time = -1
    end
]

#End

Automatically spews smoke/fire plumes from both sides of all Fenrises (so change the ship class name reference). It wouldn't be hard to make it fancier and more customizable and more optimized, but as said, it's a prototype. The particle direction/radius/velocity/lifetime randomizations should be somewhat self-explanatory and easy to tweak.

If that's all you need for your particular usecase and it doesn't have any visible drawbacks then great; if you need more customization (custom smoke bitmap, or for it to work on different ship classes with different emitter locations, etc) then I could easily add those.
Title: Re: Particle Emitters?
Post by: Galemp on November 24, 2015, 10:28:44 am
Very interesting. I'll have to try this later and see what I can learn from it! I do have a particular use in mind but it's still in the concept art stages... perhaps I'll follow up with you once there's a POF we can play with. :)