Home   Help Search Login Register  

Author Topic: Getting a unit to fire  (Read 2150 times)

0 Members and 1 Guest are viewing this topic.

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Getting a unit to fire
« on: 06 May 2008, 03:55:46 »
I've been playing with the fire command. I have aguy and can get him to shoot but it's straight up in the air and only one round.

I asked him to dowatch and dotarget a target and told him to go fullauto but it isn't working.

Any ideas on how I can get him to stand, look at what I tell him and then unload a clip?
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline Pirin

  • Members
  • *
Re: Getting a unit to fire
« Reply #1 on: 06 May 2008, 06:00:50 »
What are you trying to have him fire at?  doFire doesn't work against Objects.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Getting a unit to fire
« Reply #2 on: 06 May 2008, 06:22:15 »
This is a pain.  I can't get "Fire", "dofire", or "action ["useWeapon",...] to work for this.

The sure fire way is to use invisible targets (like Mapfact's Misc addon), but that requires an addon.  If you are interested in that approach see my Coup De Grace scripts in the scripting resource beta thread.

For a cutscene, you can use the trick I used in the outro for Last Tango in Bagango, where I had a MG AI fire on a camera.  The trick was I had an enemy soldier stashed away off camera, who was setcaptive true.  His name was "vidCamTarget".  The Machine gunner was named "corporal".  In the script below, I setpos the enemy (vidCamTarget) in front of the shooter (corporal).  The camera was focused on the shooter, so the enemy was not in the field of view.  The shooter was then ordered to target and fire.  The timing of when the shooter would recognize the enemy and shoot varied greatly from each test, so I accellerated time to make it fast, and immediately de-accelerated time once the shooter shot (via a "fired" eventhandler on the shooter setting the global variable mgFired true).  It was a lot of work to figure out, but it worked well.  The shooter fired quickly, exactly where I wanted him to.

vidCamTarget setpos (vid2 modelToWorld [2,.5,0])
corporal doTarget vidCamTarget
~.1
mgFired = false
setacctime 2.5
corporal dotarget vidCamTarget
~.3
vidCamTarget setCaptive false
corporal dofire vidCamTarget
~1
corporal dofire vidCamTarget
corporal dofire vidCamTarget
#mgNotFired
~.05
?(Alive vidCamTarget): goto "mgNotFired"
setacctime 1.0
vidCamTarget setpos [0,0,0]

If you find an easier way, be sure and post it.  Good luck.
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re: Getting a unit to fire
« Reply #3 on: 06 May 2008, 15:30:47 »
That is really far from suitible. I have seen youtube videos with guys firing away but it's becoming more and more clear that it is possibly many takes editied together.

I'll keep experimenting but people do keep an eye out for a better solution.
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline Mr.Peanut

  • Former Staff
  • ****
  • urp!
Re: Getting a unit to fire
« Reply #4 on: 06 May 2008, 15:38:07 »
Sadly, the only real solution is an invisible target.  I have seen an OFP script that gets a unit to watch and target a position(not an object) and then uses the fire (not doFire) command, but AFAIK this only works for vehicle units.
« Last Edit: 07 May 2008, 17:47:11 by Mr.Peanut »
urp!

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re: Getting a unit to fire
« Reply #5 on: 07 May 2008, 11:47:28 »
Yeah, invisible targets seem to do the trick. Cheers fellas.
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline Cheetah

  • Former Staff
  • ****
Re: Getting a unit to fire
« Reply #6 on: 07 May 2008, 11:50:22 »
Still, using an addon for such a thing doesn't make me feel right. I hope BIS will include it in Arma 2.
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline Surdus Priest

  • Members
  • *
  • Only I can Forgive You!
Re: Getting a unit to fire
« Reply #7 on: 07 May 2008, 15:03:39 »
unit1 action ["useWeapon",unit1,unit1,0]

this will make a soldier called unit1 fire a single round from his primary weapon.

to make repeated bursts you have to make a script that automates the firing.
Code: [Select]
while {whatever condition} do
     {
     unit1 action ["useWeapon",unit1,unit1,0];
     sleep 0.2;
     };

i was messing around with this to create a super soldier which had amazing reaction times and accuracy.  but while both the accuracy and reactions where adequate, the soldier was still just a soldier which died after a couple of rounds to the chest...

edit: you need to use dotarget rather than watch because he will end up shooting at the blokes feet otherwise.
« Last Edit: 07 May 2008, 15:05:17 by Surdus Priest »
Campaigns are hard, I'll stick with scripting for now!

Offline Cheetah

  • Former Staff
  • ****
Re: Getting a unit to fire
« Reply #8 on: 07 May 2008, 16:19:39 »
Looks promising Surdus Priest. What works best for you? Different sleeps for MGers, rifleman etc?

Also, can you use this only for fire against other units, or against objects / positions too?
Like missions? Help with Beta Testing! or take a look at the OFPEC Missions Depot for reviewed missions!

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Getting a unit to fire
« Reply #9 on: 10 May 2008, 20:24:37 »
I am surprised that this command...

unit1 action ["useWeapon",unit1,unit1,0];

...is working for you SurdusPriest.

When I use it, the unit plays the take weapon from ammo box animation...every time.  Except when the unit is on a vehicle weapon.  Then it works.

Is this working for you for non-vehicle units?  Under what version of ARMA?
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...

Offline DeanosBeano

  • Addons Depot Staff
  • *****
  • SirDeanosbeano bstowed on me by sui ;)
    • Fraghaus
Re: Getting a unit to fire
« Reply #10 on: 10 May 2008, 21:21:19 »
 well heres one i use to make a unit fire until somethings dead

Code: [Select]
loop
? !(alive c1) : goto "enders"
airo selectweapon ">>insert your units weapon type here<<"
airo dotarget c1
airo dofire c1
~.15
goto "loop"
#enders
airo is a man his name in the editor is airo

 c1 is a man his name in editor is c1

here is wiki of all weapon types
http://community.bistudio.com/wiki/ArmA:_Weapons

 you can find weapon easily of unit by parameter of execution but i have no time now unfortunately

 



 

I love ofp

Offline Sparticus76

  • Members
  • *
Re: Getting a unit to fire
« Reply #11 on: 12 May 2008, 12:20:49 »
I had a hard time getting an M113 shooting at targets without shooting in the air. Here is my solution, may 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"

Offline Rommel92

  • Members
  • *
Re: Getting a unit to fire
« Reply #12 on: 15 May 2008, 09:57:31 »
Surely surdus it should be:

Code: [Select]
while {whatever condition} do
     {
     unit1 action ["useWeapon",primaryWeapon unit1,unit1,0];
     sleep 0.2;
     };

Or something similar to that...?

Offline lendrom

  • Members
  • *
Re: Getting a unit to fire
« Reply #13 on: 17 May 2008, 18:20:47 »
Huh. I've been experimenting with this for some time now.
unit1 action ["useWeapon", primaryWeapon unit2, unit2, 0] works for me.
BUT!!
unit1 must be a game logic and not the unit you want to shoot! In the other case the unit you want to make shooting will play 'gear' animation.
Now if we only had a way to check for Line of sight we could make units really use suppressive fire.
Blessed are those who have nothing to say and yet they remain silent.

Offline johnnyboy

  • OFPEC Patron
  • ****
  • Matan los Pantalones!!!
Re: Getting a unit to fire
« Reply #14 on: 09 Jun 2008, 17:59:04 »
Quote
Now if we only had a way to check for Line of sight we could make units really use suppressive fire.

You should check out Rommels suppression script <A HREF="http://www.ofpec.com/forum/index.php?topic=31322.0">ROMMIA.sqf</A>.

Instead of "line of sight", shooters are commanded to target the most known enemy unit.  This means they point their guns at enemy, even if the enemy is behind a cover object.  The UseWeapon command then forces shooter to fire.  This puts down suppressing fire on the units position, even if he is behind cover.  It works pretty well.  Even though there is no "line of sight", the AI isn't "cheating" because they are putting down fire on targets they know about.

The script does more also (a few units lay down the suppressing fire, while the others move toward cover, or flank).
El Cojon: "Do you like to Tango?"
You: "Only in Bagango."
Download Last Tango in Bagango and discover how El Cojon earned his name...