Weapon scripts: Difference between revisions

From Spring
Jump to navigationJump to search
weapon script exemples
 
Flozi (talk | contribs)
Line 81: Line 81:
  end
  end
</code>
</code>
[[Category:Emmanuel]]

Revision as of 17:14, 8 March 2013

WEAPONERY:

following exemples are designed for being a vehicule with 3 weapons (ex: a tank with a turet a shield and a vertical missile launcher)

keep in mlind the fact that weapon1 is the sight ,

that make the unit move at range if order allow rush and other weapon will not make the vehicule move

here the list of 3d model part needed (can be jusqt some point)
local turet3,gun3 = piece ('turet3','gun3')
local tir3 = piece "tir3"
local turet2,gun2 = piece ('turet2','gun2')
local tir2 = piece "tir2"
local tir1 = piece "tir1"
local aim1 = piece "aim1"
local aim2 = piece "aim2"
local aim3 = piece "aim3"

UNCONDITIONAL WEAPONS

function script.AimWeapon1()
return 1
end 
function script.FireWeapon1()
end
function script.AimFromWeapon1()
return aim1
end
function script.QueryWeapon1()
return tir1
end

weapon with turret

function script.AimWeapon2(y2,x2)
Signal(4)
SetSignalMask(4)
Turn(turet2,y_axis,y2,2)
Turn(gun2,x_axis,- x2,2)
WaitForTurn(turet2,y_axis)
WaitForTurn(gun2,x_axis)
return 1
end 
function script.FireWeapon2()
end
function script.AimFromWeapon2()
return aim2
end
function script.QueryWeapon2()
return tir2
end

weapon with limited rotation turet

(the turet will turn only if target is between -0.5 to 3 radian mean on side)
this can be done with elevation too
function script.AimWeapon3(y3,x3)
Signal(8)
SetSignalMask(8)
if  y3<3   and x3>-0.5  then 
Turn(turet3,y_axis,y3,2)
Turn(gun3,x_axis, - x3 ,2)
WaitForTurn(turet3,y_axis)
WaitForTurn(gun3,x_axis)
return 1
end end
function script.FireWeapon3()
EmitSfx (tir3,257) Sleep(50) --this unmandatory make smoke at shooting point
end
function script.AimFromWeapon3()
return aim3
end
function script.QueryWeapon3()
return tir3
end