Jump to content
h4wek

Strange behaviour of physix on engine start

Recommended Posts

I have strange reaction of vehicles when spawned script what reproduce with special delay damage and force push on incomeing nuclear blast, problem is on vehicles what are even not used used on this spawn function before  main script not finished it's work still (other objects on map are damaging or hiding by it so it take some seconds with some 0.001 delays in loops used for that), anyway when main script is runing with this objects hide/damage, those spawned functions on vehicles wait for wave to come or when wave is finish it's impact in time, but even the time of blast is pass  vehicles on map are somehow connected to this main loop script, and if someone getin and run engine (car for example) it will colapse to ground  by its all wheels and is stacked in this state even after engine off or even after getout of player and even after main loop script end it's job after 30s (stacked forever), other strange thing is that other objects placed near this car are pushed by some force in moment when my car is pressed into ground (this happen even the objects are not used in spawn functions of blast effect).

This effect not happen if I wait to end of main loop script ,so for example after 30sec when all objects are covered and it finish it's job i can get in to the same car and normally run engine (of course if I don't try it before) - WTF??

I test it only on SP now but on MP probably will be AAAARRRMAAA effect of ejected into space objects - BTW - shame so many years and this issue of flying tanks and other vehicles are still not solved (is so hard to limit max speed of tank object to for example few m/s, and if is needed to make this speed bigger to manipulate by some variable first  - for example  _tank setmaxobjspdallow _value )? of course it can be made by event handlers by players but it should be mange in engine already specially in MP).

 

?imw=5000&imh=5000&ima=fit&impolicy=Lett

 

code is looks like that:

//function for blast wave effect do on nearby vehicles

_push = {params["_pos","_veh","_area","_maxpos","_getposASL"];
    if (_veh getvariable ["inwave",false]) exitwith {};
    _veh setvariable ["inwave",true,false];
    _wavespeed = 300;
    _start = time - 0.1;
    _timeup = _start + (_area/_wavespeed);
    waituntil {sleep 0.1;(isObjectHidden _veh) || (isnull _veh) || ((_pos distance _veh) <= ((time -_start)*_wavespeed)) || (time > _timeup)};

    if ((isObjectHidden _veh) || (isnull _veh) || (time > _timeup) || ((_pos distance _veh) > _area)) exitwith {};
    _vehsize = ((boundingBoxReal _veh)#2)/2;
    if (_veh iskindof "air") then {_vehsize = _vehsize*4};
    if (_veh iskindof "man") then {_vehsize = _vehsize/2};
    _psi = (_area/(_veh distance _pos));
    //_agl = _pos getdir _veh;
    _force = (_vehsize*_psi*6895);
    if (_force > 1000000) exitwith {deletevehicle _veh;systemchat "del psi"};

    if !(terrainIntersectASL [_maxpos, ([_veh] call _getposASL)]) then {
        _obstacle = objnull;
        if (count (lineIntersectsObjs [eyepos _veh,_Pos, _veh, objnull, true, 22]) > 0) then {_obstacle = ((lineIntersectsObjs [eyepos _veh,_Pos, _veh, objnull, true, 22])#0)};
        if ((_obstacle distance _veh < 10) && (((boundingbox _veh)#2) < ((boundingbox _obstacle)#2))) exitwith {};
        _dirV = (AGLtoASL _pos) vectorFromTo (getposASL _veh);
        _vector = _dirV vectorMultiply _force;
        _point = [0,selectrandom [random ((boundingBoxReal _veh)#2)/2,random -((boundingBoxReal _veh)#2)/2],0];
        if (_veh iskindof "man") then {
            if ((stance _veh == "STAND") || (stance _veh == "")) then {_vector = _dirV vectorMultiply _force};
            if (stance _veh == "CROUCH") then {_vector = _dirV vectorMultiply (_force/2)};
            if (stance _veh == "PRONE") then {_vector = _dirV vectorMultiply (_force/6)};
            if ((stance _veh == "UNDEFINED") || (_obstacles isnotequalto [])) then {_vector = _dirV vectorMultiply (_force/10)};
        };
        _veh addForce [_vector, _point];
        _veh setdamage ((damage _veh) + (1.25-(_area/(1+(_pos distance _veh)))));
    };
};

 

//scan for vehicles in explosion area and prepare them for blast come

{
    if ((_x iskindof "man") && (_x distance _position < _burnareaR)) then {deletevehicle _x};
    if !(isnull _x) then {
        [_position,_x,_lightareaR,_maxpos,_getposASL] spawn _push;
        };
    _hidden pushbackunique _x;
}foreach (_position nearentities ["AllVehicles",(_lightareaR*1)]);

 

//........... in later part are loops for scan objects on map (but without those vehicles covered by spawn blast function)

 

_objects = (_position nearobjects _havyareaR) - (_position nearObjects _fireballR);
_terrain = (nearestTerrainObjects [_position,_typesterrain,_havyareaR,false,true]) - (nearestTerrainObjects [_position, [], _fireballR,false,true]);
_objectsToHDestroy = (_objects - _terrain) + _terrain - _hidden;
{
    if (!(isObjectHidden _x) && !(isnull _x)) then {
        _dist = (_x distance _position)+1;
        _x setdamage [1,false];
                    if ((gettext(configfile >> "CfgVehicles" >> (typeof _x) >> "replaceDamaged") == "") && !(_x iskindof "AllVehicles")) then {_x hideObjectGlobal true;};
            _hidden pushbackunique _x;
    };
}foreach _objectsToHDestroy;

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

×