Unable to destroy or spawn Placeables (solved)

Another actually simple script showing weird behaviour. It is an OnEnterArea-Script. It should destroy two creatures and two placeables and then spawn in a different placeable.

Creatures get destroyed (good), placeables don’t react (bad).


void main()
{

object oPC = GetEnteringObject();
if (!GetIsPC(oPC)) return;

object oTarget;
object oSpawn;
location lTarget;

SendMessageToPC(oPC, "Entering Area"); //Debug Feedback

int nInt;
nInt=GetLocalInt(oPC, "OrcAttack");

if (!(nInt == 1))
   return;

nInt=GetLocalInt(oPC, "nHamDestroy");

if (nInt == 0)

    {
    SendMessageToPC(oPC, "Destroying"); //Debug Feedback

    oTarget = GetObjectByTag("ct_Hamfast");
    DestroyObject(oTarget, 0.0);
    oTarget = GetObjectByTag("pt_HamHouse");
    DestroyObject(oTarget, 0.0);
    oTarget = GetObjectByTag("pt_StatueDefaced");
    DestroyObject(oTarget, 0.0);
    oTarget = GetObjectByTag("ct_Guard");
    DestroyObject(oTarget, 0.0);

    SendMessageToPC(oPC, "Creating"); // Debug Feedback
    oTarget = GetWaypointByTag("wt_Ruin");
    lTarget = GetLocation(oTarget);
    oSpawn = CreateObject(OBJECT_TYPE_PLACEABLE, "ZEP_RUIN_Building_DAG", lTarget);

    object oEncounter1 = GetObjectByTag("et_OrcInvasion20");
    SetEncounterActive(TRUE, oEncounter1);

SetLocalInt(oPC, "nHamDestroy", 1);
}
}

Perhaps the tags are wrong? Add more debug messages, such as:

oTarget = GetObjectByTag("ct_Hamfast");
SendMessageToPC(oPC, "Destroying this: " +
    GetName(oTarget) + " " + GetTag(oTarget));
DestroyObject(oTarget); // 0.0 is the default delay

Also this: if(!(nInt == 1)) can be written simply as if(nInt != 1).

Make sure the “Static” box on the placeables you are destroying is unchecked.

1 Like

Thanks all! The static flag was the solution.

1 Like