It bothered me how glowmaps of dying capships stay on, so I wrote a little script which makes them flicker and gradually turn off altogether over the course of a few seconds. As you can see, the flicker duration is changeable by changing the value of flicker_duration. Also, "debris-glow" is not flickered.
Unfortunately, it's impossible to access the textures of debris pieces, so this is incapable of switching debris piece glowmaps off.
Feel free to use this however and wherever you wish. If you find any bugs or make improvements, post them here!
#Conditional Hooks
$Application: FS2_Open
$On Game Init: [
-- For how long the glowmaps should flicker, in seconds
flicker_duration = 4.0
glowmap_replacement = gr.createTexture(16, 16, TEXTURE_DYNAMIC)
if glowmap_replacement == nil or not glowmap_replacement:isValid() then
ba.warning("Error in initializing glowmap flickering script: could not create helper texture! Flicker effect won't work.")
else
gr.setTarget(glowmap_replacement)
gr.clearScreen()
gr.setTarget()
end
]
$State: GS_STATE_GAME_PLAY
$On State Start: [
flickering_glowmaps = {}
]
$On State End: [
flickering_glowmaps = {}
]
$On Death: [
ship = hv.Self
if ship ~= nil and ship:isValid() and glowmap_replacement ~= nil and glowmap_replacement:isValid() then
textures_num = #ship.Textures
for i=1,textures_num do
filename = ship.Textures[i]:getFilename()
if string.find(filename, "-glow") ~= nil and string.find(filename, "debris-glow") == nil then
table.insert(flickering_glowmaps, { ship_signature = ship:getSignature(), tex_i = i, tex = ship.Textures[i], start_time = mn.getMissionTime() } )
end
end
end
]
$On Frame: [
if table.maxn(flickering_glowmaps) > 0 then
for i=1,table.maxn(flickering_glowmaps) do
flicker_time_elapsed = mn.getMissionTime() - flickering_glowmaps[i].start_time
if flicker_time_elapsed < flicker_duration then
ship = mn.getObjectFromSignature(flickering_glowmaps[i].ship_signature)
if (math.random() * flicker_duration) > flicker_time_elapsed then
ship.Textures[flickering_glowmaps[i].tex_i] = flickering_glowmaps[i].tex
else
ship.Textures[flickering_glowmaps[i].tex_i] = glowmap_replacement
end
else
table.remove(flickering_glowmaps, i)
-- Removing an element might make the loop break, so let's just
-- bail out for this frame rather than do something fancy...
break;
end
end
end
]
#End