Jump to content
sneezemonkey

Piggyback shooting problem

Recommended Posts

Hi I'm trying to look for a solution that would allow any "Man" class object to shoot while "piggybacking" on another "Man" class object.

The problem is while attachTo allows unit to fire, it does not allow for unit to adjust view/aim. Is there any way to get freelook to work using this method?

Or could I define a usable turret class that isn't a "vehicle" vehicle? I'm away from my pc rn can't test.

 

Reason I'm asking is dbo_horses

Share this post


Link to post
Share on other sites

Use the in vehicle shooting system where you can raise your gun while sitting in a vehicle.

Make a invisible "chair" vehicle.

Place invisible chair vehicle onto the unit, sit in that chair, raise your gun.

Share this post


Link to post
Share on other sites

I was hoping to avoid that with a config/sqf based solution...

Will I need blender or can I just use bulldozer?

Share this post


Link to post
Share on other sites

ok I've tested keybindings and I have issues with attached objects (e.g. invisible chair) interfering with the "Carrier" unit from properly performing actions so that they can move Forward and back etc. 

I also have another issue with my keydown EH as it is preventing normal operation of other keys (like escape). I tried exitwith but that doesn't help. Any pointers appreciated.

my keyDown EH:

KeyDownEH = (findDisplay 46) displayAddEventHandler ["KeyDown", "
	params ['_displayorcontrol', '_key', '_shift', '_ctrl', '_alt'];
	_buddy = buddy; //placeholder code
	_keys = ['MoveForward', 'MoveBack', 'TurnLeft', 'TurnRight'];
	_keystate = [];
	{if (inputAction _x > 0) then {_keystate pushback 1} else {_keystate pushback 0}} forEach _keys;
	if (_shift) then {
		switch (true) do {
			case (_keystate select 0 > 0): {
				switch (true) do {
					case (_keystate select 2 > 0): {
						_dir = VectorDir _buddy;
						_newX = ((_dir select 0) * cos 2) - ((_dir select 1)* sin 2);
						_newY = ((_dir select 0) * sin 2) + ((_dir select 1)* cos 2);
						_buddy setVectorDir [_newX,_newY,_dir select 2];
						_buddy playActionNow 'WalkF';
					};
					case (_keystate select 3 > 0): {
						_dir = VectorDir _buddy;
						_newX = ((_dir select 0) * cos -2) - ((_dir select 1)* sin -2);
						_newY = ((_dir select 0) * sin -2) + ((_dir select 1)* cos -2);
						_buddy setVectorDir [_newX,_newY,_dir select 2];
						_buddy playActionNow 'FastF';
					};
					case (true): {_buddy playActionNow 'FastF'};
				}
			};
			case (_keystate select 1 > 0): {switch (true) do {
					case (_keystate select 2 > 0): {
						_dir = VectorDir _buddy;
						_newX = ((_dir select 0) * cos -2) - ((_dir select 1)* sin -2);
						_newY = ((_dir select 0) * sin -2) + ((_dir select 1)* cos -2);
						_buddy setVectorDir [_newX,_newY,_dir select 2];
						_buddy playActionNow 'FastB';
					};
					case (_keystate select 3 > 0): {
						_dir = VectorDir _buddy;
						_newX = ((_dir select 0) * cos 2) - ((_dir select 1)* sin 2);
						_newY = ((_dir select 0) * sin 2) + ((_dir select 1)* cos 2);
						_buddy setVectorDir [_newX,_newY,_dir select 2];
						_buddy playActionNow 'FastB';
					};
					case (true): {_buddy playActionNow 'FastB'};
				}
			};
			case (_keystate select 2 > 0): {
				_dir = VectorDir _buddy;
				_newX = ((_dir select 0) * cos 5) - ((_dir select 1)* sin 5);
				_newY = ((_dir select 0) * sin 5) + ((_dir select 1)* cos 5);
				_buddy playAction 'TurnL';
				_buddy setVectorDir [_newX,_newY,_dir select 2];
			};
			case (_keystate select 3 > 0): {
				_dir = VectorDir _buddy;
				_newX = ((_dir select 0) * cos -5) - ((_dir select 1)* sin -5);
				_newY = ((_dir select 0) * sin -5) + ((_dir select 1)* cos -5);
				_buddy playAction 'TurnR';
				_buddy setVectorDir [_newX,_newY,_dir select 2];
			};
		}
	} else {
		switch (true) do {
			case (_keystate select 0 > 0): {
				switch (true) do {
					case (_keystate select 2 > 0): {
						_dir = VectorDir _buddy;
						_newX = ((_dir select 0) * cos 5) - ((_dir select 1)* sin 5);
						_newY = ((_dir select 0) * sin 5) + ((_dir select 1)* cos 5);
						_buddy setVectorDir [_newX,_newY,_dir select 2];
						_buddy playActionNow 'WalkF';
					};
					case (_keystate select 3 > 0): {
						_dir = VectorDir _buddy;
						_newX = ((_dir select 0) * cos -5) - ((_dir select 1)* sin -5);
						_newY = ((_dir select 0) * sin -5) + ((_dir select 1)* cos -5);
						_buddy setVectorDir [_newX,_newY,_dir select 2];
						_buddy playActionNow 'WalkF';
					};
					case (true): {_buddy playActionNow 'WalkF'};
				}
			};
			case (_keystate select 1 > 0): {switch (true) do {
					case (_keystate select 2 > 0): {
						_dir = VectorDir _buddy;
						_newX = ((_dir select 0) * cos -5) - ((_dir select 1)* sin -5);
						_newY = ((_dir select 0) * sin -5) + ((_dir select 1)* cos -5);
						_buddy setVectorDir [_newX,_newY,_dir select 2];
						_buddy playActionNow 'WalkB';
					};
					case (_keystate select 3 > 0): {
						_dir = VectorDir _buddy;
						_newX = ((_dir select 0) * cos 5) - ((_dir select 1)* sin 5);
						_newY = ((_dir select 0) * sin 5) + ((_dir select 1)* cos 5);
						_buddy setVectorDir [_newX,_newY,_dir select 2];
						_buddy playActionNow 'WalkB';
					};
					case (true): {_buddy playActionNow 'WalkB'};
				}
			};
			case (_keystate select 2 > 0): {
				_dir = VectorDir _buddy;
				_newX = ((_dir select 0) * cos 5) - ((_dir select 1)* sin 5);
				_newY = ((_dir select 0) * sin 5) + ((_dir select 1)* cos 5);
				_buddy playAction 'TurnL';
				_buddy setVectorDir [_newX,_newY,_dir select 2];
			};
			case (_keystate select 3 > 0): {
				_dir = VectorDir _buddy;
				_newX = ((_dir select 0) * cos -5) - ((_dir select 1)* sin -5);
				_newY = ((_dir select 0) * sin -5) + ((_dir select 1)* cos -5);
				_buddy playAction 'TurnR';
				_buddy setVectorDir [_newX,_newY,_dir select 2];
			};
	}
}"];

 

Share this post


Link to post
Share on other sites

I got the keybindings to stop interfering by returning "_this"  for anyone who might encounter the same problem (I feel dumb for not realising). And have got the ai to move using doMove as well, though it is acting kind of temperamentally. Does anyone know a way I could just use playActionNow? I could do stuff with velocity vectors instead and what not but I would need to recreate collision detection so not workable. Also roads causes response issues even with FSM disabled (refuses to move sometimes) so any pointers there also appreciated. 

Share this post


Link to post
Share on other sites
On 10/17/2019 at 7:16 AM, sneezemonkey said:

 

I got the keybindings to stop interfering by returning "_this"

 

You are overriding the default key down handling by returning non false (normally you return true). This is well documented on EH pages

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

×