Script - Scripted Flak

From FreeSpace Wiki
Jump to: navigation, search

Creates particles that are closely attached to certain weapon effects—in this case, to flak weapons. This ought to fix the potential problem of missing or double glowpoints appearing with normal particle spew (pspew) option.

Table Entry

flak-sct.tbm

#Conditional Hooks

$State: GS_STATE_GAME_PLAY

$On Frame:

[

floatMissionTime = mn.getMissionTime()

if floatMissionTime ~= nil then

   floatFrameTime = ba.getFrametime(true)

   if textureFlak == nil then
      --Define the graphics file used for the flak - in this example file used is 'lglow3.dds'
      textureFlak = gr.loadTexture("lglow3")
      vectorNull = ba.createVector(0,0,0)
   end

   --Iterate through all the weapons
   for j=1,#mn.Weapons do
      objectWeapon = mn.Weapons[j]

      --If weapon type is the one within "s then...
      stringWeaponType = objectWeapon.Class.Name
      if stringWeaponType == "Flak Energy" then
         --Create particle effect where the weapon is ATM
         --One can always increase the 'frametime' to frametime x 4 etc if needed.
         ts.createParticle(vectorNull,vectorNull,floatFrameTime,2.0,PARTICLE_BITMAP,-1,false,textureFlak,objectWeapon)
      end
   end
end

]

#End

Notes

Requires that the flak weapons are stripped of their respective particle spew settings. That is weapon flag "particle spew" and also all the lines from $Pspew: to +Bitmap: should be removed.