Change who inflicts damage from EffectDamage

I did but I don’t know why it just won’t fire for me properly and it’s driving me nuts. That said the tlkoverride though works really well. I am going to build on that version as I expect by the time I am done it won’t be beta anymore but will be released.

And the UI scaling is SO much nicer.

The launcher is a little … confusing I guess by mainly because it’s new.

For what it’s worth, I found a working example of damage inflicted by a trigger.

      AssignCommand(GetNearestObjectByTag("SteamTrap4", oNPC),
        ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectDamage(d6(GetHitDice(oPC)), DAMAGE_TYPE_FIRE), oNPC));

The invisible object is plot, but not static or useable.

As far as I know, a static object can’t have an action queue.

It’s not necessary to involve the module.

oPC is the single player (used for damage scaling). oNPC is the entering object.

if you just created the invisible object, it might be that player still cannot see it due to how vision works - delaying the damage might workaround that

This was the kicker there. I just tried it and it works without the override if the object is Plot but not Static or Usable.

Yeah, static objects can’t be affected by scripts in any way at all, right? No nw_c2_sitting on a static NW_CHAIR. (That’s why I use a special invisible object with the tag and place it over static chairs, rather than just give the chairs a matching tag - I don’t want them to be not-static and possibly get fireballed or whatever).

Certainly, scripts should never involve static objects.

Normally, attempting to do so will simply fail.

However, occasionally, horrible bugs can occur. For example, if you identify a static object by tag and attempt to destroy it, random corruption ensues, which can be very hard to debug if you did it by mistake.

Yeah, when an object is created, a short delay is needed for it to be properly “registered” in the game world.

Here's a 1.69-compatible code that 'changes' the damager's name.

This spawns and invisible, non-usable object (plc_invisobj) above oVictim, makes it damage oVictim after 0.2 s delay, then makes it destroy itself. This is working example of @Proleric’s answer. It creates new objects, so avoid calling it in a loop.

void CustomDoDamage(string sName, object oVictim, int iAmount, int iType=DAMAGE_TYPE_MAGICAL, string sResRef="plc_invisobj")
{
    object oSelf;
    vector vSelf;

    if(GetLocalInt(OBJECT_SELF, "invisible_damager"))
    {
        ApplyEffectToObject(DURATION_TYPE_INSTANT,
            EffectDamage(iAmount, iType), oVictim);
        DestroyObject(OBJECT_SELF, 0.2);
    }
    else
    {
        vSelf = GetPosition(oVictim) + Vector(0.0, 0.0, 2.5);
        oSelf = CreateObject(OBJECT_TYPE_PLACEABLE, sResRef,
            Location(GetArea(oVictim), vSelf, 0.0), FALSE);
        SetName(oSelf, sName);
        SetLocalInt(oSelf, "invisible_damager", TRUE);
        AssignCommand(oSelf, DelayCommand(0.2,
            CustomDoDamage(sName, oVictim, iAmount, iType)));
    }
}

void main()
{
    CustomDoDamage("YORE DEAD FREEMAN", GetFirstPC(), 1);
}

Perhaps z+2.5 is unneeded, but it doesn’t hurt. It’s also recommended to pass the actor object to AssignCommand directly rather than as a return value from a function call.

@QuenGalad It is also possible to sit directly (via script of course) on a non-static and non-usable plc. If you set it as plot, it won’t be affected by spells (including their VFX).

Oh, sure. But I like to have as many things static as possible, because then you don’t risk them spawning in in sight, especially when you set a long fog clipoff or somesuch. “Shadohaunt” had a problem with that - none of the furniture there was set to static and since I have an old, slow laptop there was always this moment of entering an empty room and then the furniture pretending it had been there all along.

1 Like