Forum Jump :

Author Message


Posts: 131
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 22
In-game name: Joshua

 
#1 Posted at 2016-05-02 01:27        
     
In my mission, I am trying to have some AAF soldiers shoot at some pop up targets. To do this I have them always face the target and use the following line to fire. _unit is the unit that should fire.

(vehicle _unit) action ["UseWeapon", vehicle _unit, _unit, 0];

Its worked fine in the past for units in vehicles, but now I am using it on lone soldiers and they just repeatedly play the pick up item animation. I looked into it a bit and that is supposed to only happen when the command is called on the player. I also tried different weapon indices (the last number, in the given line of code, it is 0). Is their any way to fix this?

If you need more information, or I am unclear let me know. This is where I found the reference to the animation error: https://community.bistudio.com/wiki/Arma_3_Actions#UseWeapon


Author Message


Posts: 83
Rank:


Level: Member

Country: us
Location:
Occupation:
Age:
In-game name: J.Shock

 
#2 Posted at 2016-05-02 01:41        
     
You could try this:

https://community.bistudio.com/wiki/fireAtTarget

and use it like this:

yourUnit fireAtTarget [yourTarget];

John Shock
Scripter, Mission Developer

My scripts: Simple Mortar Script, Redressing Script, Cruise Control Script

My Missions: [COOP-40]Operation Bloody Bayonet

Advertisement


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#3 Posted at 2016-05-02 01:52        
     
yourUnit doWatch yourTarget;
waitUntil {yourUnit aimedAtTarget [yourTarget] > 0};
yourUnit fireAtTarget [yourTarget];

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 131
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 22
In-game name: Joshua

 
#4 Posted at 2016-05-02 02:52        
     
Unfortunately fireAtTarget isn't working. It probably has something to do with the targets being pop up targets and not people.

I did some more testing on the action method I was using before, the soldiers throw frags when the index is set to 7, and they throw other throwables (smoke grenades and chem lights) at other numbers, but they don't fire their weapons ever. I did only test indices 0 - 50, but nothing was happening after ~20, so I think it was pretty conclusive.

Any other ideas?

*Edit* I should also note I have tried fire, forceweapon fire, and dofire commands as well.

This post was edited by jshear95 (2016-05-02 03:04, 536 days ago)


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#5 Posted at 2016-05-02 21:21        
     
Sorry, some commands don't work with soldier.
You should try:
0 = your_target spawn { bob doWatch _this;
 bob doFire _this};

It works for me.

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 131
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 22
In-game name: Joshua

 
#6 Posted at 2016-05-03 03:46        
     
I tried your code as shown below to no avail. The units are passed as parameters into a script that is supposed to make them point their gun in the right direction, make them fire, and change their accuracy. As such the following code is my implementation of your script Pierre (its within my suppression script).

			0 = [_target,_unit] spawn { (_this select 1) doWatch (_this select 0);
										(_this select 1) doFire (_this select 0)};

It should be noted I have tried using it on its own as shown below, also to no avail:

0 = tgt4 spawn { tgtR4 doWatch _this; tgtR4 doFire _this};

It should also be noted, when this is run (or any other lone type of fire command preceded by doWatch), that unit will continually point their gun at the target (even accounting for elevation), not firing. When only a doWatch command is given, the unit merely shifts direction towards the unit they should be watching, not even raising their gun (the expected behaviour). This leads me to believe something within the engine is preventing the soldiers from recognizing they can fire their rifles on command. When I place down a blufor unit (hostile to independent in the mission), the independent soldiers have no problem recognizing blufor as enemy and shooting him.

The units are being spawned in with my script from this thread ( http://www.armaholic.com/forums.php?m=posts&q=34926&n=last#bottom ) (Thank you for your help on that Pierre :-) ). If you want I can upload the mission file for you to test if that will help. I am stumped, I think it might be a bug in the engine.


Author Message


Posts: 1589
Rank:


Level: Member

Country: pf
Location: Tahiti
Occupation: too many Arma
Age: 57
In-game name: Kobayashi Maru

 
#7 Posted at 2016-05-03 06:26        
     
OK, i've got it!
First of all,
0 = tgt4 spawn { tgtR4 doWatch _this; tgtR4 doFire _this};
can't work because _this and tgtR4 is the same object!
but it's not your problem.
If you use createVehicle for a soldier, you spawn an AI with no behavior.
You must use createUnit. I prefer bis_fnc_spawnGroup even for a single unit. You do an "all in one" spawn, for group and unit.

So, I also tested the targets. Some are more difficult to be fired by the unit. for example, "Land_Target_Swivel_01_F" or "Steel_Plate_L_Stand_F"...

To test, place a player + 12 different targets name them tg1, tg2,... tg12, in a circle all around a marker "mrk";
In a trigger, erase "this" on cond. field (making it unconditional) + timeout set to 3 (0 works also)
in on act field:

0 = [] spawn {
  group_bob = [getMarkerPos "mrk",resistance,["I_Soldier_AR_F"],[],[],[],[],[],0]call BIS_fnc_spawnGroup;
  bob = leader group_bob;
  waituntil {alive bob};
  _i = 1;
  while {_i <13} do {
   bob doWatch (missionNamespace getVariable  "tg"+str(_i));
   bob doFire (missionNamespace getVariable  "tg"+str(_i));
   sleep 2;
   _i = _i +1
  }
}

I hope this help!

PLEASE CONTACT ME ON BI FORUMS FOR ANY SCRIPT / MOD QUESTION. TKS

Author Message


Posts: 131
Rank:


Level: Member

Country: us
Location:
Occupation:
Age: 22
In-game name: Joshua

 
#8 Posted at 2016-05-04 12:55        
     
It did help!

A few clarification points Pierre:
1. The targets are called tgt# while the soldiers are called tgtR#. The soldiers have an additional R (in my mind, the R stands for Rifleman). It makes for easy reference, at least to me. So _this refers to _tgt4 while _tgtR4 was the soldier. Its one character difference, no worries, its an easy mistake to make.

2. I spawn the soldiers with createUnit, not createVehicle (though using createVehicle can lead to some funny moments when the AI is just brain dead *JOKINGLY* ). I would use BIS_fnc_spawnGroup. I have used that function in the past, but in order to get the name for the units for later reference, I have to use createUnit so I can place in their init that 'theirName' = this;

I had a whole long post typed up to give more info and then a solution dawned on me. *WALL*

I was looking at how you used BIS_fnc_spawnGroup and I realized I had never tried it on a unit directly placed in the editor. I placed an AAF dude and an unarmed nato dude in the editor. I tested the suppression script trying to get the AAF dude to fire at the unarmed nato dude. He kept playing the animation, so it wasn't how I was spawning in the unit. I changed the suppression script to use the code below and it worked.

_logic action ["UseWeapon", _unit, _unit, 0];

I spawn a gameLogic at the start of the script called _logic. for that first variable. I guess the key is to make sure that whatever you call it on at the beginning of the line (in the case above, _logic), is not the same as the unit that you define in the array (in the case above _unit). It also appears that it won't work when you swap _logic of a non player unit. If you use the player, the player plays the pickup animation.

Thank you for your help Pierre and JShock.