Jump to content
Sign in to follow this  
kiptanoi

To make a unit to shoot flare

Recommended Posts

How to make a unit to shoot up a flare...

I dont want to use Flare1="F_40mm_Green" createVehicle [x,y,z]

I want a unit to shoot up a flare in the air...

How is that posible, is it posible?

Share this post


Link to post
Share on other sites

I think the fire command shall do the job, with a doWatch or a doTarget you can get some nice effects.

Share this post


Link to post
Share on other sites

fire definately works. just need to be sure that you initialise the unit with a weapon that can shot flares and with flares in the inventory.

i ve created a few squads that throw smoke grens on to cover themselves while crossing a field. it looks awesome, eventhough the dotarget or dowatch doesnt seem to work too well for this.

you also need to make sure that your unit is not running/spriting. they need to walk or stand still in order to shoot the flare.

Share this post


Link to post
Share on other sites

dotarget or dowatch what is that?

I have my unit with right weapon and got some flares in he's inventory, and he is going to run to a place and then shoot up a flare och two.

---------- Post added at 05:33 PM ---------- Previous post was at 05:04 PM ----------

And I dont want him to shoot at a unit, he must shoot the FlareRed_GP25 up in the air...

And I dont know how to do it.

Share this post


Link to post
Share on other sites

Quick example:

You place your unit wherever you want, then you place some invisible target in the air via setPos, tell unit to doTarget on the invisible target, tell unit to fire.

This shall give something like that:

//Replace <Unit> with the unit name.
_unit = <Unit>;
_posUnit = getPos _unit;
//HeliHEmpty is on ArmA 1, don't know if it's still working on ArmA 2, otherwise just another one.
_invisibleTarget = "HeliHEmpty" createVehicle _posUnit ;
_invisibleTarget setPos [(_posUnit select 0)+20,_posUnit select 1+20,20];

_unit doTarget _invisibleTarget;
//Replace <FlareName> with the desired flare.
sleep 1;
_unit fire "<FlareName>";

Edited by Benny.

Share this post


Link to post
Share on other sites

Here is the script I made for my Domination version. It uses ACE and some parameters set in other scripts etc, but I think you can be able to figure out something based on it. This script caused enemies to randomly fire flares at night when we were detected, and the units had to have some flares in their inventory. As it is ACE, you need to find the proper classnames. I ran tabs to spaces for proper indents:

private ["_unit","_check","_leader","_flarechance","_mags","_one_flare","_one_flare_muzzle"];
_unit = _this select 0;
_check = false;
_flarechance = 0.6;
_enemylist = [];
while {alive _unit} do{
   if (flarefired) then {sleep 10.123 + (random 10)};
   _leader = leader _unit;
   {
       if(_leader knowsAbout _x >= 0.7) then
       {
           _check = true;
           sleep 1.123;
       };
   } forEach list tEastAriAllEnemies;

   if (_check && !flarefired && (random 1 < _flarechance) && !(call fn_isDay)) then {
       _one_flare = "";
       _mags = magazines _unit;
       {
           scopeName "xxxx1";
           if (_x in d_flarelist) then {
               _one_flare = _x;
               breakOut "xxxx1";
           };
       } forEach _mags;
       sleep 3.345;
       if (!flarefired && alive _unit) then {
           if (_one_flare != "") then {
               flarefired = true;
               sleep 1.234;
               _one_flare_muzzle = "ACE_GP25Muzzle";
               _unit selectWeapon _one_flare_muzzle;
               _unit doWatch [getPos _unit select 0, getPos _unit select 1, 200];
               sleep 1.234;
               _unit fire [_one_flare_muzzle, _one_flare_muzzle, _one_flare];
               sleep 31.234;
               if (random 1 < 0.7) then {_unit addMagazine (d_flarelist select (floor random count d_flarelist));};
           };
       }
       else {
           flarefired = false;
       };
       sleep 30;
   };
   sleep 1 + (random 1);
   flarefired = false;
};

It has problems that might not be obvious, and could probably be optimized, but it worked ok for me.

Share this post


Link to post
Share on other sites

This is crazy...

My inventory is like this

1 AK_74_GL

3 FlareRed_GP25

3 1Rnd_HE_GP25

If I use this command:

_unit fire ["AK_74_GL","GP25Muzzle","GP25Muzzle","1Rnd_HE_GP25"];

Then my unit is shooting 3 HE rounds on the target. then no more

If I use this command:

_unit fire ["AK_74_GL","GP25Muzzle","GP25Muzzle","FlareRed_GP25"];

Then he do the same, 3 rounds of HE

If I use this command:

_unit fire ["AK_74_GL","FlareRed_GP25","FlareRed_GP25","FlareRed_GP25"];

He does the same thing

The I try to put away the HE rounds and only have Red Flare rounds in my inventory,

and then I try all three commands again...

result was that he did not fire a single shot... he did nothing.

3 hours have I put down on this, so now its time to take a brake...

If someone have a commandline that will do that a unit will shoot up a flare in the sky then post it here....

Its for ArmA 2...

Thanks

Share this post


Link to post
Share on other sites

This works................ but i used west weapons... Just replace "weapons" with what ever class name

example mission crappy rapidshare only lets 10 downloads so if anyone needs it after 10 downloads just pm me

Example Mission Using Triggers

//Replace unit1 with the unit name. or just name your unit unit1
_unit = unit1;

_posUnit = getPos _unit;
//HeliHEmpty is on Arma2
_invisibleTarget = "HeliHEmpty" createVehicle _posUnit ;
_invisibleTarget setPos [(_posUnit select 0)+20,_posUnit select 1+20,20];

_unit doTarget _invisibleTarget;
//Replace <FlareName> with the desired flare.
sleep 1;
_flare_muzzle = "M203Muzzle";
_flare = "FlareRed_M203";
_unit selectWeapon _flare_muzzle;
_unit fire [_flare_muzzle, _flare_muzzle, _flare];

you have to add the flares to the unit like this addmagazine flarered_m203

Edited by binkster

Share this post


Link to post
Share on other sites

Binkster, I take it that is a script you wrote that is launched in a trigger or init.sqf? to make the script more generic for any unit just use an array.

_unit = _this select 0;
_flare_muzzle = _this select 1;
_flare =  _this select 2;

_posUnit = getPos _unit;
//HeliHEmpty is on Arma2
_invisibleTarget = "HeliHEmpty" createVehicle _posUnit ;
_invisibleTarget setPos [(_posUnit select 0)+20,_posUnit select 1+20,20];

_unit doTarget _invisibleTarget;
sleep 1;
_unit selectWeapon _flare_muzzle;
_unit fire [_flare_muzzle, _flare_muzzle, _flare];

then the init would be

wep = [unitname,"muzzle of weapon","flare mag"] execVM "Myflarescript.sqf"

Untested but should work. This way you define the variables in the array and the script could even be used for other weapons, again untest but should be setup for that. For the "muzzle of weapon" and "Flare mag" make sure you have the "". If you need an example mission I could whip one up.

Share this post


Link to post
Share on other sites

I just combined the top two scripts above to make it work there is example running either in the unit init or trigger init.

Share this post


Link to post
Share on other sites

Thanks, got it to work now, sometimes he fire 2 flare and sometimes 1 flare... I have like 4 waypoint for him, and I have triggerd them with this script:

//Replace <Unit> with the unit name.
_unit = flareman;
_posUnit = getPos _unit;
//HeliHEmpty is on ArmA 1, don't know if it's still working on ArmA 2, otherwise just another one.
_invisibleTarget = "HeliHEmpty" createVehicle _posUnit ;
_invisibleTarget setPos [(_posUnit select 0)+20,_posUnit select 1+20,20];
_unit doTarget _invisibleTarget;
//Replace <FlareName> with the desired flare.
sleep 1;
_flare_muzzle = "GP25Muzzle";
_flare = "FlareWhite_GP25";
_flare_mag = "FlareWhite_GP25";
//_flare_mag = "FlareRed_GP25";
_unit selectWeapon _flare_muzzle;
sleep 1;
_unit addmagazine _flare_mag;
sleep 1;
_unit fire [_flare_muzzle, _flare_muzzle, _flare];

Now... I use this init on the flareman

[this] exec "scripts\gear_flareguy.sqs";

and that is the gear for this man...

But I wonder now, can I do like a script to define the same gear for all vehicle="RU_Soldier_GL"; in the game, so all get the gear, then I dont need to put

[this] exec "scripts\gear_flareguy.sqs";

in all init places on all that kind of units.

Is there any thread obout this, and what should I looking for?

All this is just for singleplayer and singleplayer missions only.

I would like to learn how to put the same gear on every class that got the same rank, or are the same class and so on.

And I looked at this:

private ["_unit","_check","_leader","_flarechance","_mags","_one_flare","_one_flare_muzzle"];
_unit = _this select 0;
_check = false;
_flarechance = 0.6;
_enemylist = [];



while {alive _unit} do{
   if (flarefired) then {sleep 10.123 + (random 10)};
   _leader = leader _unit;
   {
       if(_leader knowsAbout _x >= 0.7) then
       {
           _check = true;
           sleep 1.123;
       };
   } forEach list tEastAriAllEnemies;

   if (_check && !flarefired && (random 1 < _flarechance) && !(call fn_isDay)) then {
       _one_flare = "";
       _mags = magazines _unit;
       {
           scopeName "xxxx1";
           if (_x in d_flarelist) then {
               _one_flare = _x;
               breakOut "xxxx1";
           };
       } forEach _mags;
       sleep 3.345;
       if (!flarefired && alive _unit) then {
           if (_one_flare != "") then {
               flarefired = true;
               sleep 1.234;
               _one_flare_muzzle = "GP25Muzzle";
               _unit selectWeapon _one_flare_muzzle;
               _unit doWatch [getPos _unit select 0, getPos _unit select 1, 200];
               sleep 1.234;
               _unit fire [_one_flare_muzzle, _one_flare_muzzle, _one_flare];
               sleep 31.234;
               if (random 1 < 0.7) then {_unit addMagazine (d_flarelist select (floor random count d_flarelist));};
           };
       }
       else {
           flarefired = false;
       };
       sleep 30;
   };
   sleep 1 + (random 1);
   flarefired = false;
};

But never got it to work, dont know where to put this code. I am new to this arma 2 editor and arma/arma2 game.

At the end I would like to be able to create a mission, let say a mission on the night, and then I would like to put the same gear on every unit that is the same kind of unit. And if any of the units that got flare in there inventory find me ingame, they are automatic randomly shoot up a flare in the air.

And If I understand it right this code should do something like that on every unit that have the Private rank?

Share this post


Link to post
Share on other sites
This is crazy...

My inventory is like this

1 AK_74_GL

3 FlareRed_GP25

3 1Rnd_HE_GP25

If I use this command:

_unit fire ["AK_74_GL","GP25Muzzle","GP25Muzzle","1Rnd_HE_GP25"];

Then my unit is shooting 3 HE rounds on the target. then no more

If I use this command:

_unit fire ["AK_74_GL","GP25Muzzle","GP25Muzzle","FlareRed_GP25"];

Then he do the same, 3 rounds of HE

If I use this command:

_unit fire ["AK_74_GL","FlareRed_GP25","FlareRed_GP25","FlareRed_GP25"];

He does the same thing

The I try to put away the HE rounds and only have Red Flare rounds in my inventory,

and then I try all three commands again...

result was that he did not fire a single shot... he did nothing.

3 hours have I put down on this, so now its time to take a brake...

If someone have a commandline that will do that a unit will shoot up a flare in the sky then post it here....

Its for ArmA 2...

Thanks

i think your syntax is wrong.

for the flare it should be

_unit fire ["GP25Muzzle","GP25Muzzle","FlareRed_GP25"];

thats how it worked for me iirc

Share this post


Link to post
Share on other sites

I am looking for a script to make an enemy AI on patrol fire when they detect Blufor. I guess I could just use their position and spawn a flare above them. But they have a HUGE patrol distance and the detect Blufor trigger would be a monster. If I group the trigger to that patrol only they should be able to activate it right? Anyone know a better way to get patrols to fire flares from any point, not just waypoints etc?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×