Bobble head script (aka generic camera)...
[[ It's just a framework to modify and use for your specific tasks ]]
I probably can't help make it do those //-animation specific uses-//
for example, but see what can be done with it.
Also- if you don't like my 'eccentric' scripting style-- well sorry!
I'm sticking with that style for the mean-time-- you can re-do it!
local c_firstx = {}
local c_firsty = {}
local c_firstz = {}
local c_goalx = {}
local c_goaly = {}
local c_goalz = {}
local c_scopex = {}
local c_scopey = {}
local c_scopez = {}
local run_camera = {}
local c_therex = {}
local c_therey = {}
local c_therez = {}
local c_speedx = {}
local c_speedy = {}
local c_speedz = {}
local doonce = {}
function generic_camera_init(e)
c_firstx[e] = g_PlayerAngX
c_firsty[e] = g_PlayerAngY
c_firstz[e] = g_PlayerAngZ
c_scopex[e] = g_PlayerAngX
c_scopey[e] = g_PlayerAngY
c_scopez[e] = g_PlayerAngZ
c_goalx[e] = c_scopex[e] + math.random(1,12) - 6 -- (-10) < 10
c_goaly[e] = c_scopey[e] + math.random(1,14) - 7 -- (-10) < 10
c_goalz[e] = c_scopez[e] + math.random(1,10) - 5 -- (-10) < 10
c_speedx[e] = 0
c_speedy[e] = 0
c_speedz[e] = 0
run_camera[e] = 0
c_therex[e] = 0
c_therey[e] = 0
c_therez[e] = 0
doonce[e] = 0
end -- init
function generic_camera_main(e)
-- DO ONCE ASSIGNMENTS!!
if doonce[e] == nil then doonce[e] = 0 end
if doonce[e] < 4 then
doonce[e] = doonce[e] + 1
c_firstx[e] = g_PlayerAngX
c_firsty[e] = g_PlayerAngY
c_firstz[e] = g_PlayerAngZ
c_scopex[e] = g_PlayerAngX
c_scopey[e] = g_PlayerAngY
c_scopez[e] = g_PlayerAngZ
c_goalx[e] = c_scopex[e] + math.random(1,12) - 6 -- (-10) < 10
c_goaly[e] = c_scopey[e] + math.random(1,14) - 7 -- (-10) < 10
--c_goalz[e] = c_scopez[e] + math.random(1,10) - 5 -- (-10) < 10
c_goalz[e] = 0
run_camera[e] = 0
c_therex[e] = 1
c_therey[e] = 1
c_therez[e] = 1
c_speedx[e] = 0
c_speedy[e] = 0
c_speedz[e] = 0
end -- DO ONCE ASSIGNMENTS!!
--------#######--<:>--#######--<:>--#######--<:>--
if g_Scancode == 48 then -- 'B' for bobbing camera ON
--SetCameraOverride ( 2 ) -- where i is 0-off, 1-position only, 2-angle only, 3-position and angle
c_firstx[e] = g_PlayerAngX
c_firsty[e] = g_PlayerAngY
c_firstz[e] = g_PlayerAngZ
c_scopex[e] = g_PlayerAngX
c_scopey[e] = g_PlayerAngY
c_scopez[e] = g_PlayerAngZ
c_goalx[e] = c_firstx[e] + math.random(1,12) - 6 -- (-10) < 10
c_goaly[e] = c_firsty[e] + math.random(1,14) - 7 -- (-10) < 10
--c_goalz[e] = c_scopez[e] + math.random(1,10) - 5 -- (-10) < 10
c_goalz[e] = 0
c_speedx[e] = 0
c_speedy[e] = 0
c_speedz[e] = 0
run_camera[e] = 1
end
if g_Scancode == 49 then -- 'N' for bobbing camera OFF
--SetCameraOverride ( 0 ) --
run_camera[e] = 0
end
if run_camera[e] == 1 then -- run camera bobbing
if c_therex[e] == 1 then -- find new 'X' movement
c_goalx[e] = c_firstx[e] + math.random(1,12) - 6 -- (-6) < 6
c_therex[e] = 0
end -- find new 'x' movement
if c_therey[e] == 1 then -- find new 'Y' movement
c_goaly[e] = c_firsty[e] + math.random(1,14) - 7 -- (-7) < 7
c_therey[e] = 0
end -- find new 'y' movement
if c_scopex[e] < c_goalx[e] then -- tugged to new angle '+X'
if c_speedx[e] < 1 then c_speedx[e] = c_speedx[e] + 0.07 end
end
if c_scopex[e] > c_goalx[e] then -- tugged to new angle '-X'
if c_speedx[e] > -1 then c_speedx[e] = c_speedx[e] - 0.07 end
end
if c_scopey[e] < c_goaly[e] then -- tugged to new angle '+Y'
if c_speedy[e] < 1 then c_speedy[e] = c_speedy[e] + 0.07 end
end
if c_scopey[e] > c_goaly[e] then -- tugged to new angle '-Y'
if c_speedy[e] > -1 then c_speedy[e] = c_speedy[e] - 0.07 end
end
c_scopex[e] = c_scopex[e] + c_speedx[e]
c_scopey[e] = c_scopey[e] + c_speedy[e]
if math.abs(c_scopex[e] - c_goalx[e]) < 2 then c_therex[e] = 1 end
if math.abs(c_scopey[e] - c_goaly[e]) < 2 then c_therey[e] = 1 end
--SetCameraAngle ( 0, c_scopex[e], c_scopey[e], c_scopez[e] )
SetFreezePosition(g_PlayerPosX,g_PlayerPosY,g_PlayerPosZ)
SetFreezeAngle(c_scopex[e], c_scopey[e], c_scopez[e])
TransportToFreezePosition()
end -- run_camera[e] = 1
--[[
Text(5, 7,3,"goalx; "..c_goalx[e])
Text(5,11,3,"goaly; "..c_goaly[e])
Text(5,15,3,"goalz; "..c_goalz[e])
Text(5,20,3,"scopex; "..c_scopex[e])
Text(5,24,3,"scopey; "..c_scopey[e])
Text(5,28,3,"scopez; "..c_scopez[e])
--]]
end -- main