Jump to content
Sign in to follow this  
madrussian

Manual Fire On/Off - Any way to detect when on or off?

Recommended Posts

I'm working on a dispersion mod, and need to be able to detect whether each round was fired by a player or an AI. I've got most of the logic in place. (Way more complicated than it should need to be.) But I've hit one final hurdle. To finish this thing...

I really need a way to detect whether Manual Fire is on or off (when a given vehicle fires).

Any help is much appreciated. :)

Share this post


Link to post
Share on other sites

eventhandle fired ?

not sure how this works with 2 players in a vehicle "gunner/pilot"

but only the player is returned as "gunner" if AI is gunner. so a bummer there

Edited by nuxil

Share this post


Link to post
Share on other sites

Thanks for the response. I am indeed using the fired event handler, and have overcome some huge obstacles already. Namely, you can get at the shooter, like this:

_shooter = _this select 0;

At this point you don't know whether the shooter is a man or vehicle but that can be determined like this:

_onFoot = false;
if (_shooter isKindOf "Man") then
{
_onFoot = true;
};

If he's on foot, I simply do an (isPlayer _shooter) to determine whether he is a player or not.

However, if _shooter is a vehicle, the issue immediately becomes you don't know exactly who inside the vehicle fired the shot.

Indeed, when _shooter is a vehicle, it turns out that (isPlayer _shooter) will always return true provided there is at least one player inside. So I had to get creative and pull the weapon values from the config for the particular vehicle type and compare them against the weapon the eventhandler provides. And then once you consider special turrets (gunners other than the "gunner" and "commander" positions), it's gets really hairy figuring out who fired the shot, but it's turns out it wasn't impossible after all.

In any event, I've currently got all that logic working, and can now determine with 100% certainty whether a player actually fired the shot or not.

There's just one thing left...

If the player is in maunal fire mode and shoots, it causes his AI to fire as expected. But especially in air units, the player is really doing the aiming at that point, so I'd like to treat it as a special case and assume the player actually fired the shot.

And so it comes down to one final thing:

I need to determine whether the vehicle is in "Manual Fire On" mode or not.

Unfortunately, I'm at a bit of a loss at the moment. :confused:

Share this post


Link to post
Share on other sites

you cant afik.. its the same with autohover.

no function or command in arma that returns this.

the only thing you can do is toggle manual fire on/off with action same goes for autohover.

maybe you can hack around a bit..

make it so a keypress function that listens to the firebutton.. so if a driver/pilot presses the button and a shot is fired. well you know manual fire is on

Share this post


Link to post
Share on other sites

Interesting suggesting on the keys. Based on past experience, that would probably require ArmALib (not out for ArmA2 yet) and an external program... probably too much of a hack indeed.

So in keeping things a bit more simple...

If worst comes to worst, for Air vehicles, I will simply check to see if if either the pilot(driver) -or- the main gunner is a player. (i.e. The player cannot control any of the special turret gunners via "Manual Fire On" anyway). The only known issue will be that if the AI main gunner in air vehicles fires, pilot is a player, and "Manual Fire" is off, my system will choose a dispersion method other than the correct one as defined in my purpose-built settings file.

Shouldn't be the end of the world, but still, if anyone knows a way we haven't thought of to detect "Manual Fire On", I'm all ears!

Share this post


Link to post
Share on other sites

Wouldn't hasweapon or hasmagazine change when he has control?

Share this post


Link to post
Share on other sites

Hadn't tried that. :)

However, with the following code:

_anyoneHaveWeap = false;
{
   if (_x hasWeapon _weapon) then
   {
       _anyoneHaveWeap = true;
   };
} foreach (crew _shooter);

hint format ["_anyoneHaveWeap : %1", _anyoneHaveWeap ];

Unfortunately, _anyoneHaveWeap always comes back false, provided _shooter is a vehicle.

When I simply try (_shooter hasWeapon _weapon) and _shooter is a vehicle, it always returns true, which makes sense. The vehicle always does have the weapon that got fired.

So the mystery of how to detect "Manual Fire On/Off" remains unsolved... :confused:

Share this post


Link to post
Share on other sites

I didnt meant you should use any 3rd part apps.

arma already has a "KeyLogger" :p

i was more tinking of usind the displayAddEventHandler command along with the fire event.

anyway. here is a quick and dirty example . to show you what i meant.

// need a sleep for displayAddEventHandler to work.
WaitUntil {!IsNull (FindDisplay 46)};
HELI = _this;

_firebuttonon = (findDisplay 46) displayAddEventHandler ["MouseButtonDown","call {if (_this select 1 == 0) then {call mfuncseton}} "];
_firebuttonoff = (findDisplay 46) displayAddEventHandler ["MouseButtonUp","call {if (_this select 1 == 0) then {call mfuncsetoff}} "];
vehicle HELI addeventhandler ["fired","[driver vehicle HELI] call mfunc "];

mfuncseton = 
{	
HELI setvariable ["MFire",true];
};

mfuncsetoff = 
{	
HELI setvariable ["MFire",false];
};

mfunc = 
{	
_test =HELI getvariable "MFire";
if ((_test) && (isPlayer driver HELI)) then
{
	HELI vehiclechat "Manual fire must be on";
};
};

this is far from perfect code.. you need to mess around a bit with it,

you can test it by putting a heli "AH1Z" empty. name it HELI.

and on the HELI init you put something like

MFC = this execvm "ManualFireCheck.sqf"

Edited by nuxil

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  

×