Hi everyone. Here's a quick video showing how to add your own ship launching system. As it is 50 years (or close enough) since the Moon Landings I thought I'd make it Moon themed
This is just a simple example and I will make a second video showing how you can get this to work with several objects. I thought it best to do it the easy way first though. That way you will see why the changes I make are needed.
Here is the code used.
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Launches Ship
function launchmis_single_init(e)
missileactivated=0
missilespeed=0
soundstarted=0
end
function launchmis_single_main(e)
if soundstarted==0 then
PlaySound(e,0)
soundstarted=1
end
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 800 and g_PlayerHealth > 0 and g_PlayerThirdPerson==0 then
if missileactivated==0 then
Prompt("Press E to Activate Ship")
if g_KeyPressE==1 then
missileactivated=1
end
end
end
if missileactivated==1 then
missilespeed=missilespeed+0.25
CollisionOff(e)
SetPosition(e,g_Entity[e]['x'],g_Entity[e]['y']+missilespeed,g_Entity[e]['z'])
StartParticleEmitter(e)
if g_Entity[e]['y']>120000 then
missileactivated=0
missilespeed=0
StopParticleEmitter(e)
Destroy(e)
end
CollisionOn(e)
end
end
Part 2 is now done.
Here's the code.
-- LUA Script - precede every function and global member with lowercase name of script + '_main'
-- Player Launches Missile
missileactivated={}
missilespeed={}
function launchmis_init(e)
missilespeed[e]=0
missileactivated[e]=0
end
function launchmis_main(e)
PlayerDist = GetPlayerDistance(e)
if PlayerDist < 500 and g_PlayerHealth > 0 and g_PlayerThirdPerson==0 then
if missileactivated[e]==0 then
Prompt("Press E to Activate Missile")
if g_KeyPressE==1 then
missileactivated[e]=1
StartParticleEmitter(e)
end
end
end
if missileactivated[e]==1 then
tempspeed=missilespeed[e]
tempspeed=tempspeed+0.25
missilespeed[e]=tempspeed
tempspeed=0
CollisionOff(e)
SetPosition(e,g_Entity[e]['x'],g_Entity[e]['y']+missilespeed[e],g_Entity[e]['z'])
if g_Entity[e]['y']>60000 then
StopParticleEmitter(e)
missileactivated[e]=0
missilespeed[e]=0
Destroy(e)
end
CollisionOn(e)
end
end
SPECS: Ryzen 1700 CPU. Nvidia 970GTX. 16 Gig Memory. Win 10.