Difference between revisions of "Script - Scripted Flak"

From FreeSpace Wiki
Jump to: navigation, search
(new page)
 
(changed the flakscript to upgraded version)
Line 3: Line 3:
  
 
==Table Entry==
 
==Table Entry==
<pre>#Global Hooks
+
'''flak-sct.tbm'''
 +
<pre>#Conditional Hooks
  
$GameInit:
+
$State: GS_STATE_GAME_PLAY
 +
 
 +
$On Frame:
  
 
[
 
[
  
flaktexture = gr.loadTexture("yellow_glow")
+
floatMissionTime = mn.getMissionTime()
nullvec = ma.newVector(0,0,0)
 
  
]
+
if floatMissionTime ~= nil then
  
$Simulation:
+
  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
  
frametime = ba.getFrametime()
+
  --Iterate through all the weapons
 +
  for j=1,#mn.Weapons do
 +
      objectWeapon = mn.Weapons[j]
  
for i=1, mn.getNumWeapons() do
+
      --If weapon type is the one within "s then...
  local flakweapon = mn.getWeaponByIndex(i)
+
      stringWeaponType = objectWeapon.Class.Name
  local flakname = flakweapon.Class.Name
+
      if stringWeaponType == "Flak Energy" then
  if flakname == "Flak Rapid" or flakname == "Standard Flak" or flakname == "Heavy Flak" or flakname == "Long Range Flak" then
+
        --Create particle effect where the weapon is ATM
      ts.createParticle(nullvec,nullvec,frametime,1.5,"Bitmap",-1,false,flaktexture,flakweapon)
+
        --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
 
end
Line 30: Line 40:
 
]
 
]
  
#End</pre>
+
#End
 +
</pre>
  
 
==Notes==
 
==Notes==

Revision as of 11:21, 5 October 2007

Function

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.