Destroy group of placeables

Is this possible? I have an area where a bunch of placeables are grouped together in a Group. I tried with the function DestroyObjectsInGroup(); found in the include library ginc_group, but that only seems to work with creatures grouped together.
There’s quite a lot of placeable objects in this group so it would be so much easier if one could destroy them all in one go instead of destroying each placeable.

groupplaceables

1 Like

I tried to ungroup them and they all (and that’s good) seem to have the same tag. (This is a prefab area)
I tried searching here on the vault for some great scripts and I found one from kevL_s that I modified, but that didn’t work unfortunately.

void DestroyPatch(object oSelf);

void main(string sGroup)
{
    object oSelf = GetObjectByTag(sGroup);

    DestroyPatch(oSelf);

    SetPlotFlag(oSelf, FALSE);
    AssignCommand(oSelf, SetIsDestroyable(TRUE));
    DestroyObject(oSelf, 0.25f);
}

const string sDESTROYME = "DESTROYME";
//
void DestroyPatch(object oSelf)
{
    int i = 1;
    object o = GetNearestObject(OBJECT_TYPE_ALL, oSelf, i);
    while (GetIsObjectValid(o))
    {
        if (GetDistanceToObject(o) <= 3.f
            && (GetLocalInt(o, sDESTROYME) == 1 || GetTag(o) == sDESTROYME))
        {
            SetPlotFlag(o, FALSE);
            AssignCommand(o, SetIsDestroyable(TRUE));
            DestroyObject(o);
        }
        o = GetNearestObject(OBJECT_TYPE_ALL, oSelf, ++i);
    }
}

EDIT:

I changed the script to this, and now some of the placeables are destroyed but not all:

void DestroyPatch(object oSelf);

void main(string sGroup)
{
    object oSelf = GetObjectByTag(sGroup);

    DestroyPatch(oSelf);

    SetPlotFlag(oSelf, FALSE);
    AssignCommand(oSelf, SetIsDestroyable(TRUE));
    DestroyObject(oSelf, 0.25f);
}

const string sDESTROYME = "DESTROYME";
//
void DestroyPatch(object oSelf)
{
    int i = 1;
    object o = GetNearestObject(OBJECT_TYPE_ALL, oSelf, i);
    while (GetIsObjectValid(o))
    {
      
            SetPlotFlag(o, FALSE);
            AssignCommand(o, SetIsDestroyable(TRUE));
            DestroyObject(o);
     
        o = GetNearestObject(OBJECT_TYPE_ALL, oSelf, ++i);
    }
}

EDIT2: I remade all the objects to Placeable objects since I noticed many of the were envorinment objects. That didn’t have any effect unfortunately. I also tried this version of the script:

void DestroyPatch(string sGroup, object oSelf);

void main(string sGroup)
{
    object oSelf = OBJECT_SELF;

    DestroyPatch(sGroup,oSelf);

    SetPlotFlag(oSelf, FALSE);
    AssignCommand(oSelf, SetIsDestroyable(TRUE));
    DestroyObject(oSelf, 0.25f);
}

const string sDESTROYME = "DESTROYME";
//
void DestroyPatch(string sGroup, object oSelf)
{
    int i = 1;
    object o = GetNearestObjectByTag(sGroup, oSelf, i);
    while (GetIsObjectValid(o))
    {
      
            SetPlotFlag(o, FALSE);
            AssignCommand(o, SetIsDestroyable(TRUE));
            DestroyObject(o);
     
        o = GetNearestObjectByTag(sGroup, oSelf, ++i);
    }
}

I’m pretty sure there’s a box on the generic script ( ga_destroy ) in the conversations for destroying all objects of a single tag. I’d give them a new exactly the same tag each as a grouped tag might have done something weird.

I think they have to be placeables so you were on the right track.

1 Like

You can’t destroy static object. Don’t use dynamic collision on all the object but a collision box.

2 Likes

Shallina’s right, collision boxes can definitely be destroyed I’ve done that before.

1 Like

Forgot to check that. They were indeed all set to static for some reason. Now it works.

2 Likes