Jump to content

Multiple AI factions


Grahame

Recommended Posts

Hi All,

   I rationalized the siding of players to purely use BLUFOR on my primary server and things seem to work well. I thought I would provide the details here in case anyone else was interested in freeing OPFOR for another AI faction (on EpochZ: Black Tide this change allows the infected to attack and eat the roaming, dynamic and mission AI).

The changes themselves are fairly easy.

epoch_server.PBO

In compile/epoch_player/EPOCH_server_loadPlayer.sqf:

Change line 65 from

_class = "Epoch_Male_F";

to

// _class = "Epoch_Male_F";

In init/server_init.sqf:

Change lines 94 and 95 from

EAST setFriend[WEST, 1];

WEST setFriend[EAST, 1];

to

WEST setFriend [EAST, 0];

EAST setFriend [WEST, 0];

Now, these changes alone will make all players BLUFOR (females) and free OPFOR and RESISTANCE for use by two AI factions. There are, of course issues. The first is that all players are now female by default and will remain so until the siding is possibly removed from the CfgVehicles.hpp definition for EPOCH_Female_F and EPOCH_Male_F.

The changes do work well if you have Haljv's Black Market traders and Initial Gear and HALO Spawn scripts. The reason for that is both force uniforms on your character so you can select any uniform and as soon as you have you will regain your ARMA profile "face".

If you are allowing players to use any uniforms with these scripts then you can prevent them being deleted at respawn, restart or revive by making the following changes (also in the epoch_server.PBO).

In compile/epoch_player/EPOCH_server_loadPlayer.sqf:

Change line 181 from

_newPlyr addUniform _uniform;

to

_newPlyr forceAddUniform _uniform;

In compile/epoch_player/EPOCH_server_revivePlayer.sqf:

Change line 162 from

_newPlyr addUniform _uniform;

to

_newPlyr forceAddUniform _uniform;

Hope this helps,

Cheers,

Grahame.

 

Link to comment
Share on other sites

  • 2 months later...
  • 3 months later...

for anybody else, this will save you sometime

BLUFOR uniform class-names

 a3 and epoch

U_Rangemaster
U_Competitor
U_B_survival_uniform
U_B_GEN_Soldier_F
U_B_GEN_Commander_F
U_BG_Guerilla1_1
U_BG_Guerilla2_1
U_BG_Guerilla2_2
U_BG_Guerilla2_3
U_BG_Guerilla3_1
U_BG_Guerilla3_2
U_BG_Guerrilla_6_1
U_CamoBlue_uniform
U_CamoBrn_uniform
U_CamoRed_uniform
U_CamoAloha_uniform
U_CamoBiker_uniform
U_CamoBubblegum_uniform
U_CamoLumberjack_uniform
U_CamoOutback_uniform
U_CamoPink_uniform
U_CamoPinkPolka_uniform
U_Wetsuit_uniform
U_Wetsuit_White
U_Wetsuit_Blue
U_Wetsuit_Purp
U_B_CombatUniform_mcam
U_B_CombatUniform_mcam_tshirt
U_B_CombatUniform_mcam_vest
//U_B_CombatUniform_sgg			// no good, it no work..... 
U_B_CombatUniform_sgg_tshirt	 
U_B_CombatUniform_sgg_vest		 
//U_B_CombatUniform_wdl			// no good, it no work.....
//U_B_CombatUniform_wdl_tshirt	// no good, it no work.....
//U_B_CombatUniform_wdl_vest	// no good, it no work.....
U_B_CTRG_Soldier_F
U_B_CTRG_Soldier_2_F
U_B_CTRG_Soldier_3_F
U_B_CTRG_1
U_B_CTRG_2
U_B_CTRG_3
U_BG_leader
U_B_SpecopsUniform_sgg
U_B_HeliPilotCoveralls
U_B_PilotCoveralls
U_B_T_Soldier_AR_F
U_B_T_Soldier_F
U_B_T_Soldier_SL_F
U_B_CTRG_Soldier_urb_1_F
U_B_CTRG_Soldier_urb_2_F
U_B_CTRG_Soldier_urb_3_F
U_Camo_uniform
U_Wetsuit_Camo
U_B_T_Sniper_F
U_B_GhillieSuit
U_B_FullGhillie_lsh
U_B_FullGhillie_sard
U_B_FullGhillie_ard
U_B_T_FullGhillie_tna_F
U_ghillie1_uniform
U_ghillie2_uniform
U_ghillie3_uniform
U_B_Wetsuit

 

Link to comment
Share on other sites

  • 8 months later...
On 11/30/2016 at 5:38 PM, Grahame said:

Hi All,

   I rationalized the siding of players to purely use BLUFOR on my primary server and things seem to work well. I thought I would provide the details here in case anyone else was interested in freeing OPFOR for another AI faction (on EpochZ: Black Tide this change allows the infected to attack and eat the roaming, dynamic and mission AI).

The changes themselves are fairly easy.

epoch_server.PBO

In compile/epoch_player/EPOCH_server_loadPlayer.sqf:

Change line 65 from

_class = "Epoch_Male_F";

to

// _class = "Epoch_Male_F";

In init/server_init.sqf:

Change lines 94 and 95 from

EAST setFriend[WEST, 1];

WEST setFriend[EAST, 1];

to

WEST setFriend [EAST, 0];

EAST setFriend [WEST, 0];

Now, these changes alone will make all players BLUFOR (females) and free OPFOR and RESISTANCE for use by two AI factions. There are, of course issues. The first is that all players are now female by default and will remain so until the siding is possibly removed from the CfgVehicles.hpp definition for EPOCH_Female_F and EPOCH_Male_F.

The changes do work well if you have Haljv's Black Market traders and Initial Gear and HALO Spawn scripts. The reason for that is both force uniforms on your character so you can select any uniform and as soon as you have you will regain your ARMA profile "face".

If you are allowing players to use any uniforms with these scripts then you can prevent them being deleted at respawn, restart or revive by making the following changes (also in the epoch_server.PBO).

In compile/epoch_player/EPOCH_server_loadPlayer.sqf:

Change line 181 from

_newPlyr addUniform _uniform;

to

_newPlyr forceAddUniform _uniform;

In compile/epoch_player/EPOCH_server_revivePlayer.sqf:

Change line 162 from

_newPlyr addUniform _uniform;

to

_newPlyr forceAddUniform _uniform;

Hope this helps,

Cheers,

Grahame.

 

It appears the EPOCH_server_revivePlayer.sqf is significantly different now.
 

/*
    Author: Aaron Clark - EpochMod.com

    Contributors: He-Man

    Description:
    Player Login

    Licence:
    Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike

    Github:
    https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_player/EPOCH_server_loadPlayer.sqf
*/
//[[[cog import generate_private_arrays ]]]
private ["_Primary","_CheckLocation","_allGroupMembers","_alreadyDead","_assignedItems","_attachments","_backpack","_backpackItems","_canBeRevived","_class","_communityStats","_communityStatsArray","_currentWeapon","_deadPlayer","_defaultData","_dir","_equipped","_found","_goggles","_group","_handgunWeapon","_headgear","_instanceID","_jammer","_jammers","_linkedItems","_loadout","_location","_newLocation","_newPlyr","_playerData","_playerGroup","_playerGroupArray","_playerNetID","_playerUID","_primaryWeapon","_reject","_secondaryWeapon","_serverSettingsConfig","_type","_uniform","_uniformItems","_vars","_vest","_vestItems","_wMags","_wMagsArray","_weapon"];
//[[[end]]]
_reject = true;

params [["_player",objNull,[objNull]],["_isMale",true],["_fsmHandle",0],["_playerData",[]]];

if (!isNull _player) then {

    // load server settings
    _serverSettingsConfig = configFile >> "CfgEpochServer";
    _instanceID = call EPOCH_fn_InstanceID;

    _playerNetID = owner _player;
    _playerUID = getPlayerUID _player;

    if (_playerUID != "") then {

        if (_playerdata isequalto []) then {
            // Make Hive call
            (["Player", _playerUID] call EPOCH_fnc_server_hiveGETRANGE) params [
                ["_status", 0 ],
                ["_playerDataTmp", [] ]
            ];
            if (_status == 1 && _playerDataTmp isEqualType []) then {
                _playerData = _playerDataTmp;
            };
        };
        
        // Apperance defaults
        _uniform = [_serverSettingsConfig, "defaultUniformFemale", "U_Test_uniform"] call EPOCH_fnc_returnConfigEntry;
        _class = "Epoch_Female_F";
        _vest = [_serverSettingsConfig, "defaultVestFemale", "V_F41_EPOCH"] call EPOCH_fnc_returnConfigEntry;
        if (_isMale) then {
            _uniform = [_serverSettingsConfig, "defaultUniformMale", "U_Test1_uniform"] call EPOCH_fnc_returnConfigEntry;
            _class = "Epoch_Male_F";
            _vest = [_serverSettingsConfig, "defaultVestMale", "V_41_EPOCH"] call EPOCH_fnc_returnConfigEntry;
        };
        _goggles = [_serverSettingsConfig, "defaultGoggles", ""] call EPOCH_fnc_returnConfigEntry;
        _headgear = [_serverSettingsConfig, "defaultHeadgear", ""] call EPOCH_fnc_returnConfigEntry;
        _backpack = [_serverSettingsConfig, "defaultBackpack", ""] call EPOCH_fnc_returnConfigEntry;

        // Inventory defaults
        _primaryWeapon = [_serverSettingsConfig, "defaultprimaryWeapon", []] call EPOCH_fnc_returnConfigEntry;    // ["arifle_MX_pointer_F","","acc_pointer_IR","",["30Rnd_65x39_caseless_mag",29],[],""];
        _secondaryWeapon = [_serverSettingsConfig, "defaultsecondaryWeapon", []] call EPOCH_fnc_returnConfigEntry;  // ["launch_NLAW_F","","","",["NLAW_F",1],[],""];
        _handgunWeapon = [_serverSettingsConfig, "defaulthandgunWeapon", []] call EPOCH_fnc_returnConfigEntry;    // ["hgun_P07_F","","","",["16Rnd_9x21_Mag",16],[],""];
        _uniformItems = [_serverSettingsConfig, "defaultuniformItems", []] call EPOCH_fnc_returnConfigEntry;     // [["FAK",1],["30Rnd_65x39_caseless_mag",2,30],["Chemlight_green",1,1]];
        _vestItems = [_serverSettingsConfig, "defaultvestItems", []] call EPOCH_fnc_returnConfigEntry;        // [["30Rnd_65x39_caseless_mag",3,30],["16Rnd_9x21_Mag",2,16],["SmokeShell",1,1],["SmokeShellGreen",1,1],["SmokeShellBlue",1,1],["SmokeShellOrange",1,1],["Chemlight_green",1,1]];
        _backpackItems = [_serverSettingsConfig, "defaultbackpackItems", []] call EPOCH_fnc_returnConfigEntry;    // [["Medikit",1],["FAK",10],[["hgun_P07_F","","","",["16Rnd_9x21_Mag",16],[],""],1]];
        _assignedItems = [_serverSettingsConfig, "defaultassignedItems", ["","","","",[],[],""]] call EPOCH_fnc_returnConfigEntry; // ["Rangefinder","","","",[],[],""]
        _linkedItems = [_serverSettingsConfig, "defaultlinkedItems", ["ItemMap","","EpochRadio0","","",""]] call EPOCH_fnc_returnConfigEntry; // ["ItemMap","ItemGPS","ItemRadio","ItemCompass","ItemWatch","NVGoggles"]
        _currentWeapon = [_serverSettingsConfig, "defaultSelectedWeapon", ""] call EPOCH_fnc_returnConfigEntry; // class of selected weapon

        _loadout = [
            _primaryWeapon,
            _secondaryWeapon,
            _handgunWeapon,
            [_uniform,_uniformItems],
            [_vest,_vestItems],
            [_backpack,_backpackItems],
            _headgear,
            _goggles,
            _assignedItems,
            _linkedItems
        ];

        // default data, if "Player" data format is changed update this array!
        _defaultData = [[0, [], _instanceID, 1.0], [0, 0, 1, 0, [0,0,0,0,0,0,0,0,0,0,0]], ["", "", "", "", _currentWeapon, _class], [], call EPOCH_defaultVars_SEPXVar, _loadout, [], [], [], [], "", true];

        // If data does not validate against default or is too short, override with default data.
        if !(_playerData isEqualTypeParams _defaultData) then {
            diag_log format["DEBUG: Invaild player data %1, defaults used instead.", _playerData];
            _playerData = _defaultData;
        };

        _playerData params ["_worldspace","_medical","","_server_vars","_vars","","","","","","_playerGroup","_canBeRevived"];

        // Load world space and previous instance id
        _worldspace params ["_dir","_location","_prevInstance",["_schemaVersion",0.5]];

        if (count _location == 2) then{
            _location = (_location select 0) vectorAdd (_location select 1);
        };

        // Get player group
        _playerGroupArray = [];
        // check players group
        if (_playerGroup != "") then {
            _found = false;
            (["Group", _playerGroup] call EPOCH_fnc_server_hiveGETRANGE) params [
                ["_status", 0 ],
                ["_playerGroupArrayTmp", [] ]
            ];
            if (_status == 1 && !(_playerGroupArrayTmp isEqualTo[])) then {
                _playerGroupArrayTmp params ["","","","_modArray","_memberArray"];
                _found = _playerGroup == _playerUID;
                if (!_found) then {
                    _allGroupMembers = (_modArray + _memberArray) apply {_x select 0};
                    _found = _playerUID in _allGroupMembers;
                };
                if (_found) then {
                    _playerGroupArray = _playerGroupArrayTmp;
                };
            };
            if (!_found) then {
                _playerGroup = "";
            };
            // diag_log format["DEBUG (Load Player) Set Group: %1", _playerGroup];
        };

        _medical params ["_bleedingRemaining","_fatigue","_oxygenRemaining","_damage",["_hitpoints",[0,0,0,0,0,0,0,0,0,0,0]] ];

        _deadPlayer = ["PlayerStats", _playerUID, 0] call EPOCH_fnc_server_hiveGETBIT;

        // check if player is already dead or was critically hit HitHead = 2 or HitBody = 7 and if blood pressure too high.
        _alreadyDead = (_deadPlayer || (_damage == 1) || (_hitpoints select 2 == 1) || (_hitpoints select 7 == 1) || (_vars select 12 >= 180));

        if (_alreadyDead || _prevInstance != _instanceID || (count _location) < 3 || !(_location isEqualType [])) then {
            // reset hitpoints
            _hitpoints = [0,0,0,0,0,0,0,0,0,0,0];
            _dir = random 360;
            // try to find respawn point by position
            _newLocation = _server_vars param [0,[]]; // 0 = RESPAWN POS
            // normal respawn location
            _location = getMarkerPos "respawn_west";
            _location set[2, 0];
            if (_newLocation isEqualType [] && {(count _newLocation) == 3}) then {
                _CheckLocation = _newLocation;
                if (surfaceiswater _newLocation) then {
                    _CheckLocation = ATLToASL _newLocation;
                };
                _jammers = nearestObjects[_CheckLocation, ["PlotPole_EPOCH"], 6];
                if !(_jammers isEqualTo[]) then {
                    // get nearby object
                    _jammer = _jammers param [0,objNull];
                    // check if object is not null and is alive.
                    if (!isNull _jammer && {alive _jammer}) then {
                        // check if player is still a member of object group.
                        if ((_jammer getVariable["BUILD_OWNER", "-1"]) in [_playerUID, _playerGroup]) then {
                            // Override location with that of object
                            _location = _newLocation;
                        };
                    };
                };
            };
            if (_alreadyDead) then {
                _vars = call EPOCH_defaultVars_SEPXVar;
                _canBeRevived = true;
            };
        };

        _group = grpNull;

        // find existing group
        if (_playerGroup != "") then {
            {
                if ((_x getVariable["GROUP", ""]) == _playerGroup) exitWith{
                    _group = group _x;
                };
            } forEach (allPlayers select {alive _x});
        };

        if (isNull _group) then {
            _group = createGroup [west, true];
        };

        _newPlyr = _group createUnit[_class, getMarkerPos "respawn_west", [], 0, "CAN_COLLIDE"];
        _newPlyr hideobjectglobal true;
        if !(isNull _newPlyr) then {

            // disable AI on temp unit
            _newPlyr disableAI "ALL";

            if (!_alreadyDead) then {
                // Medical
                _newPlyr setBleedingRemaining _bleedingRemaining;
                // _newPlyr setFatigue _fatigue;
                _newPlyr setOxygenRemaining _oxygenRemaining;
                _newPlyr setDamage _damage;
            } else {
                // player dead use default Data for appearance and loadout data
                _playerData = _defaultData;
            };

            // disable further damage server side
            _newPlyr allowDamage false;

            // set player loadout
            _playerData params ["","","_appearance","","","_loadout"];
            // get current weapon to send to param for selectWeapon
            _currentWeapon = _appearance param [4,""];
//                _newPlyr setUnitLoadout [_loadout, false];

            // Workaround for Client / Server synchronizing issue in SetUnitLoadout
            _loadabs = [_newPlyr,_loadout] call Epoch_server_SetUnitLoadout;
            if (_loadabs isequalto -1) then {
                deleteVehicle _newPlyr;
            };

            // Final Push
            if (isNull _player) then {
                deleteVehicle _newPlyr;
                diag_log "Epoch: DEBUG: _player object was null reject connection";
            } else {

                // add to cleanup
                addToRemainsCollector[_newPlyr];

                _reject = false;

                if (_playerGroup != "") then {
                    _newPlyr setVariable["GROUP", _playerGroup];
                };

                _newPlyr setVariable["PUID", _playerUID];

                if !(_vars isEqualTo[]) then {
                    _newPlyr setVariable["VARS", _vars];
                };

                if !(_server_vars isEqualTo[]) then{
                    _newPlyr setVariable["SERVER_VARS", _server_vars];
                };

                if (!_canBeRevived) then {
                    _newPlyr setVariable["REVIVE", _canBeRevived];
                };

                // load community stats
                _communityStatsArray = ["CommunityStats", _playerUID] call EPOCH_fnc_server_hiveGETRANGE;
                _communityStats = (_communityStatsArray param [1,[]]) param [0,[]];
                _newPlyr setVariable["COMMUNITY_STATS", _communityStats];

                // Flag new body as ready for use.
                _newPlyr setVariable["FinalDest", [_location,_dir], true];

                // Send message to player so they can take over the new body.
                [_playerNetID, _playerUID, [_newPlyr, _vars, _currentWeapon, _loadabs, _playerGroup, _canBeRevived, _newPlyr call EPOCH_server_setPToken,_playerGroupArray, _communityStats, _hitpoints], _fsmHandle, _player] call EPOCH_server_pushPlayer;

                // revive test
                _newPlyr setVariable ['#rev_enabled', true, true];
                // [] remoteExec ["bis_fnc_reviveInit",_player];

                // new Dynamicsimulation
                if([configFile >> "CfgEpochServer", "playerDynamicSimulationSystem", true] call EPOCH_fnc_returnConfigEntry)then
                {
                    _newPlyr enableDynamicSimulation true;
                    _newPlyr triggerDynamicSimulation true;
                };
            };
        } else {
            diag_log format["LOGIN FAILED UNIT NULL: %1 [%2|%3]", _player, _group, count allgroups];
        };
    };
};


if (_reject) then {
    diag_log format ["DEBUG PLAYER NOT SETUP OR INVAILD: %1", _player];
    true remoteExec ['EPOCH_client_rejectPlayer',_player];
};

true

 

Found the male class...

        // Apperance defaults
        _uniform = [_serverSettingsConfig, "defaultUniformFemale", "U_Test_uniform"] call EPOCH_fnc_returnConfigEntry;
        _class = "Epoch_Female_F";
        _vest = [_serverSettingsConfig, "defaultVestFemale", "V_F41_EPOCH"] call EPOCH_fnc_returnConfigEntry;
        if (_isMale) then {
            _uniform = [_serverSettingsConfig, "defaultUniformMale", "U_Test1_uniform"] call EPOCH_fnc_returnConfigEntry;
            _class = "Epoch_Male_F";
            _vest = [_serverSettingsConfig, "defaultVestMale", "V_41_EPOCH"] call EPOCH_fnc_returnConfigEntry;
        };

I assume that the above code for _class = "Epoch_Male_F"; is the correct one to comment out?

 

Also I am unable to locate _newPlyr addUniform _uniform; in the EPOCH_server_loadPlayer.sqf or EPOCH_server_revivePlayer.sqf

 

EPOCH_server_loadPlayer.sqf

/*
    Author: Aaron Clark - EpochMod.com

    Contributors: He-Man

    Description:
    Player Login

    Licence:
    Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike

    Github:
    https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_player/EPOCH_server_loadPlayer.sqf
*/
//[[[cog import generate_private_arrays ]]]
private ["_Primary","_CheckLocation","_allGroupMembers","_alreadyDead","_assignedItems","_attachments","_backpack","_backpackItems","_canBeRevived","_class","_communityStats","_communityStatsArray","_currentWeapon","_deadPlayer","_defaultData","_dir","_equipped","_found","_goggles","_group","_handgunWeapon","_headgear","_instanceID","_jammer","_jammers","_linkedItems","_loadout","_location","_newLocation","_newPlyr","_playerData","_playerGroup","_playerGroupArray","_playerNetID","_playerUID","_primaryWeapon","_reject","_secondaryWeapon","_serverSettingsConfig","_type","_uniform","_uniformItems","_vars","_vest","_vestItems","_wMags","_wMagsArray","_weapon"];
//[[[end]]]
_reject = true;

params [["_player",objNull,[objNull]],["_isMale",true],["_fsmHandle",0],["_playerData",[]]];

if (!isNull _player) then {

    // load server settings
    _serverSettingsConfig = configFile >> "CfgEpochServer";
    _instanceID = call EPOCH_fn_InstanceID;

    _playerNetID = owner _player;
    _playerUID = getPlayerUID _player;

    if (_playerUID != "") then {

        if (_playerdata isequalto []) then {
            // Make Hive call
            (["Player", _playerUID] call EPOCH_fnc_server_hiveGETRANGE) params [
                ["_status", 0 ],
                ["_playerDataTmp", [] ]
            ];
            if (_status == 1 && _playerDataTmp isEqualType []) then {
                _playerData = _playerDataTmp;
            };
        };
        
        // Apperance defaults
        _uniform = [_serverSettingsConfig, "defaultUniformFemale", "U_Test_uniform"] call EPOCH_fnc_returnConfigEntry;
        _class = "Epoch_Female_F";
        _vest = [_serverSettingsConfig, "defaultVestFemale", "V_F41_EPOCH"] call EPOCH_fnc_returnConfigEntry;
        if (_isMale) then {
            _uniform = [_serverSettingsConfig, "defaultUniformMale", "U_Test1_uniform"] call EPOCH_fnc_returnConfigEntry;
            //_class = "Epoch_Male_F";
            _vest = [_serverSettingsConfig, "defaultVestMale", "V_41_EPOCH"] call EPOCH_fnc_returnConfigEntry;
        };
        _goggles = [_serverSettingsConfig, "defaultGoggles", ""] call EPOCH_fnc_returnConfigEntry;
        _headgear = [_serverSettingsConfig, "defaultHeadgear", ""] call EPOCH_fnc_returnConfigEntry;
        _backpack = [_serverSettingsConfig, "defaultBackpack", ""] call EPOCH_fnc_returnConfigEntry;

        // Inventory defaults
        _primaryWeapon = [_serverSettingsConfig, "defaultprimaryWeapon", []] call EPOCH_fnc_returnConfigEntry;    // ["arifle_MX_pointer_F","","acc_pointer_IR","",["30Rnd_65x39_caseless_mag",29],[],""];
        _secondaryWeapon = [_serverSettingsConfig, "defaultsecondaryWeapon", []] call EPOCH_fnc_returnConfigEntry;  // ["launch_NLAW_F","","","",["NLAW_F",1],[],""];
        _handgunWeapon = [_serverSettingsConfig, "defaulthandgunWeapon", []] call EPOCH_fnc_returnConfigEntry;    // ["hgun_P07_F","","","",["16Rnd_9x21_Mag",16],[],""];
        _uniformItems = [_serverSettingsConfig, "defaultuniformItems", []] call EPOCH_fnc_returnConfigEntry;     // [["FAK",1],["30Rnd_65x39_caseless_mag",2,30],["Chemlight_green",1,1]];
        _vestItems = [_serverSettingsConfig, "defaultvestItems", []] call EPOCH_fnc_returnConfigEntry;        // [["30Rnd_65x39_caseless_mag",3,30],["16Rnd_9x21_Mag",2,16],["SmokeShell",1,1],["SmokeShellGreen",1,1],["SmokeShellBlue",1,1],["SmokeShellOrange",1,1],["Chemlight_green",1,1]];
        _backpackItems = [_serverSettingsConfig, "defaultbackpackItems", []] call EPOCH_fnc_returnConfigEntry;    // [["Medikit",1],["FAK",10],[["hgun_P07_F","","","",["16Rnd_9x21_Mag",16],[],""],1]];
        _assignedItems = [_serverSettingsConfig, "defaultassignedItems", ["","","","",[],[],""]] call EPOCH_fnc_returnConfigEntry; // ["Rangefinder","","","",[],[],""]
        _linkedItems = [_serverSettingsConfig, "defaultlinkedItems", ["ItemMap","","EpochRadio0","","",""]] call EPOCH_fnc_returnConfigEntry; // ["ItemMap","ItemGPS","ItemRadio","ItemCompass","ItemWatch","NVGoggles"]
        _currentWeapon = [_serverSettingsConfig, "defaultSelectedWeapon", ""] call EPOCH_fnc_returnConfigEntry; // class of selected weapon

        _loadout = [
            _primaryWeapon,
            _secondaryWeapon,
            _handgunWeapon,
            [_uniform,_uniformItems],
            [_vest,_vestItems],
            [_backpack,_backpackItems],
            _headgear,
            _goggles,
            _assignedItems,
            _linkedItems
        ];

        // default data, if "Player" data format is changed update this array!
        _defaultData = [[0, [], _instanceID, 1.0], [0, 0, 1, 0, [0,0,0,0,0,0,0,0,0,0,0]], ["", "", "", "", _currentWeapon, _class], [], call EPOCH_defaultVars_SEPXVar, _loadout, [], [], [], [], "", true];

        // If data does not validate against default or is too short, override with default data.
        if !(_playerData isEqualTypeParams _defaultData) then {
            diag_log format["DEBUG: Invaild player data %1, defaults used instead.", _playerData];
            _playerData = _defaultData;
        };

        _playerData params ["_worldspace","_medical","","_server_vars","_vars","","","","","","_playerGroup","_canBeRevived"];

        // Load world space and previous instance id
        _worldspace params ["_dir","_location","_prevInstance",["_schemaVersion",0.5]];

        if (count _location == 2) then{
            _location = (_location select 0) vectorAdd (_location select 1);
        };

        // Get player group
        _playerGroupArray = [];
        // check players group
        if (_playerGroup != "") then {
            _found = false;
            (["Group", _playerGroup] call EPOCH_fnc_server_hiveGETRANGE) params [
                ["_status", 0 ],
                ["_playerGroupArrayTmp", [] ]
            ];
            if (_status == 1 && !(_playerGroupArrayTmp isEqualTo[])) then {
                _playerGroupArrayTmp params ["","","","_modArray","_memberArray"];
                _found = _playerGroup == _playerUID;
                if (!_found) then {
                    _allGroupMembers = (_modArray + _memberArray) apply {_x select 0};
                    _found = _playerUID in _allGroupMembers;
                };
                if (_found) then {
                    _playerGroupArray = _playerGroupArrayTmp;
                };
            };
            if (!_found) then {
                _playerGroup = "";
            };
            // diag_log format["DEBUG (Load Player) Set Group: %1", _playerGroup];
        };

        _medical params ["_bleedingRemaining","_fatigue","_oxygenRemaining","_damage",["_hitpoints",[0,0,0,0,0,0,0,0,0,0,0]] ];

        _deadPlayer = ["PlayerStats", _playerUID, 0] call EPOCH_fnc_server_hiveGETBIT;

        // check if player is already dead or was critically hit HitHead = 2 or HitBody = 7 and if blood pressure too high.
        _alreadyDead = (_deadPlayer || (_damage == 1) || (_hitpoints select 2 == 1) || (_hitpoints select 7 == 1) || (_vars select 12 >= 180));

        if (_alreadyDead || _prevInstance != _instanceID || (count _location) < 3 || !(_location isEqualType [])) then {
            // reset hitpoints
            _hitpoints = [0,0,0,0,0,0,0,0,0,0,0];
            _dir = random 360;
            // try to find respawn point by position
            _newLocation = _server_vars param [0,[]]; // 0 = RESPAWN POS
            // normal respawn location
            _location = getMarkerPos "respawn_west";
            _location set[2, 0];
            if (_newLocation isEqualType [] && {(count _newLocation) == 3}) then {
                _CheckLocation = _newLocation;
                if (surfaceiswater _newLocation) then {
                    _CheckLocation = ATLToASL _newLocation;
                };
                _jammers = nearestObjects[_CheckLocation, ["PlotPole_EPOCH"], 6];
                if !(_jammers isEqualTo[]) then {
                    // get nearby object
                    _jammer = _jammers param [0,objNull];
                    // check if object is not null and is alive.
                    if (!isNull _jammer && {alive _jammer}) then {
                        // check if player is still a member of object group.
                        if ((_jammer getVariable["BUILD_OWNER", "-1"]) in [_playerUID, _playerGroup]) then {
                            // Override location with that of object
                            _location = _newLocation;
                        };
                    };
                };
            };
            if (_alreadyDead) then {
                _vars = call EPOCH_defaultVars_SEPXVar;
                _canBeRevived = true;
            };
        };

        _group = grpNull;

        // find existing group
        if (_playerGroup != "") then {
            {
                if ((_x getVariable["GROUP", ""]) == _playerGroup) exitWith{
                    _group = group _x;
                };
            } forEach (allPlayers select {alive _x});
        };

        if (isNull _group) then {
            _group = createGroup [west, true];
        };

        _newPlyr = _group createUnit[_class, getMarkerPos "respawn_west", [], 0, "CAN_COLLIDE"];
        _newPlyr hideobjectglobal true;
        if !(isNull _newPlyr) then {

            // disable AI on temp unit
            _newPlyr disableAI "ALL";

            if (!_alreadyDead) then {
                // Medical
                _newPlyr setBleedingRemaining _bleedingRemaining;
                // _newPlyr setFatigue _fatigue;
                _newPlyr setOxygenRemaining _oxygenRemaining;
                _newPlyr setDamage _damage;
            } else {
                // player dead use default Data for appearance and loadout data
                _playerData = _defaultData;
            };

            // disable further damage server side
            _newPlyr allowDamage false;

            // set player loadout
            _playerData params ["","","_appearance","","","_loadout"];
            // get current weapon to send to param for selectWeapon
            _currentWeapon = _appearance param [4,""];
//                _newPlyr setUnitLoadout [_loadout, false];

            // Workaround for Client / Server synchronizing issue in SetUnitLoadout
            _loadabs = [_newPlyr,_loadout] call Epoch_server_SetUnitLoadout;
            if (_loadabs isequalto -1) then {
                deleteVehicle _newPlyr;
            };

            // Final Push
            if (isNull _player) then {
                deleteVehicle _newPlyr;
                diag_log "Epoch: DEBUG: _player object was null reject connection";
            } else {

                // add to cleanup
                addToRemainsCollector[_newPlyr];

                _reject = false;

                if (_playerGroup != "") then {
                    _newPlyr setVariable["GROUP", _playerGroup];
                };

                _newPlyr setVariable["PUID", _playerUID];

                if !(_vars isEqualTo[]) then {
                    _newPlyr setVariable["VARS", _vars];
                };

                if !(_server_vars isEqualTo[]) then{
                    _newPlyr setVariable["SERVER_VARS", _server_vars];
                };

                if (!_canBeRevived) then {
                    _newPlyr setVariable["REVIVE", _canBeRevived];
                };

                // load community stats
                _communityStatsArray = ["CommunityStats", _playerUID] call EPOCH_fnc_server_hiveGETRANGE;
                _communityStats = (_communityStatsArray param [1,[]]) param [0,[]];
                _newPlyr setVariable["COMMUNITY_STATS", _communityStats];

                // Flag new body as ready for use.
                _newPlyr setVariable["FinalDest", [_location,_dir], true];

                // Send message to player so they can take over the new body.
                [_playerNetID, _playerUID, [_newPlyr, _vars, _currentWeapon, _loadabs, _playerGroup, _canBeRevived, _newPlyr call EPOCH_server_setPToken,_playerGroupArray, _communityStats, _hitpoints], _fsmHandle, _player] call EPOCH_server_pushPlayer;

                // revive test
                _newPlyr setVariable ['#rev_enabled', true, true];
                // [] remoteExec ["bis_fnc_reviveInit",_player];

                // new Dynamicsimulation
                if([configFile >> "CfgEpochServer", "playerDynamicSimulationSystem", true] call EPOCH_fnc_returnConfigEntry)then
                {
                    _newPlyr enableDynamicSimulation true;
                    _newPlyr triggerDynamicSimulation true;
                };
            };
        } else {
            diag_log format["LOGIN FAILED UNIT NULL: %1 [%2|%3]", _player, _group, count allgroups];
        };
    };
};


if (_reject) then {
    diag_log format ["DEBUG PLAYER NOT SETUP OR INVAILD: %1", _player];
    true remoteExec ['EPOCH_client_rejectPlayer',_player];
};

true

 

EPOCH_server_revivePlayer.sqf

/*
    Author: Aaron Clark - EpochMod.com

    Contributors: He-Man

    Description:
    Player Revive

    Licence:
    Arma Public License Share Alike (APL-SA) - https://www.bistudio.com/community/licenses/arma-public-license-share-alike

    Github:
    https://github.com/EpochModTeam/Epoch/tree/release/Sources/epoch_server/compile/epoch_player/EPOCH_server_revivePlayer.sqf
*/
//[[[cog import generate_private_arrays ]]]
private ["_loadabs","_loadout","_CorpseCrypto","_PlayerCrypto","_attachments","_cIndex","_class","_currwh","_deleteprimary","_deletesecondary","_dir","_droppedPrimary","_droppedSecondary","_droppedWeapons","_equipped","_group","_garbage","_location","_newPlyr","_playerGroup","_playerUID","_token","_type","_vars","_wMags","_wMagsArray","_weapon","_wh","_kIndex","_reviver","_reviverCStats","_reviverKarma","_reviverKarmaAdj"];
//[[[end]]]
params ["_player","_reviver",["_token","",[""]] ];

if !([_reviver, _token] call EPOCH_server_getPToken) exitWith{};
if (isNull _player) exitWith{};
if (_player distance _reviver > 20) exitWith{};

if (!local _player) then {
    _playerUID = getPlayerUID _player;
    if (!isNil "_playerUID" && !alive _player) then {

        if (_player == _reviver) exitWith {
            'epochserver' callExtension format['820|%1|EpochMod.com Autoban #R1',getPlayerUID _reviver];
            ['ahb', format['%1 (%2): Tried to Revive yourself (%3)', name _reviver, getPlayerUID _reviver, _this]] call EPOCH_fnc_server_hiveLog;
        };

        _class = typeOf _player;

        if (_class in ["Epoch_Male_F", "Epoch_Female_F"]) then {

            if (_player getVariable["REVIVE", true]) then {
                if (_player getvariable ['Reviving', false]) exitwith {
                    diag_log format['DEBUG Reviving skipped - Player already reviving : %1', _this];
                };
                _player setvariable ['Reviving',true];

                diag_log format["DEBUG server_revivePlayer : %1", _this];

                _location = getPosATL _player;
                _dir = getDir _player;
                _playerGroup = _player getVariable["GROUP", ""];

                // Load Inventory
                _loadout = getUnitLoadout _player;

                _wh = nearestObjects[_player, ["WeaponHolderSimulated"], 12];
                _droppedPrimary = [];
                _droppedSecondary = [];
                _deleteprimary = [];
                _deletesecondary = [];
                reverse _wh;
                {
                    _currwh = _x;
                    {
                        _type = getNumber(configfile >> "cfgweapons" >> (_x select 0) >> "type");
                        switch _type do {
                            case 1: {_droppedPrimary = _x; _deleteprimary = [_currwh]};
                            case 4: {_droppedSecondary = _x; _deletesecondary = [_currwh]};
                        };
                    } forEach (weaponsItemsCargo _x);
                } foreach _wh;
                {
                    if (!isnull _x) then {deletevehicle _x};
                } foreach (_deleteprimary+_deletesecondary);
                if (count _droppedPrimary == 6) then {
                    _droppedPrimary set [6,_droppedPrimary select 5];
                    _droppedPrimary set [5,[]];
                
                };
                if (count _droppedSecondary == 6) then {
                    _droppedSecondary set [6,_droppedSecondary select 5];
                    _droppedSecondary set [5,[]];
                };

                hideObjectGlobal _player;

                // create new player unit change this class later
                _group = grpNull;
                if (_playerGroup != "") then {
                    {
                        if ((_x getVariable["GROUP",""]) == _playerGroup) exitWith {
                            _group = group _x;
                        };
                    }forEach (allPlayers select {alive _x});

                    if (isNull _group) then {
                        _group = createGroup [west, true];
                    };

                    diag_log format["DEBUG Group Found: %1", _group];
                } else {
                    _group = createGroup [west, true];
                    diag_log format["DEBUG Group Created: %1", _group];
                };

                _newPlyr = _group createUnit[_class, _location, [], 0, "CAN_COLLIDE"];

                // new Dynamicsimulation
                if([configFile >> "CfgEpochServer", "playerDynamicSimulationSystem", true] call EPOCH_fnc_returnConfigEntry)then
                {
                    _newPlyr enableDynamicSimulation true;
                    _newPlyr triggerDynamicSimulation true;
                };

                addToRemainsCollector[_newPlyr];

                _newPlyr disableAI "ALL";

                _newPlyr setVariable ["SETUP", true];
                _newPlyr setVariable ["PUID", _playerUID];
                _newPlyr setVariable ["GROUP", _playerGroup];
                _newPlyr setVariable ["REVIVE", false];
                _newPlyr setVariable ["SERVER_VARS",_player getVariable ["SERVER_VARS",[]]];

                // _player playActionNow "Die";

                _newPlyr setDir _dir;
                _newPlyr setPosATL _location;

                // Medical
                _newPlyr setFatigue 1;
                _newPlyr setDamage 0.25;

                // Add inventory
                _loadout set [0,_droppedPrimary];
                _loadout set [1,_droppedSecondary];
//                _newPlyr setUnitLoadout [_loadout, false];

                // Workaround for Client / Server synchronizing issue in SetUnitLoadout
                _loadabs = [_newPlyr,_loadout] call Epoch_server_SetUnitLoadout;
                if (_loadabs isequalto -1) exitwith {
                    removeFromRemainsCollector [_newPlyr];
                    deletevehicle _newPlyr;
                    _player setvariable ['Reviving',false];
                    _player hideObjectGlobal false;
                };

                _garbage = createVehicle [selectrandom ["MedicalGarbage_01_1x1_v1_F","MedicalGarbage_01_1x1_v3_F","MedicalGarbage_01_1x1_v2_F"], _location, [], 0, "CAN_COLLIDE"];
                EPOCH_cleanupQueue pushBack _garbage;

                // Final Push
                _token = _newPlyr call EPOCH_server_setPToken;

                _CorpseCrypto = _player getVariable['Crypto', 0];
                if (_CorpseCrypto > 0) then {
                    _cIndex = EPOCH_customVars find 'Crypto';
                    _vars = _player getVariable['VARS', call EPOCH_defaultVars_SEPXVar];
                    _PlayerCrypto = _CorpseCrypto;
                    _PlayerCrypto remoteExec ['EPOCH_effectCrypto',_player];
                    _vars set[_cIndex, _PlayerCrypto];
                    _newPlyr setVariable['VARS', _vars];
                };

                // send to player
                [_newPlyr, _token, _loadabs] remoteExec ['EPOCH_clientRevive',_player];

                // send stat to reviver
                [_reviver, "Revives", 1, true] call EPOCH_server_updatePlayerStats;
                
                // send karma stat to reviver
                _kIndex = EPOCH_communityStats find "Karma";
                _reviverCStats = _reviver getVariable["COMMUNITY_STATS", EPOCH_defaultStatVars];
                _reviverKarma = _reviverCStats select _kIndex;
                _reviverKarmaAdj = 5;
                if(_reviverKarma < 0)then{_reviverKarmaAdj = -5};
                [_reviver, "Karma", _reviverKarmaAdj, true] call EPOCH_server_updatePlayerStats;
            };
        };
    };
};

 

Edited by C4-timah
Link to comment
Share on other sites

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
  • Discord

×
×
  • Create New...