Aller au contenu

Photo

Removing Placed Effects?


  • Veuillez vous connecter pour répondre
3 réponses à ce sujet

#1
comeandsee

comeandsee
  • Members
  • 32 messages

Hello. So I'm trying to make a wand that'll destroy all placed effects that DMs can spawn ingame with the DM creator. I'm not having any luck with either of these scripts I put together. Any suggestions?

    object oEffect = GetNearestObject(OBJECT_TYPE_PLACED_EFFECT,OBJECT_SELF);

    DestroyObject(oEffect);
    object oEffect = GetFirstObjectInArea();

    while (GetIsObjectValid(oEffect))

    {

    if (GetObjectType(oEffect) == OBJECT_TYPE_PLACED_EFFECT)

    {

    DestroyObject(oEffect);

    SendMessageToPC(oPC,"Debug test: Effect destroyed!");

    }

    oEffect = GetNextObjectInArea();

    }



#2
kevL

kevL
  • Members
  • 4 052 messages
here's a script that creates and destroys Placed light-effect objects. It works (though i'm not sure why simply searching for OBJECT_TYPE_PLACED_EFFECT on the destroy-loop doesn't...)
// - onHeartbeat of Area

const string POINT  = "sp_light";        // tag of Object(s) to spawn lights at
const string LIGHT  = "lt_white";        // resref of the Light to spawn
const string EFFECT = "lt_phosphor0101"; // resref of the Placed_Effect to spawn

// both LIGHT and EFFECT will spawn at POINT at dusk, and get destroyed at dawn.

void main()
{
    object oArea = OBJECT_SELF;

    int bDark = (GetIsNight() || GetIsDusk());
    if (bDark == GetLocalInt(oArea, "bDark"))
        return;

    SetLocalInt(oArea, "bDark", bDark);

    if (bDark)
    {
        object oPoint = GetFirstObjectInArea(oArea);
        while (GetIsObjectValid(oPoint))
        {
            if (GetTag(oPoint) == POINT)
            {
                location lPoint = GetLocation(oPoint);
                object oLight = CreateObject(OBJECT_TYPE_LIGHT, LIGHT, lPoint);
                object oEffect = CreateObject(OBJECT_TYPE_PLACED_EFFECT, EFFECT, lPoint);
                SetLocalInt(oLight, "bDestroy", TRUE);
                SetLocalInt(oEffect, "bDestroy", TRUE);
            }
            oPoint = GetNextObjectInArea(oArea);
        }
    }
    else
    {
        object oDestroy = GetFirstObjectInArea(oArea);
        while (GetIsObjectValid(oDestroy))
        {
            if (GetLocalInt(oDestroy, "bDestroy"))
            {
                DestroyObject(oDestroy);
            }
            oDestroy = GetNextObjectInArea(oArea);
        }
    }
}
notice I flagged the Placed_Effects for destruction (didn't want to destroy anything that should remain static).

Maybe you can compare the idea against what you're doing and find something useful there.

#3
comeandsee

comeandsee
  • Members
  • 32 messages

Hmm, now the question is what script controls the DM Creator so those items can be flagged with a variable?



#4
kevL

kevL
  • Members
  • 4 052 messages
uh-oh. Looks like it's implemented via 'dmccreator.xml' -- a GUI
OnLeftClick=UIButton_Input_CreatorSelectItem() 
OnLeftDoubleClick=UIButton_Input_CreatorUseItem()
gui-functions are notoriously hard-coded ....