Jump to content
🛡️FORUMS ARE IN READ-ONLY MODE Read more... ×
hongdino

Canceling Paradrop?

Recommended Posts

I am currently making a ww2 mission using warlords and want to change unit reinforcement with just popping up out of nowhere instead of paradropping. (Because airdropping every solider and tank in ww2 era does not make sense.) I figured out how to cancel vehicle airdrop. I pasted this in init.sqf and it worked, but only for vehicles.
 

Quote

if (isServer) then {
[] spawn {
while {true} do {
_allVehicles = (vehicles select {isNil {_x getVariable "treatedAsVehicle"} && getPosATL _x #2 > 20});
{
_x setVariable ["treatedAsVehicle",true];
_x spawn {
waitUntil {uisleep 0.5; !isNull attachedTo _this};
_para = attachedTo _this;
detach _para;

deleteVehicle _para;
_pos = getPos _this;
_pos set [2,0];
_this setPos _pos;
};
} forEach _allVehicles;
};
}};




However, when I changed 'vehicles' to 'allunits'(I've also tried changing it 'soldiers', 'units') to cancel airdropping infantry reinforcements like below, it did not work and unit reinforcement kept falling down from the sky with parachute, instead of popping up.


 

Quote

if (isServer) then {
[] spawn {
while {true} do {
_allVehicles = (allunits select {isNil {_x getVariable "treatedAsVehicle"} && getPosATL _x #2 > 20});
{
_x setVariable ["treatedAsVehicle",true];
_x spawn {
waitUntil {uisleep 0.5; !isNull attachedTo _this};
_para = attachedTo _this;
detach _para;

deleteVehicle _para;
_pos = getPos _this;
_pos set [2,0];
_this setPos _pos;
};
} forEach _allVehicles;
};
}};




Can anyone tell me what is wrong in the script I edited? Since I have little knowledge about scripting, I can't find out which part is wrong.

Share this post


Link to post
Share on other sites

That's because the chute of an unit is not "attached" but a vehicle itself.

if (isServer) then {
  [] spawn {
    while {true} do {
      _allUnits = (allunits select {isNil {_x getVariable "treatedAsUnit"} && getPosATL _x #2 > 20});
      {
        _x setVariable ["treatedAsUnit",true];
        _x spawn {
          waitUntil {uisleep 0.5; !isNull objectParent _this};
          _para = objectParent _this;
          deleteVehicle _para;
          _pos = getPos _this;
          _pos set [2,0];
          _this setPos _pos;
        };
      } forEach _allUnits;
    };
}};

 

  • Like 1

Share this post


Link to post
Share on other sites
5 hours ago, pierremgi said:

That's because the chute of an unit is not "attached" but a vehicle itself.


if (isServer) then {
  [] spawn {
    while {true} do {
      _allUnits = (allunits select {isNil {_x getVariable "treatedAsUnit"} && getPosATL _x #2 > 20});
      {
        _x setVariable ["treatedAsUnit",true];
        _x spawn {
          waitUntil {uisleep 0.5; !isNull objectParent _this};
          _para = objectParent _this;
          deleteVehicle _para;
          _pos = getPos _this;
          _pos set [2,0];
          _this setPos _pos;
        };
      } forEach _allUnits;
    };
}};

 

Thanks! it is working.

 

One more thing, how should I make the script for both infantry and vehicles to cancel airdropping? 

Share this post


Link to post
Share on other sites

Should work (another approach), in initServer.sqf:

 

["correctDrop","onEachFrame",{
  _allDropped = (vehicles select {_x isKindOf "ParachuteBase"});
  {
  call {
    if !(attachedObjects _x isEqualTo []) exitWith {
      _veh = (attachedObjects _x) #0;
      detach _veh;
      _pos = getpos _veh;
      _pos set [2,0];
      deleteVehicle _x;
      _veh setPos _pos;
    };
    if (!isnull driver _x) exitWith {
      _man = driver _x;
      _pos = getpos _x;
      _pos set [2,0];
      deleteVehicle _x;
      _man setpos _pos;
    };
  };
  } forEach _allDropped;
}] call BIS_fnc_addStackedEventHandler;

 

Do not expect any chute after that! (even ejected pilot).

  • Like 1

Share this post


Link to post
Share on other sites
10 hours ago, pierremgi said:

Should work (another approach), in initServer.sqf:

 


["correctDrop","onEachFrame",{
  _allDropped = (vehicles select {_x isKindOf "ParachuteBase"});
  {
  call {
    if !(attachedObjects _x isEqualTo []) exitWith {
      _veh = (attachedObjects _x) #0;
      detach _veh;
      _pos = getpos _veh;
      _pos set [2,0];
      deleteVehicle _x;
      _veh setPos _pos;
    };
    if (!isnull driver _x) exitWith {
      _man = driver _x;
      _pos = getpos _x;
      _pos set [2,0];
      deleteVehicle _x;
      _man setpos _pos;
    };
  };
  } forEach _allDropped;
}] call BIS_fnc_addStackedEventHandler;

 

Do not expect any chute after that! (even ejected pilot).

This is much better. Thanks!

Share this post


Link to post
Share on other sites

×