FreeSpace Releases > Scripting Releases

yup, guided missiles

<< < (2/2)

WMCoolmon:

--- Quote from: Nuke on August 30, 2007, 07:01:33 pm ---i know theres hooks for weapon colisions, but do they have access to the colision location vector and do they work on beams?
--- End quote ---

No and probably not. I don't remember testing beams. I believe the collision location is already calculated in the code itself, but there's no scripting access to the variable.

Check your PMs. :D

jr2:

--- Quote from: Nuke on August 27, 2007, 02:53:52 pm ---
--- Code: ---#Global Hooks ;;guided missiles, proof of concept version
$GameInit:
[
-------------------------------
----------screen vars----------
-------------------------------

setscreenvars = function() --scalers and constants for multi res support
local w = gr.getScreenWidth()
local h = gr.getScreenHeight()
local cx = w/2
local cy = h/2
local wf = 0
local hf = 0
local awh = 0
local hires = false

if w >= 1024 then
wf = w / 1024
hf = h / 768
awh = (wf + hf) / 2
hires = true
else
wf = w / 640
hf = h / 480
awh = ((wf + hf) / 2) * 0.625
hires = false
end

return w,h,cx,cy,wf,hf,awh,hires
end

----------------------------
----------controls----------
----------------------------

mousejoy = function() --mousejoy function, short version
local X = io.getMouseX()
local Y = io.getMouseY()

if hires then
X = (X / 511.5) - 1
Y = (Y / 383.5) - 1
else
X = (X / 319.5) - 1
Y = (Y / 239.5) - 1
end

return X, Y
end

-------------------------
----------Maths----------
-------------------------

matx = function(ma, mb) --matrix multiply
local m = ba.createVector(0,0,0):getOrientation()
m[1] = ma[1] * mb[1] + ma[2] * mb[4] + ma[3] * mb[7]
m[2] = ma[1] * mb[2] + ma[2] * mb[5] + ma[3] * mb[8]
m[3] = ma[1] * mb[3] + ma[2] * mb[6] + ma[3] * mb[9]
m[4] = ma[4] * mb[1] + ma[5] * mb[4] + ma[6] * mb[7]
m[5] = ma[4] * mb[2] + ma[5] * mb[5] + ma[6] * mb[8]
m[6] = ma[4] * mb[3] + ma[5] * mb[6] + ma[6] * mb[9]
m[7] = ma[7] * mb[1] + ma[8] * mb[4] + ma[9] * mb[7]
m[8] = ma[7] * mb[2] + ma[8] * mb[5] + ma[9] * mb[8]
m[9] = ma[7] * mb[3] + ma[8] * mb[6] + ma[9] * mb[9]
return m
end

arbrot = function(a, r)
local s = math.sin(r)
local c = math.cos(r)
local t = 1 - c
local m = ba.createVector(0,0,0):getOrientation()

m[1] = t * a.x^2 + c
m[2] = t * a.x * a.y + s * a.z
m[3] = t * a.x * a.z - s * a.y

m[4] = t * a.x * a.y - s * a.z
m[5] = t * a.y^2 + c
m[6] = t * a.y * a.z + s * a.x

m[7] = t * a.x * a.z + s * a.y
m[8] = t * a.y * a.z - s * a.x
m[9] = t * a.z^2 + c

return m
end

w,h,cx,cy,wf,hf,awh,hires = setscreenvars()

]
$Simulation:
[

player = mn.Ships['Alpha 1']

x,y = mousejoy()
x = x * ba.getFrametime()
y = y * ba.getFrametime()

for i=1, #mn.Weapons do
local wep = mn.Weapons[i]
if wep.Class.Name == "Infyrno" then
local axis = wep.Orientation:unrotateVector(ba.createVector(1,0,0))
local mat = arbrot(axis,y)
wep.Orientation = matx(wep.Orientation,mat)

axis = wep.Orientation:unrotateVector(ba.createVector(0,1,0))
mat = arbrot(axis,x)
wep.Orientation = matx(wep.Orientation,mat)

wep.Physics.Velocity = wep.Orientation:unrotateVector(ba.createVector(0,0,wep.Class.Speed))
tracking = true
end
end

]
$HUD:
[
if tracking then gr.setColor(255,0,0,128) else gr.setColor(0,0,255,128) end
tracking = nil
gr.drawCircle(3,io.getMouseX()*wf,io.getMouseY()*hf)

]
#End

--- End code ---

load up some infyrnos. use the mouse to steer them. :D

--- End quote ---

Can you release them when they are locked on, like in descent (press fire button again, and they home like normal).

Nuke:
you could do that with weapon children and remote-detonate. you can pretty much use this on any non-homing missile, homing ones work but are abit jumpy. you can even use primaries but it tends to screw up their collosions.

Cobra:
Ooh! OOH! Do the Helios! :D

Navigation

[0] Message Index

[*] Previous page

Go to full version