Home   Help Search Login Register  

Author Topic: M2's shooting into the air  (Read 3532 times)

0 Members and 1 Guest are viewing this topic.

Offline ceeeb

  • Members
  • *
Re: M2's shooting into the air
« Reply #15 on: 12 Jan 2008, 06:46:50 »
Quote
Code: [Select]
_gunner action ["USEWEAPON", _firer, _gunner, _weaponindex];

actual syntax is :
_anyunit action ["useWeapon", _vehicle, _firingUnit, _weaponIndex]

_anyunit can be any unit (vehicle or person not in a vehicle, the vehicle to do firing works well)
_vehicle is the vehicle/unit which will fire
_firingUnit is the operator of the weapon to be fired
_weaponIndex is a number

eg:

myM2 doWatch myTarget;
myM2 action ["useWeapon", myM2, gunner myM2, 0]
<repeat>

problem is using doWatch doesn't provide any leading for moving targets. doTarget may work best. checking the m2 is actually able to aim at the target would be an worthwhile test too.
« Last Edit: 12 Jan 2008, 07:06:32 by ceeeb »

Offline Sparticus76

  • Members
  • *
Re: M2's shooting into the air
« Reply #16 on: 12 Jan 2008, 15:27:34 »
That worked, here's the finished product that will fire an M2 at any armoured vehicle or any target you designate. Thanks alot to Mandoble, Spooner and Ceeeb for the great help...

Code: [Select]
; initiated with [vehicle firing, targeted vehicle] exec "tgt.sqs"

  _firer = _this select 0
  _tgt = _this select 1

; Get crew of the target for exiting script if they're dead.
  _crew = crew _tgt
; Establish info for USE WEAPON action.
  _gunner = gunner _firer

; If target is destroyed, start the target search script again and exit program.
; If not, make burst size 20 rounds with between 0.5 and 1 second gaps.
#fire
  ? (!alive (_crew select 1) && !alive (_crew select 2)) || getdammage _tgt == 1 : [_firer] exec "findtgt.sqs" ; exit
  _ammo = _firer ammo "M2"
  _burst = _ammo - 20
  ~(Random 0.5) + 0.5
  goto "burst"

; If target is destroyed, start the target search script again and exit program.
; Get Firer to watch the target and use his main weapon.
; Conduct burst with ammo check and loop.
; If ammo is less than burst then go back to fire to establish new burst size.
#burst
  ? (!alive (_crew select 1) && !alive (_crew select 2)) || getdammage _tgt == 1 : [_firer] exec "findtgt.sqs" ; exit
  _firer dowatch getpos _tgt
  _firer action ["useWeapon", _firer,_gunner, 0]
  _ammo = _firer ammo "M2"
  ? _ammo <= _burst : goto "fire" 
  ? _ammo > _burst : goto "burst"
« Last Edit: 13 Jan 2008, 15:04:16 by Sparticus76 »