OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: The-Architect 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?
-
What are you trying to have him fire at? doFire doesn't work against Objects.
-
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.
-
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.
-
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.
-
Yeah, invisible targets seem to do the trick. Cheers fellas.
-
Still, using an addon for such a thing doesn't make me feel right. I hope BIS will include it in Arma 2.
-
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.
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.
-
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?
-
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?
-
well heres one i use to make a unit fire until somethings dead
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 (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 had a hard time getting an M113 shooting at targets without shooting in the air. Here is my solution, may help?
; 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"
-
Surely surdus it should be:
while {whatever condition} do
{
unit1 action ["useWeapon",primaryWeapon unit1,unit1,0];
sleep 0.2;
};
Or something similar to that...?
-
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.
-
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).