Weapon scripts: Difference between revisions
From Spring
Jump to navigationJump to search
weapon script exemples |
m completed exemple |
||
| (One intermediate revision by one other user not shown) | |||
| Line 1: | Line 1: | ||
WEAPONERY: | =WEAPONERY:= | ||
following exemples are designed for being a vehicule with 3 weapons (ex: a tank with | ''following exemples are designed for being a vehicule with 3 weapons '' | ||
::<small>(ex: a tank with a vertical missile launcher a turet canon a front flamer )</small> | |||
here the list of 3d model | |||
keep in mind the fact that <big>weapon1 is the sight</big> , | |||
that make the unit will <big>move at weapon1 range</big> if order allow roam | |||
::(other weapon will not make the vehicule move ) | |||
here the list of 3d model piece needed (can be jusqt some empty : | |||
<code> | |||
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" | |||
</code> | |||
== UNCONDITIONAL WEAPONS == | == UNCONDITIONAL WEAPONS == | ||
<code> | |||
function script.AimWeapon1() | function script.AimWeapon1() | ||
return 1 | return 1 | ||
| Line 30: | Line 38: | ||
return tir1 | return tir1 | ||
end | end | ||
</code> | |||
=== weapon with turret === | === weapon with turret === | ||
<code> | |||
function script.AimWeapon2(y2,x2) | 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 | end | ||
| Line 53: | Line 63: | ||
return tir2 | return tir2 | ||
end | end | ||
</code> | |||
==== weapon with limited rotation turet ==== | ==== weapon with limited rotation turet ==== | ||
(the turet will turn only if target is between -0.5 to 3 radian mean on side) | (the turet will turn only if target is between -0.5 to 3 radian mean on side) | ||
this can be done with elevation too | this can be done with elevation too | ||
<code> | |||
function script.AimWeapon3(y3,x3) | 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() | function script.FireWeapon3() | ||
| Line 81: | Line 99: | ||
end | end | ||
</code> | </code> | ||
* Signal(1) & SetSignalMask(1) are using ^2 if ever you need more than 30 of them you must use table names | |||
**the folowing <big>UnitDef</big> tag are involved : | |||
<code> | |||
::highTrajectory=0, | |||
::weapons = {[1]="verti_missile1",[2]="canon2",[3]="flamethrower3", | |||
::slaveTo=0.0, | |||
::mainDir={0.0, 0.0, 1.0}, | |||
::maxAngleDif=180.0, | |||
</code> | |||
*[[SpringRtsTutorialAnimDef]] return to the list of animDef exemples | |||
[[Category:Emmanuel]] | |||
Latest revision as of 12:09, 19 March 2013
WEAPONERY:
following exemples are designed for being a vehicule with 3 weapons
- (ex: a tank with a vertical missile launcher a turet canon a front flamer )
keep in mind the fact that weapon1 is the sight ,
that make the unit will move at weapon1 range if order allow roam
- (other weapon will not make the vehicule move )
here the list of 3d model piece needed (can be jusqt some empty :
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
- Signal(1) & SetSignalMask(1) are using ^2 if ever you need more than 30 of them you must use table names
- the folowing UnitDef tag are involved :
- highTrajectory=0,
- weapons = {[1]="verti_missile1",[2]="canon2",[3]="flamethrower3",
- slaveTo=0.0,
- mainDir={0.0, 0.0, 1.0},
- maxAngleDif=180.0,
- SpringRtsTutorialAnimDef return to the list of animDef exemples