rfx()
var/fir1 = 10
for(var/fi = 1 to fir1)
var/obj/fx/flame_thrower/f
if(flame_thrower_fx_grave2.len) {f = flame_thrower_fx_grave2[1];flame_thrower_fx_grave2 -= f}
else
f = new()
f.start()
//var/list/fIl = list('fire_s_1.dmi','fire_s_2.dmi','fire_s_3.dmi','fire_s_4.dmi','fire_s_5.dmi')
var/fIr = rand(1,5)
if(fIr == 1){f.icon = 'fire_s_1.dmi'};if(fIr == 2){f.icon = 'fire_s_2.dmi'};if(fIr == 3){f.icon = 'fire_s_3.dmi'};if(fIr == 4){f.icon = 'fire_s_4.dmi'};if(fIr == 5){f.icon = 'fire_s_5.dmi'}
//var/icon/fI = new(fIl[fIr])
f.icon_state = pick(icon_states(f.icon))
if(fIr == 4) f.icon_state = "[rand(5,8)]"
var/rr = 1
f.color = pick(rgb(255,213/(rand(10,30)/10),75/(rand(10,30)/10)),rgb(255,166/(rand(10,30)/10),57/(rand(10,30)/10)),rgb(227,123/(rand(10,30)/10),85/(rand(10,30)/10)),rgb(213,103/(rand(10,30)/10),62/(rand(10,30)/10)),rgb(188,80/(rand(10,30)/10),40/(rand(10,30)/10)))
f.alpha = 100
f.layer = layer+10
f.plane = plane
f.loc = loc
f.pixel_x = 0;f.pixel_y = 0
f.pixel_x += step_x-32 + rand(-rr,rr)
f.pixel_y += step_y+pixel_y + rand(-rr,rr)
if(fIr != 2 && fIr != 5)
f.pixel_x += 16
f.pixel_y -= 16
if(fIr == 4)
f.pixel_x -= 16
f.pixel_y -= 16
var/fc = pick(rgb(153,65,33),rgb(104,44,22),rgb(69,24,21))
var/obj/g
if(flame_thrower_fx_grave2_glow.len) {g = flame_thrower_fx_grave2_glow[1];flame_thrower_fx_grave2_glow -= g}
else
g = new()
f.g_obj = g
g.icon = 'fire_g_glow.dmi'
g.blend_mode = BLEND_ADD
g.pixel_x = 0;g.pixel_y = 0
g.pixel_x -= 16
g.pixel_y -= 16
g.transform = matrix()*1
g.layer = f.layer
g.plane = f.plane
//g.alpha = 100
if(fIr != 2 && fIr != 5)
g.pixel_x -= 16
g.pixel_y += 16
if(fIr == 4)
g.pixel_x += 16
g.pixel_y += 16
f.underlays += g
f.transform = turn(matrix()*(size*0.5),rand(0,360))
var/aa = 0//f.alpha/2
var/tt = 5//rand(3,5)
animate(f,time=tt,alpha = aa,transform = turn(matrix()*0.1,rand(0,360)),color=fc,easing=SINE_EASING)
//spawn(tt)
//if(fi > 1)
// f.deleter(0)
//else
//f.loc = null
f.deleter(tt)
Mind the mess and the comments. The main problem here, is that the code runs on almost no cpu, when I set f.loc = null, right before f.deleter(tt), which you can see is currently commented out. This places me to believe the renderer is what's choking up here. This is running on an update loop. With f.loc = null disabled, the particles cause a complete slowdown running at 30%~+ cpu and tick_usage.
How many of these particles are there?
The rendering code for each particle will do the following things that all use the CPU:
- The obj will have to generate an icon or set of icons, which
- checks the current state of the animation and interpolates, and
- has to build the icon based on the interpolated appearance.
- The resulting icons have to be put into the finalized MapIcon format.
- The resulting icons get sorted.
Rendering will use some CPU time, but I imagine the bulk of it will come in the earlier routines, with interpolation and sorting possibly taking the most time. Matrix interpolation in particular is likely to take a little bit of time for each obj, so a whole crapload of those particles could end up being a drag. (Linear matrix interpolation is faster, but it doesn't handle rotation correctly. However in a particle system I have doubts that you need to worry about perfection, and could use that as a shortcut.)