ID:802467
 
Resolved
Client-side particle effects have been added! The particle system allows for a massive amount of flexibility with special effects (which is likely to be expanded in future builds). These effects are purely visual, run on the client, and should not impact server performance.
Applies to:DM Language
Status: Resolved (514.1543)

This issue has been resolved.
I've recently witnessed several projects move away from BYOND in favor of other languages and engines. They all chose not to use BYOND for various reasons, but one big reason they all shared was BYOND's lack of particle effects. Big, juicy particle effects are a huge factor in a game's slickness and addictiveness, I think it's something worth giving some thought.

Particle effects can certainly be user-made, but they're always heavily dependent on network conditions and use up valuable bandwidth. If you wanted to do something like show damage text you'll have to create some numbers then update their pixel offset every tick. You would have to do the same with smoke for example and raise its pixel_y every tick while maybe swaying it to the left and right. The thing is, if there are any connection hitches the particles will jump several pixels at a time, ruining the whole effect. In a worst case scenario with a choppy connection you would only see a few "snapshots" out of the entire animation.

What I'd like to see is BYOND add some sort of particle datum to fill this role. It wouldn't have to use true client-side processing, it would just need to offload some of the processing from the server to the client. It would need to take predefined variables and animate particles in a predictable fashion. I have a good idea of how I'd like some of the effects to work, but I'm just one developer so please chime in if you think of something better.

The way I see it, there are three main variables a particle needs. Angle, Speed, and Duration. After being created the particle needs to know which direction to travel in, how fast, and for how long. With these variables you have your basic "line" particle animation. Expanding on that, there would be a Tilt variable which determines how much Angle should be adjusted each tick. With this extra variable you could change a line into a circular shape. From here it gets a little more complicated depending on how advanced the particles should be. If you could stack effects on the same particle you could do something like take a circular particle animation then add a line animation to it, creating a spiral animation. If you took a circle animation then flipped it every 180 degrees you would get an wave animation.

I think the key here is robustness, a few very simple rules which can be combined in different ways would cover most use cases. The particles should be visual-only, they should be super cheap and efficient to use. They wont replace standard projectile effects which have collision properties, but they'll be able to act as the bullet shell flying out of the weapon, the smoke from the barrel, the vapor trail left by the bullet, the blood splatter from the victim, and finally the damage numbers flying over the victim's head.
I like the suggestion, but I am afraid that this would open a huge can of worms because the limited effects are going to beget tremendous feature creep. I'm not saying that is reason to avoid exploring such a thing (it is very similar to the excellent idea of having transformation variables associated with atoms). But I would want to see if there is a more general solution first.

I don't know if such a thing exists, but the ideal thing here would be using an existing particle engine on top of the client. It would have to be an interpreted language, of course, and I'm not sure how it would handle icons. But in theory, if one could just give a pixel "start" location and a set of commands to pass to the engine, BYOND could have more powerful effects without having to reinvent the wheel.

Is there such a thing?
There's Spark which seems to be an open source C++ particle engine.

It's capable of some really nice effects.
In response to SuperAntx
I believe Tom is looking for an implementation that works with an interpreted language, not something compiled like C++.
So LUA, for instance.
In response to Murrawhip
That's just something I'm too out of touch with. There are a bunch of free/open source particle engines but I don't know of any using interpreted languages.
I'd love to see the ability to do this with BYOND but I'd hate to see it implemented this way. It'd be too limited and it'd almost be easier to create a more solid, useful feature.

BYOND desparately needs variables to control the rotation, opacity, color, and size of objects (even if those vars can only be manipulated by the server). This alone puts you a good way towards being able to create these effects. The rest of it is being able to execute code on the client. It seems like it'd be difficult but it's actually very straightforward. Unfortunately, it'd require modifications to the DM language/compiler that I don't think the BYOND staff can make.

Dream Seeker can already execute compiled DM code, you just need a way to pack procs that can be executed on the client in the .rsc. Changes made client-side would only exist on the client (they wouldn't be propagated back to the server), they'd only affect display (changing pixel offsets, rotation, opacity, etc.), they'd take priority over changes made by the server, and they'd have a limited scope (if the proc needs to read a var, pass it as a parameter - you're not going to be doing things like for(var/mob/m in world) in a client-side proc).

This also has other uses. If you want to change the way a mob appears to certain players you don't have to create an image object and attach it to the mob, you just run a client-side proc that modifies the mob's icon or icon_state. Since the changes made by the client-side proc take priority over changes made by the server, that's all you'd have to do.

Another important thing is that procs that run client-side can generate particles. If particles are generated by the server, even if their movement and updating is handled on the client it can take a lot of bandwidth just to create all of the particles. Some effects can require tons of particles. If you could execute a single proc on the client and have it know how to generate the particles, lots of bandwidth would be saved.
This is so amazing lol.
Is this still being considered? Would be very cool if BYOND had an efficient particle system.
Bump
I hate to necro a post like this, but this is something that would be completely invaluable to the language. With the ability to handle procs client-side, it would give BYOND the horsepower capable of being taken more seriously as a game engine. There are so many functions that should be handled entirely client-side that just aren't right now and I think that's one of the core reasons why people seem to think that BYOND isn't a powerful engine.

I don't believe for a second that BYOND's not a powerful engine, but what it does lack right now is a completely dynamic method of removing the load of "juicing" up your game from the server and put that strain on the client. Every other game engine does this.

I can't get my particle engine to efficiently render past a thousand or so full collision particles at one time, which for one client would be an amazingly huge amount, but on a server full of players breaking stuff, fighting, having particles splash around and just look badass, that threshold is just far too low for it to be viable in any game.

I know Lummox has been super busy with getting the Webclient DSified and it's awesome that he's been doing such fantastic work to the engine lately, but this is something that I really think BYOND needs to be able to do more effectively. If we could package procs for the client to run dynamically, it would open up so many more possibilities. Not to mention all of the GUI code and everything could be pushed into these packages and keep all of that mess off of the server, freeing up a ton of resources.
Client-side procs are rather a different animal than particle effects.

animate() exists now, which does help a lot with particle effects. However I suspect what's needed here is a cross between animate() and missile(). Of course, BYOND's rendering also still treats every icon as a sprite, so each individual particle would be sorted into the display space.
In response to Lummox JR
Well, having client-side procs would basically solve the particle effect issue I'm having right now, plus it would be a much better blanket solution to a large number of improvements than a built-in particle engine would be.

Animate is great and I use it for the actual particles themselves for tweening and whatnot, but the issue isn't the animation, it's the resource cost effectiveness regarding the actual particles themselves, which is what's killing the performance.

I know there's no such thing as a simple method of accomplishing this, but would you think there's any way in the future that something like this could be looked into? I would assume you'd have at least a general idea of how to accomplish something like this.
To be honest, I speculated on the idea of client-side procs many years ago, and in most of the years since I've discovered how ridiculously complicated such a thing would be.

I'm more interested in learning what you would need to handle particles effectively without using client-side procs, which are probably overkill. What is killing performance exactly? Have you profiled the code to find out? I could also see 1000 particles causing plenty of issues client-side even without server-side complications.
In response to Lummox JR
I haven't finished testing and debugging my code, nor have I finished completely installing all efficiency measures in it, like particle recycling. I'm working on that right now and once I have it done, I'll see about profiling it and giving you a better idea of how it's being handled.

Right now, most of the compilation is with creating and deleting the particles, unsurprisingly enough, so once I get a recycling system in place, it should see a good jump in performance.

But even as far as I know, it's very hard to get more than a couple thousand particles on the screen at once, even with full efficiency.
Question being, how much of that is server-side and how much is client-side? The whole display system BYOND uses on the client end would be somewhat unfriendly to 1000 particles.
In response to Lummox JR
Then off-screen particles shouldn't affect the client much, right? That would just be the server handling that.
If the particles are definitely not visible to the client (even within the soft border used for scrolling, etc.), then only the server would be impacted.
Well, apparently the server is the issue, because it doesn't matter whether the particles are happening on screen or off screen, it's still ramming the CPU hardcore.
Lummox JR resolved issue with message:
Client-side particle effects have been added! The particle system allows for a massive amount of flexibility with special effects (which is likely to be expanded in future builds). These effects are purely visual, run on the client, and should not impact server performance.
Bruh
Page: 1 2