I haven't worked on this for a while, but I intend to release a completed version eventually with a test mission. For now, I thought I'd better put the whole script up as it is presently. This version is dependent upon the mediaVPs, a custom texture for the weapon particle, and an addition to the weapon table.
#Conditional Hooks
$Application: FS2_Open
$On Game Init:
[
--impact explosion, check the MediaVP wep.tbm files for which one you want and what radius to use
local texturename = "Akheton_Impact"
imageRadius = 1.8
repairImpactImage = gr.loadTexture(texturename, true)
--Render particle instead of laser
local texturename = "naniteparticle2"
laserRadius = 0.5
repairLaserImage = gr.loadTexture(texturename, true)
]
$State: GS_STATE_GAME_PLAY
$Weapon class: Nanite Repair ;;Weapon class is the same name as is displayed on the HUD
$On Ship Collision:
[
local repairValue = 350 --use lower values for weapons with a high rate of fire and vice versa.
hv.Ship.HitpointsLeft = hv.Ship.HitpointsLeft+repairValue
if (hv.Ship.HitpointsLeft > hv.Ship.HitpointsMax) then
hv.Ship.HitpointsLeft = hv.Ship.HitpointsMax
end
local createPos = hv.Self.LastPosition --can be replaced with proper collision detection if you're picky
local velocity = ba.createVector(0,0,0)
ts.createParticle(createPos, velocity, 1, imageRadius, PARTICLE_BITMAP, -1, false, repairImpactImage)
hv.Self.LifeLeft = 0 -- weapon not flagged for death until all collisions this frame have been checked
hv.Self.Physics.Velocity = hv.Ship.Physics.Velocity --hack to prevent multiple collisions
]
+Override: true
$State: GS_STATE_GAME_PLAY
$Weapon class: Nanite Repair ;;Weapon class is the same name as is displayed on the HUD
$On Object Render:
[
local createPos = hv.Self.Position
local velocity = hv.Self.Physics.Velocity
local time = 0.016667
if lastTime then
if ((time + lastTime) < mn.getMissionTime()) then
ts.createParticle(createPos, velocity, time, laserRadius, PARTICLE_BITMAP, -1, false, repairLaserImage)
local lastTime = mn.getMissionTime()
end
else
ts.createParticle(createPos, velocity, time, laserRadius, PARTICLE_BITMAP, -1, false, repairLaserImage)
local lastTime = mn.getMissionTime()
end
]
$State: GS_STATE_GAME_PLAY
$Weapon class: Nanite Repair ;;Weapon class is the same name as is displayed on the HUD
$On Weapon Fired:
[
if hv.User == hv.Player then
local soundPos = hv.User.Position
local time = 0.6
if lastTimeSound then
if ((time + lastTimeSound) < mn.getMissionTime()) then
soundHandle = ad.playGameSound(192)
end
else soundHandle = ad.playGameSound(192)
end
lastTimeSound = mn.getMissionTime()
end
]
#End