Ambu5h

Relation between ARMA 3 groups and Exile party's/Families

8 posts in this topic

I am currently scripting a script that moves players to an AI controlled aircraft.

Couple of issues i ran into, if the payer is in a different group then the AI the AI WILL automaticly land. They ALWAYS do this.
Tipical arma AI lacking the ability to turn this function off (FSM, TARGET etc is all disabled).

So i recoded it such that when the player gets put into the vehicle, the AI is assigned to the same group as the player.
Then it wont trigger then landing procedure since they are in the same group, and the AI will continue normaly on its path.

This works perfect for single player.... not so much for MP.

Say player 1 joins the aircraft... both aircraft and AI are assigned to his group.
Now player 2 joins. Again both aircraft and AI are assigned to THAT players group.

Thus there is 1 vehicle, 1 AI and 1 player in that group. And 1 player that is no longer in the same group.
This will again trigger the pilot to start landing or use evasive maneuvres since there are 2 groups pressent in the aircraft.

Now my question is... can i, instead of changing the aircraft/AI's group to the players group. Change the player to the group of the AI?
Will this work in relation to the Exile parties/families or will it remove them from their current party?

Here is the code im trying to get working. Works fine, but just for 1 player with 1 group.

Spoiler

{
    if (!isPlayer _x  &&  name _x == "DropshipDennis" && (typeOf vehicle _x) == "Exile_Plane_BlackfishInfantry") then // If it is only an AI piloting a Blackfish
    {        
        vehicle _x setFuel 1;                                                                   // Make sure he doesnt run out.
        
//        while {(count (waypoints group _bambiPlayer)) > 0} do
//        { deleteWaypoint ((waypoints group _bambiPlayer) select 0); };

        group _bambiPlayer copyWaypoints group _x;                                              // Copy AI waypoints over to players group (wont mater for players i hope?)
        _currentWP = currentWaypoint group _x;                                                    // Get current active waypoint for continuing current path
        
        group _bambiPlayer addVehicle vehicle _x;                                              // Change vehicle group to players group
        [_x] joinSilent group _bambiPlayer;                                                  // Change the group of the AI to players group.
        
        [group _bambiPlayer, _bambiPlayer] remoteExec ["selectLeader", groupOwner group _x]; // make AI nunit the leader, if you dont do this the AI will land automaticly .
                                                                                             // This is becouse the player gets TP'ed into the vehicle and thus automaticly triggers the getout command.
        group _bambiPlayer setCurrentWaypoint [group _bambiPlayer, _currentWP];                 // Set the active waypoint to where it was previously.
        group _x setCurrentWaypoint [group _x, _currentWP];                                     // Just double it up to make sure it works (for some reson it didnt always work, now it does)
        
        _bambiPlayer assignAsCargo vehicle _x;                                                  // Assign player as cargo
        _bambiPlayer moveInCargo vehicle _x;                                                  // Move player into cargo
        
        {
            [group _bambiPlayer, _x] setWaypointVisible false;                                 // Make the waypoints invisible on the map (sometimes players keep ownership and can then edit the waypoints)
        } foreach waypoints _bambiPlayer;
        
        vehicle _x flyInHeight 500;                                                          // Set minimum fly height to 500 meters. High enough for parachute jump
        vehicle _x setUnloadInCombat [false, false];                                          // Disable the AI from triggering landing procedure.
    };
} foreach allunits;


Im trying to make a battle royale type spawnpoint (aircraft flying specific waypoints across the map).
This will allow players to jump out whenever the aircraft is in the most favorable position for their wishes.

If i get this to work flawlessly i will post it in the scripts section for everyone to use.

Edited by Ambu5h

Share this post


Link to post
Share on other sites

@Ambu5h

Yeah. Changing the players group will remove them from their current party.

Store the current group of the player when they enter the vehicle (can use getIn/getOut event handlers to trigger this), Switch them to the AI group, once the player has decided where they're going and gets out, reassign them to their original group.

Not exactly clean.... but... eh... Arma.

  • Like 1

Share this post


Link to post
Share on other sites
Advertisement
On 18-3-2017 at 7:06 AM, Mezo said:

@Ambu5h

Yeah. Changing the players group will remove them from their current party.

Store the current group of the player when they enter the vehicle (can use getIn/getOut event handlers to trigger this), Switch them to the AI group, once the player has decided where they're going and gets out, reassign them to their original group.

Not exactly clean.... but... eh... Arma.

Thanks for the responce!
I thought that would happen and this would be the way to avoid the problem.
However, how do i do this?

In ExileServer_object_player_createBambi.sqf i make sure to move the player into the vehicle however how do i parse this to a get out trigger on that aircraft?
Do i manually add a global variable to the player with his previous party and then trigger a getout function on that vehicle with addMPEventHandlers?

Im completely new to most of the scripting parts of arma 3 so im looking for the tips and tricks (aka functions) in the coding to use.
After reading through thousands of lines of code from other mods, scripts and addons im prety fermiliar with the syntax and general functions but the knowledge of avoiding obstacles (like my current one) is kind of lacking behind :p.

Share this post


Link to post
Share on other sites

Right.... Here goes.

So....

You need to assign the getIn event handler to the vehicle.

_vehicle addEventHandler ["getIn", {_this call FUNCTION};}];

The unit that triggered the GetIn can be accessed through the call arguments from the eventhandler.

_unit = _this select 2;

the group of a unit can be accessed by:

group _unit;

You want to store the the group they're in, and then change them over to your AI Group.

You can then add another event handler to the same vehicle "getOut"

and have that function put them back in the group they were originally by doing something like

player join _oldGroup;

_oldGroup could be stored as a variable on the player object or even just a global client variable.

There's way too much to be done here to sit there and go through it line-to-line. But this should give you a rough idea.

  • Like 2

Share this post


Link to post
Share on other sites
On 22-3-2017 at 7:10 PM, Mezo said:

Right.... Here goes.

So....

You need to assign the getIn event handler to the vehicle.


_vehicle addEventHandler ["getIn", {_this call FUNCTION};}];

The unit that triggered the GetIn can be accessed through the call arguments from the eventhandler.


_unit = _this select 2;

the group of a unit can be accessed by:


group _unit;

You want to store the the group they're in, and then change them over to your AI Group.

You can then add another event handler to the same vehicle "getOut"

and have that function put them back in the group they were originally by doing something like


player join _oldGroup;

_oldGroup could be stored as a variable on the player object or even just a global client variable.

There's way too much to be done here to sit there and go through it line-to-line. But this should give you a rough idea.

Yes thank you!!!
Exacly the info that i was looking for, also exacly what i had in mind already :p.

Will try, and release as soon as possible.

  • Like 1

Share this post


Link to post
Share on other sites

Alright here i am again.
Some things seem to have changed.

If i am in a family the AI will fly normaly and continue on. If im in a party my party gets reset and since the old party gets destroyed (if 1 plyr) i cant recall the old party from a player bound variable.

Sooo i figured lets just skip this part (where i recall the previous party) and just assign a new group to the player always on the getout command.

Well... that worked fairly fine. But only if the player is in a family, if hes only in a party, he gets a new party (group).
So Exile parties are directly linked to the group.

Now.... some strange things are happening. Lets just forget about the exile parties to simplify what im seeing.
When a player is in a family, he gets put into the pilot's group. Nothing changes... plane flies normaly and continues its waypoints. Player stays in the family aswell.
Second player from a different family dies, gets put into the plane, again nothing changes. Plane flies normaly through its waypoints.
Players can eject whenever they want, no issues here. Works as advertised.

NOW IF the player is NOT in a family (again, wether he is in a group/party doesnt seem to make any difference).
The plane flies on to the next waypoint and then just keeps circling. The triggering of waypoint completion never occurs.
I tried adding,

group _x setCurrentWaypoint [group _x, (currentWaypoint group _x)];

_x refers to the AI pilot. Just to make sure the AI pilot has a defined next waypoint to reach. But again, the waypoint completion is never triggered and it will just keep circling endlessly on the waypoint its suppose to complete.

If i goto debug console, request the amount of waypoints and the current set waypoint it will always give me the right answer.
10 waypoints set <-- correct.
# Current waypoint <-- correct, depending on where he was flying ofcourse.

Just to setup a simple analogy of what is happening. You are driving a car with navigation from point a to b to c, you pickup 1 out of 2 twins. And depending on which of the 2 twins you picked up, your navigation just shuts off at the next town???!?!???

If you dont have a family, the AI never completes its waypoint (checked the variables from the debug console and they seem just fine).
The aircraft will then just keep endlessly circling unless i manually run the next piece of code in the debug console (exec global):

{ 
if (!isPlayer _x && (typeOf vehicle _x) == "Exile_Plane_BlackfishInfantry") then    
{  
group _x setCurrentWaypoint [group _x, (currentWaypoint group _x)+1];
};  
} foreach allunits;

If you have a family, variables stay exacly the same as the point above but the waypoint completion works just fine and the plane just keeps going as advertised.

Now the weird thing is, if families are linked to groups i can see why it doesnt complete this. Since you are in a different family then the AI. But what seems to be happening is the exact opposite.

I hope i was clear enough in explaining what is happening since its a bit hard to explain in detail.
Below are the 3 pieces of code i use to spawn the aircraft, insert bambi into the aircraft and trigger a getout when the player ejects out.

Spawning (yes this can be simplified):

Spoiler

diag_log "SPAWN AIRCRAFT LOADING!";
 
if (!isServer) exitWith{};
 
private [
"_wayPoints",
"_side",
"_airCraft",
"_group"
];
 
_wayPoints = [
        [2879.42, 12604.6, 600],
        [2333.56, 6964.26, 600],
        [4579.37, 2323.64, 600],
        [11660.4, 3145.45, 600],
        [9910.64, 7165.81, 600],
        [6149.39, 10765.3, 600],
        [14199,   13850.1, 600],
        [7867.51, 14851.2, 600]
];        //Waypoints for spawn craft to fly.

_side           = createCenter resistance;
_group           = createGroup _side;
[_wayPoints select 0, 90,"Exile_Plane_BlackfishInfantry", _group] call BIS_fnc_spawnVehicle;
 
diag_log "SPAWN AIRCRAFT CREATED!";

_airCraftSelection = nearestObjects [_wayPoints select 0, ["air"], 100];
_airCraft = _airCraftSelection select 0;

if(!isNull _airCraft) then
{
    _airCraft setCombatMode "BLUE";
    _airCraft allowDamage false;
    _airCraft flyInHeight 500;
    _airCraft setUnloadInCombat [false, false];
    
    _airCraft addBackpackCargoGlobal ["sab_parachute_pack", 8];
    _airCraft addBackpackCargoGlobal ["B_I_Parachute_02_F", 8];
    _airCraft addBackpackCargoGlobal ["B_Parachute", 8];
    _airCraft addBackpackCargoGlobal ["sab_parachute_wwi_bp", 8];
    _airCraft addBackpackCargoGlobal ["sab_parachute_wwi_bp_o", 8];
    _airCraft addBackpackCargoGlobal ["sab_parachute_wwi_bp_2", 8];
    _airCraft addBackpackCargoGlobal ["CUP_T10_Parachute_backpack", 8];
    
    _group    addVehicle _airCraft;
    
    _vehicleRoles = (typeOf _airCraft) call bis_fnc_vehicleRoles;
    {
        _safeSpawn = [_wayPoints select 0, 20, 40, 15, 0, 20, 0] call BIS_fnc_findSafePos;
        _vehicleRole = _x select 0;
        _vehicleSeat = _x select 1;
        
        // Add a pilot
        if(_vehicleRole == "Driver") then
        {
            //_unit = [_group, _safeSpawn, "random", "difficult", "EAST", "Vehicle", []] call DMS_fnc_SpawnAISoldier;
            _units = [_safeSpawn, _side, 1] call BIS_fnc_spawnGroup;
            
            {
                _x setCombatMode "BLUE";
                _x setBehaviour "CARELESS";
                _x setName "DropshipDennis";
                                        
                _x disableAI "FSM";
                _x disableAI "ANIM";
                _x disableAI "TARGET";
                _x disableAI "THREAT_PATH";
                _x disableAI "AUTOTARGET";
                _x disableAI "AUTOCOMBAT";
                _x disableAI "COVER";
                _x disableAI "SUPPRESSION";
                _x allowFleeing 0;
                _x setSkill 1;
                _x allowCrewInImmobile true;

                _x assignAsDriver _airCraft;
                _x moveInDriver _airCraft;
                
                _x allowDamage false;
                
                [_x] joinSilent _group;
                
                diag_log format["SPAWN AIRCRAFT Added Driver! - Side:%1 - Role:%2 - Vehicle:%3", _side, _vehicleRole, typeOf _airCraft];
            } forEach units _units;
        };
    } forEach _vehicleRoles;

    // Add all waypoints
    {
        _wp = _group addWaypoint [_x, 0];
        _wp setWaypointType "MOVE";
        _wp setWaypointBehaviour "CARELESS";
        _wp setWaypointspeed "NORMAL";
        _wp setWaypointCompletionRadius 400;
        _wp setWaypointVisible false;
        _wp showWaypoint "NEVER";
        
        diag_log format["SPAWN AIRCRAFT Added waypoint %1", _x];
        
    }foreach _wayPoints;
    
    // Set first waypoint as cycle position
    _wpcycle = _group addWaypoint [_wayPoints select 0, 0];
    _wpcycle setWaypointType "CYCLE";
    _wpcycle setWaypointBehaviour "CARELESS";
    _wpcycle setWaypointspeed "NORMAL";
    _wpcycle setWaypointCompletionRadius 400;
    _wpcycle setWaypointVisible false;
    _wpcycle showWaypoint "NEVER";
    
    _airCraft addMPEventHandler ["getout", "_this call Spawn_fnc_getOut;"];
    _airCraft addEventHandler ["getout", "_this call Spawn_fnc_getOut;"];
};
 

 


ExileServer_object_player_createBambi.sqf: (Left out the default stuff since i only added to it and did not modify)

Spoiler

if (_spawnLocationMarkerName == "Aircraft") then
{
    {                                                                                                                      // Scroll through all AI units
        if (!isPlayer _x  &&  name _x == "DropshipDennis" && (typeOf vehicle _x) == "Exile_Plane_BlackfishInfantry") then // If it is only an AI piloting a Blackfish
        {        
            vehicle _x setFuel 1;                                                                   // Make sure he doesnt run out. If, atleast, someone dies within the hour.

            diag_log format["SPAWN AIRCRAFT Player chose for aircraft spawn: %1 - %2", name _bambiPlayer, group _bambiPlayer];
            
//            _bambiPlayer setVariable ["oldGroupForSpawn", group _bambiPlayer];
            [_bambiPlayer] joinSilent group _x;
            
            _bambiPlayer assignAsCargo vehicle _x;                                                  // Assign player as cargo
            _bambiPlayer moveInCargo vehicle _x;                                                  // Move player into cargo
            
            vehicle _x flyInHeight 500;                                                          // Set minimum fly height to 500 meters. High enough for parachute jump
            vehicle _x setUnloadInCombat [false, false];                                          // Disable the AI from triggering landing procedure.

            group _x setCurrentWaypoint [group _x, (currentWaypoint group _x)];
            
        };
    } foreach allunits;
};


getOut.sqf: (Function being triggered by the aircraft when someone ejects)
Kind of useless at the moment since i dont reset the party of the player back to its previous party.

Spoiler

_unit     = _this select 0;
_vehicle = vehicle _unit;
_player  = _this select 2;

diag_log format["SPAWN AIRCRAFT Player jumped, vehicle:%1 - Player:%2", typeOf _vehicle, name _player];

if ((typeOf _vehicle) == "Exile_Plane_BlackfishInfantry"  &&  isPlayer _player) then
{
    diag_log format["SPAWN AIRCRAFT Player jumped: %1 - Current group: %2", name _player, group _player];
    
    _side         = createCenter resistance;
    _newgroup     = createGroup _side;
    [_player] joinSilent _newgroup;
    
    group _unit setCurrentWaypoint [group _unit, (currentWaypoint group _unit)];
    
    diag_log format["SPAWN AIRCRAFT Group was lost, created new group! unit:%1  plyr:%2", group _unit, group _player];
};


Yes, code looks like shit. But thats what you get when your trying out dozens of different ways to acomplish a seamingly simple job.
But then again... this is ARMA. Nothing is simple as suppose to be.

ALL of this effort only to find out. "disableAI" does NOT disable AI responce what so ever. No mater what function i disable.

Edited by Ambu5h

Share this post


Link to post
Share on other sites

@Mezo
Any chance you can help me further with this? Sorry for the tag, but been waiting for a while to get an answer on both here and armaholic :p.
Ive been trying around alot with the script and the result seems to always be the same.
If a player is in a family the plane does exacly what its suppose to do. (fly its waypoints and keep cycling them).
But when a player is NOT in a family the plane just starts circling at its next set waypoint. Completion of that waypoint never triggers.
Both player and AI Pilot are in the same group at all times (from spawn up untill getout command).

Edited by Ambu5h

Share this post


Link to post
Share on other sites
Advertisement

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.