A3Wasteland / ArmA3_Wasteland.Altis

A3Wasteland is a survival sandbox mission for Arma 3 where two teams and independent players fight for survival. Built in collaboration between GoT, TPG, KoS, 404Games, and others.
http://a3wasteland.com
GNU Affero General Public License v3.0
102 stars 184 forks source link

R3F_ARTY_AND_LOG #397

Open ghost opened 8 years ago

ghost commented 8 years ago

Hey,

My self and a number of server owners as you know use R3F 3.1 and i for one would certainly use your heavily modified version of R3F_ARTY_AND_LOG if it wasn't for one key feature that's missing, the ability auto load objects in vehicles which is used for our airdrop systems, building base packs from the stores etc etc. Would you consider adding this to your version so we can swap back to using it ?

http://puu.sh/p3aRB/01b7f4c68d.png

`// charger_auto.sqf waitUntil { if (R3F_LOG_mutex_local_verrou) then { false } else { R3F_LOG_mutex_local_verrou = true; true } };

private ["_transporteur", "_liste_a_charger", "_chargement", "_chargement_actuel", "_chargement_maxi", "_objets_charges", "_cout_chargement_objet"]; private ["_objet_ou_classe", "_quantite", "_objet", "_classe", "_bbox", "_bbox_dim", "_pos_degagee", "_fonctionnalites", "_i"];

_transporteur = _this select 0; _liste_a_charger = _this select 1;

_chargement = [_transporteur] call R3F_LOG_FNCT_calculer_chargement_vehicule; _chargement_actuel = _chargement select 0; _chargement_maxi = _chargement select 1; _objets_charges = _transporteur getVariable ["R3F_LOG_objets_charges", []];

// Pour chaque élément de la liste à charger { if (typeName _x == "ARRAY" && {count _x > 0}) then { _objet_ou_classe = _x select 0;

    if (typeName _objet_ou_classe == "STRING" && count _x > 1) then
    {
        _quantite = _x select 1;
    }
    else
    {
        _quantite = 1;
    };
}
else
{
    _objet_ou_classe = _x;
    _quantite = 1;
};

if (typeName _objet_ou_classe == "STRING") then
{
    _classe = _objet_ou_classe;
    _bbox = [_classe] call R3F_LOG_FNCT_3D_get_bounding_box_depuis_classname;
    _bbox_dim = (vectorMagnitude (_bbox select 0)) max (vectorMagnitude (_bbox select 1));

    // Recherche d'une position dégagée. Les véhicules doivent être créé au niveau du sol sinon ils ne peuvent être utilisés.
    if (_classe isKindOf "AllVehicles") then
    {
        _pos_degagee = [_bbox_dim, getPos _transporteur, 200, 50] call R3F_LOG_FNCT_3D_tirer_position_degagee_sol;
    }
    else
    {
        _pos_degagee = [] call R3F_LOG_FNCT_3D_tirer_position_degagee_ciel;
    };

    if (count _pos_degagee == 0) then {_pos_degagee = getPosATL _transporteur;};
}
else
{
    _classe = typeOf _objet_ou_classe;
};

_fonctionnalites = [_classe] call R3F_LOG_FNCT_determiner_fonctionnalites_logistique;
_cout_chargement_objet = _fonctionnalites select R3F_LOG_IDX_can_be_transported_cargo_cout;

// S'assurer que le type d'objet à charger est transportable
if !(_fonctionnalites select R3F_LOG_IDX_can_be_transported_cargo) then
{
    diag_log format ["[Auto-load ""%1"" in ""%2""] : %3",
        getText (configFile >> "CfgVehicles" >> _classe >> "displayName"),
        getText (configFile >> "CfgVehicles" >> (typeOf _transporteur) >> "displayName"),
        "The object is not a transporable class."];

    systemChat format ["[Auto-load ""%1"" in ""%2""] : %3",
        getText (configFile >> "CfgVehicles" >> _classe >> "displayName"),
        getText (configFile >> "CfgVehicles" >> (typeOf _transporteur) >> "displayName"),
        "The object is not a transporable class."];
}
else
{
    for [{_i = 0}, {_i < _quantite}, {_i = _i+1}] do
    {
        // Si l'objet à charger est donné en tant que nom de classe, on le crée
        if (typeName _objet_ou_classe == "STRING") then
        {
            // Recherche d'une position dégagée. Les véhicules doivent être créé au niveau du sol sinon ils ne peuvent être utilisés.
            if (_classe isKindOf "AllVehicles") then
            {
                _objet = _classe createVehicle _pos_degagee;
                _objet setVectorDirAndUp [[-cos getDir _transporteur, sin getDir _transporteur, 0] vectorCrossProduct surfaceNormal _pos_degagee, surfaceNormal _pos_degagee];
                _objet setVelocity [0, 0, 0];

                // Airdrop addition
                if (_transporteur isKindOf "Land_Pod_Heli_Transport_04_box_F" && {!(_objet isKindOf "ReammoBox_F")}) then // || _objet isKindOf "Land_InfoStand_V2_F")}) then
                {
                    _objet setVariable ["allowDamage", true, true];
                };
            }
            else
            {
                _objet = _classe createVehicle _pos_degagee;

                // Airdrop addition
                if (_transporteur isKindOf "Land_Pod_Heli_Transport_04_box_F" && {!(_objet isKindOf "ReammoBox_F")}) then // || _objet isKindOf "Land_InfoStand_V2_F")}) then
                {
                    _objet setVariable ["allowDamage", true, true];
                };
            };
        }
        else
        {
            _objet = _objet_ou_classe;
        };

        if (!isNull _objet) then
        {
            // Vérifier qu'il n'est pas déjà transporté
            if (isNull (_objet getVariable ["R3F_LOG_est_transporte_par", objNull]) &&
                (isNull (_objet getVariable ["R3F_LOG_est_deplace_par", objNull]) || (!alive (_objet getVariable ["R3F_LOG_est_deplace_par", objNull])) || (!isPlayer (_objet getVariable ["R3F_LOG_est_deplace_par", objNull])))
            ) then
            {
                if (isNull (_objet getVariable ["R3F_LOG_remorque", objNull])) then
                {
                    // Si l'objet loge dans le véhicule
                    if (_chargement_actuel + _cout_chargement_objet <= _chargement_maxi) then
                    {
                        _chargement_actuel = _chargement_actuel + _cout_chargement_objet;
                        _objets_charges pushBack _objet;

                        _objet setVariable ["R3F_LOG_est_transporte_par", _transporteur, true];
                        _objet attachTo [R3F_LOG_PUBVAR_point_attache, [] call R3F_LOG_FNCT_3D_tirer_position_degagee_ciel];
                    }
                    else
                    {
                        diag_log format ["[Auto-load ""%1"" in ""%2""] : %3",
                            getText (configFile >> "CfgVehicles" >> _classe >> "displayName"),
                            getText (configFile >> "CfgVehicles" >> (typeOf _transporteur) >> "displayName"),
                            STR_R3F_LOG_action_charger_pas_assez_de_place];

                        systemChat format ["[Auto-load ""%1"" in ""%2""] : %3",
                            getText (configFile >> "CfgVehicles" >> _classe >> "displayName"),
                            getText (configFile >> "CfgVehicles" >> (typeOf _transporteur) >> "displayName"),
                            STR_R3F_LOG_action_charger_pas_assez_de_place];

                        if (typeName _objet_ou_classe == "STRING") then
                        {
                            deleteVehicle _objet;
                        };
                    };
                }
                else
                {
                    diag_log format [STR_R3F_LOG_objet_remorque_en_cours, getText (configFile >> "CfgVehicles" >> _classe >> "displayName")];
                    systemChat format [STR_R3F_LOG_objet_remorque_en_cours, getText (configFile >> "CfgVehicles" >> _classe >> "displayName")];
                };
            }
            else
            {
                diag_log format [STR_R3F_LOG_objet_en_cours_transport, getText (configFile >> "CfgVehicles" >> _classe >> "displayName")];
                systemChat format [STR_R3F_LOG_objet_en_cours_transport, getText (configFile >> "CfgVehicles" >> _classe >> "displayName")];
            };
        };
    };
};

} forEach _liste_a_charger;

// On mémorise sur le réseau le nouveau contenu du véhicule _transporteur setVariable ["R3F_LOG_objets_charges", _objets_charges, true];

R3F_LOG_mutex_local_verrou = false;`

AgentRev commented 8 years ago

I will actually implement v3, I just whipped that up during the afternoon... I have been holding off making major changes to v1 because I will have to re-implement them in v3 anyway...

ghost commented 8 years ago

ah that's great to know, some of your recent anti abuse changes would be a great addition to v3.

fantastic news.

AgentRev commented 8 years ago

The reason why v3 isn't in yet is because R3F code is really shitty... There is a lot of crap I need to optimize and rewrite, because it's horribly inefficient. When A3W got ported to Altis, we started getting really massive lag because R3F was hogging up the scheduler, stuffing all found vehicles in an array and making sure every new one wasn't already in the array... That kinda stuff.

ghost commented 8 years ago

I remember reading a past comment about rf3 you made along the same lines that's why I was keen to swap back but players love the ability to airdrop or buy bases in a box so I am stuck between a rock and a hard place.

ghost commented 8 years ago

Having thought about this I'd sleep better at night knowing I'm using the most optimised version so I've reverted back to your version Rev, if you do find the time at some point to convert to 3.1 or even add the ability to auto load objects that would be awesome.