Preventing a profiled unit from despawning

  1. 5 years ago

    Hi, I'm working at a mission where taking ALiVE spawned units as prisoners and extracting them out of the AO (where they are then deleted via script) is a key mechanic. This however conflicts wiht ALiVE's despawner, which will delete any unit that's taken too far from their... Spawning location?

    What I've managed to do so far is use Spyderblack's script example to force a unit out of its group, but that only seems to work for subordinate group members spawned by the CQB module, and not for anyone else spawned by the Military Placement modules either.

    So, any ideas on how to prevent a profiled unit from despawning, even when taken far from its spawning location?

  2. OK, found this and here's what I got so far:
    [_unit] spawn { _unit = _this select 0; waitUntil { sleep 1; captive _unit }; _profileID = _unit getVariable ["profileID",""]; _profile = [ALiVE_profileHandler,"getProfile", _profileID] call ALiVE_fnc_hashGet; [ALiVE_profileHandler, "unregisterProfile", _profile] call ALIVE_fnc_profileHandler; };

    Which I'm running as init on all ALiVE spawned units as linked in the first post. Units are unprofiled when captive and I get to carry them wherever I please. Tested it, it works. So far, so good.

    What it doesn't do, however, is work with CQB-module spawned units.

    Some more digging and this is where I'm at:

    [_unit] spawn
    {
      _unit = _this select 0;
      waitUntil
      {
        sleep 1; captive _unit
      };
    
      _house = _unit getVariable "house";
    
      if (isNil "_house") then
      {
        _profileID = _unit getVariable ["profileID",""];
        _profile = [ALiVE_profileHandler,"getProfile", _profileID] call ALiVE_fnc_hashGet;
        [ALiVE_profileHandler, "unregisterProfile", _profile] call ALIVE_fnc_profileHandler;
      } else
      {
      _group = createGroup (side _unit);
      _house setVariable ["group",_group];
      [ALiVE_CQB, "clearHouse", _house] call ALiVE_fnc_CQB;
      };
    };

    What I'm trying to achieve here is to detect whether a unit was spawned by the CQB module (house variable present) and if so to mark the house as cleared upon setting the unit as captive, hopefully tricking the CQB module into deleting a newly created group instead. It seems to work only some of the time, certain units persist past the zone and certain ones despawn. I don't get it.

  3. You could perhaps try creating a new group and moving the unit into the new one, allowing the old group to be deleted by the CQB module.

  4. Edited 5 years ago by 'mante

    @SpyderBlack723 You could perhaps try creating a new group and moving the unit into the new one, allowing the old group to be deleted by the CQB module.

    That's what I was doing but the garbage collector was still deleting the group leader, if I took him too far from his CQB zone. I solved it (I think) by setting the "house" unit variable as 0. That tricks the garbage collector into not deleting the unit, which it would if "house" was nil. It's pretty dirty and hacked together, but it works.

    Thanks for replying and for your script examples by the way, they're enormously useful.

 

or Sign Up to reply!