Jump to content
Ulfgaar

Controlling the AI driver for vehicles on dedicated servers?

Recommended Posts

Hello everyone.

I am the mission creator of a medium sized Arma 3 group. Our group is organized into 3 divisions, doing "their" kind of gameplay - being Spec.Ops, regular grunts and combined arms, and the air division.

I am looking for a way to let the combined arms group be able to utilize vehicles to a much larger exctent than what they currently can do, as any vehicle requires minimum 2, preferably 3 people to operate. If we want it to be an IFV, we're quickly looking at needing 9 people to fully man 1 IFV. This is currently leaving us with basicly just using 1 vehicle - where we would like to operate at least 2 or 3 in a group. 

Now, BI has apparently made it so that in singleplayer or in locally hosted games - that you can operate any vehicle from a gunner/commander position in the vehicle, as long as there is an AI in the driver seat (i.e. controlling the driver). As long as you do this in singleplayer/locally hosted games - the control of the vehicle is smoth and precise. Almost like driving a tank in the Battlefield series. However, when doing the same on a dedicated server the controls gets really wonky and the AI driver just simply cannot compute the same detail of control it seems. Where in singleplayer its basicly like driving any other vehicle yourself - while on the dedicated they can only make 40+ degree turns - which makes it impossible to even stay on a simple road.

Now, i fully understand that many people play this game for its realism - so do i - but the reason why i love this game is that it is first and foremost a sandbox, where you can form the game to fit your own needs and desires. My group is a MilSim group, but a casual one at that, and far from anything resembling "realsim". But that is our choice, and how we like to play Arma. We also only play vs AI's, having a Zeus controlling them for us during missions, which is set in an ongoing narrative and story which unfolds over several campaigns. Any reservations or opinions about the "overpoweredness" of being able to fill two roles of a tank as a single player is sort of void, because we're not looking at balance or pure realism in this sense - we're looking for a solution which enables more people of our group to have fun in our games (lets face it, if your stuck as the driver the entire game...you need to be a special kind of interested in driving, else it will be one long and boring mission, and we end up in a situation where "who needs to fall on the sword this mission to let everyone else have fun with a vehicle backing them up" kind of thing). 

For regular unarmored vehicles this is not going to be used, as those are for the most part just filling the role of transports - taking our players into the missions, being ditched at a safe place, upon where the mission begins. Often they need to go back to said vehicle to get out of the mission  - but as said, im looking for this primarily to free up player slots from the most unpopular role to have in any mission where armored vehicles are going to be used - the driver seat.

Im not looking for opinions, im looking for solutions, tips or tricks. Im glad BI has sorted this for singleplayer as such, but it seemingly does not work the same way on a dedicated server, which is what i need it to do.

Thanks for any advice, help or solutions you may provide me with!

//Ulfgaar

Share this post


Link to post
Share on other sites

I had this before. The delay is caused by network communication delays if the player client tells the AI which is located on server what it should do.

No workaround I know of if u want to have the AI located on server.

But what you can do is move the locality of the driver AI to the players client which gives the commands. This way you have no delay and the same experience as in SP.

 

EDIT: setOwner is the command for this.

Share this post


Link to post
Share on other sites

Alright, i guess this is what happens then when you remote control a unit using Zeus on a dedicated server. Because when i control AI vehicles as Zeus - you are placed as the gunner of said vehicles, but have detailed controls of the driver just like in singleplayer. 

I'll explore the "setOwner" command, but could you provide me of an Example of how it would look, and where to place it? As in, is it placed in the AI drivers init, or in the vehicle Init?

Also, thank you for the very rapid response to this!

//Ulfgaar

Share this post


Link to post
Share on other sites

I would do it with an getIn event handler which I would put on the vehicle. The event Handler should check if a player embarks the wanted seat and then moves the AIs locality to this player.

Which player is the one which commands the AI? Gunner or Commander or someone else? Maybe the first or the last player which enters the vehicle? I need some details of the situation to get a solution.

Share this post


Link to post
Share on other sites

I would like the control of the vehicle to be tied with the gunner, as they are the ones who need to have detailed control of the vehicle as such - so that they can "sneak above a hill" with their turret and know when to stop. 

The commander role will be preoccupied giving orders and keeping an eye on the surroundings, keeping in touch with HQ and the other vehicle commanders - while the gunner will be the executing part - both driving and gunning, if possible.

Do i need to place the vehicles in the editor having an AI driver placed, with gunner and commander slots vacant? Or does it requrie the vehicle to be "empty"?

As i am also building up a database for myself over all the things i've learned over the years in this game, commands wise - i would be very much appreciate if you could show me the different codes you would use to accomplish the things you've staded above. 

Such as:
AI controlled by Commander/Gunner.
AI controlled by last person in the vehicle.

Having the codes to edit for these two functions - will provide me with a powerful tool for content making in the future 🙂

Also, thank you so much for your help and effort!

//Ulfgaar

 

 

Share this post


Link to post
Share on other sites
_d = this addEventHandler ["GetIn", 
{
 params ["_vehicle", "_role", "_unit"];
 _role = toLower _role;
 _driver = driver _vehicle;
   
 if(!isServer || {!(isPlayer _unit) || {!(_role isEqualTo "gunner") || {isPlayer _driver}}}) exitWith{};
 
 _driver  setOwner (owner _unit);

}];

this is the solution for the gunner. you could just change "gunner" to "commander" to have the commander solution.

 

to be continued ...

 

EDIT: excluded execution if driver is a player

EDIT2: added dummy variable for init line usage, added missing semicolon

EDIT3: "then" deleted

Edited by sarogahtyp

Share this post


Link to post
Share on other sites
2 minutes ago, Ulfgaar said:

See edited post above.

 

dito

  • Like 1

Share this post


Link to post
Share on other sites

Still getting an error, seemingly the same, in spite of your edits 😞 . 

Share this post


Link to post
Share on other sites

beginner mistake... just delete the "then" right before "exitWith"

  • Like 2

Share this post


Link to post
Share on other sites

Did you edit it? As i cant see any "then"'?

If "then" is a term within coding, you must excuse me as im not speaking code very well.

Share this post


Link to post
Share on other sites
Just now, Ulfgaar said:

Did you edit it? As i cant see any "then"'?

I did

  • Like 1

Share this post


Link to post
Share on other sites

That certainly did the trick - no errors!

Thank you so much for your work and effort - very kind of you, and most helpful if it works as intended. 

Will make some tweaks to my mission, adding this - and then test it on my dedicated. Will check back to give the greenlight if all works as we hope 🙂.

Quite sure many others will be interested in this as well!

  • Like 1

Share this post


Link to post
Share on other sites
7 minutes ago, sarogahtyp said:

beginner mistake... just delete the "then" right before "exitWith"

If I had a £ for every time I did that....... 🙂

  • Haha 1

Share this post


Link to post
Share on other sites

Alright - i can confirm that this works as intended. 

Placing down an empty vehicle, then adding an AI driver to it - then copy pating this code into the vehicle init line, does the trick!

Just a note to you @sarogahtyp - no matter what role i get into, i can control the tank, either as gunner or as commander. Or is it so that when multiple players are inside, that it gives control of the driving to the gunner as priority?

Share this post


Link to post
Share on other sites

it works like if a player embarks the vehicle as gunner/commander (depends on used role in event handler)  then the AI gets controlled by it's client. There are no changes made which manipulate the commanding of the AI.

 

U have to differentiate here between which machine/client controls the AIs "intelligence" and which player  commands the AI to drive where and how ("move left, fast").

 

EDIT:

this means if u used "gunner" in event handler then u should not have a delay if u enter as gunner but if u enter as commander then the delay should occur.

  • Like 1

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

×