Hard Light Productions Forums

Modding, Mission Design, and Coding => The Scripting Workshop => Topic started by: JCDNWarrior on September 10, 2016, 02:19:54 pm

Title: Hovertank Turret Control
Post by: JCDNWarrior on September 10, 2016, 02:19:54 pm
While modding using BP2, I noticed that the included Dakota Hovertank could be a pretty interesting ship/tank to control for a few specific mission types. Sadly, when testing I noticed that its biggest cannon was AI-controlled, so I couldn't have WW2-esque tank battles nor shoot down aircraft 'above' the Hovertank by my own hands.

I would like to be able to take control over this turret and aim it like one would in usual tank games, in a full 360 circle at the same Y plane and all the way upwards for anti-aircraft purposes. The more aiming freedom, the better.

To avoid having the tank go and fly up and move around like an aircraft while aiming and firing that turret, the player would likely give up any other control over the tank so that it's either standing still and vulnerable or the AI can take over if the Scripter/FREDer prefers so it fulfills a set path in the meantime. Then, with the press of a hotkey, the player would return to the original 'driver seat' being able to figure the other, forward weapons, with easy switching between 'gunner' and 'driver' seat.

It would be even more interesting if the player could still accelerate and decelerate/go backwards manually though that would be an added bonus, since I'm not sure if that's possible/easy to program.


Also, I made a little recording in a quickly made test map showing what it's like to pilot these without any modification (except increased speed): https://youtu.be/vC1zqSQTd6s
This was done to hopefully make what I mean more visually apparent.

Spoiler:
If this is easily accomplished in FRED2 already, my apologies, in that case the thread can be moved to there instead. I think it requires a bit of extra scripting though.
Title: Re: Hovertank Turret Control
Post by: Chromatix on October 04, 2016, 12:04:33 am
In actual tank games, there are independent controls for aiming the gun and driving the vehicle.

In World of Tanks and Armoured Warfare, that's WASD for driving (also R and F for cruise control), and mouselook for aiming.  You get to choose whether you're in a first-person "gunner view" or a third-person "external view", but the controls remain the same in both cases.  You can also "auto-aim" at a target (without lead) by right-clicking on it, and you can look around without moving the turret by holding the right mouse button.

Translating that into Freespace terms, the most obvious controls would be using the joystick to fly (as normal) and mouselook to aim.  Both, however, are devices that most players strongly prefer to use right-handed.  I think you're going to find it very difficult to make this seem natural, regardless of any programming difficulties.

More fundamentally, all terrestrial tanks I'm aware of are at least dual-manned, at minimum a driver and a gunner - the latter being a higher position, also acts as commander and radioman if there's nobody else to do it for him.  The original Renault FT, being the first turreted tank, established this pattern.  A Panzer IV had a typical "large tank" crew of driver, gunner, loader, radioman and commander; some tanks with really big guns had two loaders, one for the shell and one for the propellant.  Some modern tanks have eliminated the loader and/or radioman, due to modern technology simplifying or even automating these tasks.

The point is that driving and gunnery are independent tasks which are difficult to combine in one person.  Tank games manage this by simplifying both tasks considerably.
Title: Re: Hovertank Turret Control
Post by: AdmiralRalwood on October 04, 2016, 03:44:08 am
Translating that into Freespace terms, the most obvious controls would be using the joystick to fly (as normal) and mouselook to aim.  Both, however, are devices that most players strongly prefer to use right-handed.  I think you're going to find it very difficult to make this seem natural, regardless of any programming difficulties.
And those programming difficulties are nothing to sneeze at; currently, the mouse and joystick assignments overlap (mouse X/Y axes and joystick X/Y axes are assigned together; IIRC left mouse = joystick button 1, right mouse = joystick button 2, etc.). So not only would you have to put in the effort of allowing independent movement and aiming, but then you'd have to decouple the mouse input from the joystick input (which, to be fair, is mostly a problem on the configuration side; the actual inputs are handled separately, they're just conflated by FSO's controls code).
Title: Re: Hovertank Turret Control
Post by: m!m on October 04, 2016, 05:37:05 am
I wrote a script (http://www.hard-light.net/forums/index.php?topic=75021.0) that allows to control a turret. You could adapt the turret code for aiming the turret since that's a little involved since FSO isn't exactly built for this sort of things.
Title: Re: Hovertank Turret Control
Post by: JCDNWarrior on October 04, 2016, 08:33:21 am
Thanks for the responses!

Chromatix, good points, if all else fails I can just make sure that in such missions the automatic turret represents a fellow pilot/gunner in the ship.

AdmiralRalwood, thanks for the additions, I suppose there's room to look for alternative solutions? I'm thinking of the example of old PC co op games where two players would use the same keyboard, such as WASD versus something like (i think) IJKL. NUMPAD already being used well for camera and alternate movement, of course.

m!m, thanks for linking and writing the script, didn't know it already existed. I'll start testing with it and see if it fits my requirements well enough for this purpose and adapt where I need (Though I'm not too experienced with coding).

I'll update findings later when I'm able to test it out as well. Meanwhile I'm open for any other suggestions, ideas and attempts at achieving this.