Since a long time I have been working on a project to give a machine gun for tank commanders. I encountered many problems, I have fixed some but some bugs are still unfixed.
3 questions:
*There is a command Getdir which gives the tank's direction and [Getpos which gives the tank's position.
Is there a command which can make possible for me to retrieve the direction and the position of the tank's turret?unsure.gif
*Now the second and the toughest questions:
I'm working on this project on a mission. An empty tank, a machine gun 2 lads and a trigger to start the scripts.
Here are the init of some objects:
The tank: Name : Tank
init: this setBehaviour "careless"; this addAction ["Turn Out MG","turnMG.sqs"]
Machine gun: name mg_turn
init *empty*
The first guy (player) Name : aP
init: this moveInCommander tank; this setBehaviour "careless"
the second guy, noname
init: this moveInDriver tank; dostop this
These two guys are in the same group, the leader is the player.
The trigger
Condition : true
on activation :[tank,mg_turn] exec "mg_turn_out.sqs"
Now the scripts:
mg_turn_out.sqs
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
;_carrier =>tank "carrying" the mg
;_cargo =>mg a "put" on the tank
_carrier = _this select 0
_cargo = _this select 1
CoPeTe = false
goto debug
#BOZO
truel = true
_x = (getPos _carrier) select 0
_y = (getPos _carrier) select 1
_z = (getPos _carrier) select 2
_GetdirC = Getdir _carrier
_Angle = 360 - _getdirC
_cargo setPos [_x+(0.5*cos _Angle + sin _Angle), _y+(0.5*sin _Angle -cos _Angle), _z + 1.25]
_cargo setDir (getDir _carrier)
~.01
? (!CoPeTe) : goto "BOZO"
exit
TurnMG.sqs
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
;aP =>player or/and tank commander
;tank =>the tank which carries the mg
;mg_turn =>the mg which is on the tank
aP action ["TURNOUT", tank]
~1
aP action ["eject",tank]
aP MoveInGunner mg_turn
tank removeaction turnOutMG
turnIn=mg_turn addaction ["Turn In","turntank.sqs"]
TurnTank.sqs
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">
;aP =>player or/and tank commander
;tank =>the tank which carries the mg
;mg_turn =>the mg which is on the tank
aP action ["eject", mg_turn]
aP MoveInCommander tank
aP action ["TURNOUT", tank]
mg_turn removeaction turnIN
turnOutMG=tank addaction ["Turn Out MG","turnMG.sqs"]
Here are my 2 last questions:
How to put my mg off the mission editor, put it thanks the command Createvehicle in the first script and then retrieve its name for the other scripts?
I believe that a *.sqf would be useful to replace the first script because the game lags a bit on old computers.
If yes, may someone make me one of these *.sqf because i don't speak the *.sqf language at all...
OK that's all, thank you to have at least read this post to the end and thank you for your answers or your comments...
Thanks to Messer for the translation!
We are french, sorry for our (maybe...) bas english...