Melee Tussle

Hi good peoples! :slight_smile: Need a little help. My script isn’t firing properly.

Got a room full of chairs w/tables and an encounter with a particularly nasty bugbear. I would like : if when your in combat with the bugbear and you get to close to any of the chairs, they burst into pieces - mimicking a brawl with chairs being broken from the ensuing tussle?

Code is attached to all of the chairs OnHeartbeat handler.
Heartbeat Code so far:

void main()
{
    object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF);

    if (!GetIsInCombat(oPC) ) return;
    else
    {
        if ( GetIsInCombat(oPC) )
        {
            if ( GetDistanceToObject(oPC) <= 1.0 )
            {
                object oSelf = OBJECT_SELF;
                effect eDamage = EffectDamage(1000, DAMAGE_TYPE_BLUDGEONING, DAMAGE_POWER_PLUS_TWENTY);
                ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oSelf);
                DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect
                ( VFX_IMP_DUST_EXPLOSION ), oSelf));
            }
        }
    }
}

Thanks for any help.

Hmm maybe update the formatting a bit but unless the range is bad don’t see any major problems.

It won’t work on static placeables but you can have them as non-static but unusable so they don’t popup when pressing TAB.

void main()
{
    object oPC = GetNearestCreature(CREATURE_TYPE_PLAYER_CHAR, PLAYER_CHAR_IS_PC, OBJECT_SELF);

    if (!GetIsInCombat(oPC) ) return;

    if ( GetDistanceToObject(oPC) <= 1.0 )
    {
        object oSelf = OBJECT_SELF;
        effect eDamage = EffectDamage(1000, DAMAGE_TYPE_BLUDGEONING, DAMAGE_POWER_PLUS_TWENTY);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oSelf);
        DelayCommand(0.5, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect
        ( VFX_IMP_DUST_EXPLOSION ), oSelf));
    }
}

If you’re sure the PC is in range (test with a debug statement) try

AssignCommand(GetModule(), ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, oSelf));

I’ve found in cases where placeables fail to act as instructed, the module can do it.

Thanks for the response. All of the chairs were flagged as static. They explode now. However, they aren’t very accurate or timely. Every once in a while, they will explode - but it’s usually horribly mistimed. Already tried adjusting the delay’s with no luck.
Hmmm…

It’s running on the heartbeat I think you said above. That’s every 6 seconds… I bet you could move close to one and then away before it fires pretty easily.
Once the tussle starts you could put an aoe around each chair and have the on enter script do it. Actually if they can’t move you could just paint a bunch of small tirggers. Have a variable on the area that sets if the fight is on, or check if the entering creature is in combat. Something like that should fix the timing.

Thanks Meaglyn.
I tried that method and it seems to be working well. :slight_smile:
I changed the code a little -

void main()
{
    object oPC = GetEnteringObject();
    if ( !GetIsPC(oPC) ) return;

    if ( !GetIsInCombat(oPC) ) return;

    if ( GetIsInCombat(oPC) && GetDistanceToObject(oPC) <= 0.5 )
    {
        effect eDamage = EffectDamage(1000, DAMAGE_TYPE_BLUDGEONING, DAMAGE_POWER_NORMAL);
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eDamage, GetNearestObjectByTag("CHAIR_EX_01"));
        ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectVisualEffect
        ( VFX_IMP_DUST_EXPLOSION ), GetNearestObjectByTag("CHAIR_EX_01"));
    }
}
1 Like

Cool! Nice job. The bugbear might smash chairs too :slight_smile: