Page 1 of 1

Lamp00 at 0 health doesn't get removed when calling IObject.Remove()

Posted: Sun Feb 20, 2022 3:14 pm
by NearHuscarl
When you damage the lamp (object name Lamp00), it can never be removed using ScriptAPI:

Code: Select all

foreach (var o in Game.GetObjects<IObject>().Where(o => o.Name == "Lamp00"))
{
    // If you comment this line, the code that runs in the next 5 seconds will work
    o.DealDamage(o.GetHealth());
}

// Run after 5 seconds
ScriptHelper.Timeout(() =>
{
    foreach (var o in Game.GetObjects<IObject>().Where(o => o.Name == "Lamp00"))
    {
        o.Remove();
    }
}, 5000);
Expected result: The lamp get removed regardless of its health

Re: Lamp00 at 0 health doesn't get removed when calling IObject.Remove()

Posted: Tue Feb 22, 2022 6:18 pm
by Astolfo
Broken lamps have the _D suffix, so if you want to remove a broken lamp, use Lamp00_D

Re: Lamp00 at 0 health doesn't get removed when calling IObject.Remove()

Posted: Tue Feb 22, 2022 7:21 pm
by NearHuscarl
Astolfo wrote:
Tue Feb 22, 2022 6:18 pm
Broken lamps have the _D suffix, so if you want to remove a broken lamp, use Lamp00_D
I want to remove the "Lamp00", The "Lamp00" has the same sprite as "Lamp00_D" after being shot. It's just impossible to remove it, I've tried IObject.Destroy() and IObject.Remove(). Nothing has worked so far. @Astolfo