/*
    PROJECT Q IV
    (c) 2022 by Pstemarie

    Purple Worm OnPhysicallyAttacked Event Script

    Version: 1.0
    Created: 28 Jan 2003
    Author:  Lacero

*/

#include "NW_I0_GENERIC"
#include "q_i0_worm"

void main()
{
    if(!GetIsObjectValid(GetAttemptedAttackTarget()) && !GetIsObjectValid(GetAttemptedSpellTarget()))
    {
        if(GetIsObjectValid(GetLastAttacker()))
        {
            if(GetArea(GetLastAttacker()) == GetArea(OBJECT_SELF))
            {
                pw_DetermineCombatRound();
            }
            //Shout Attack my target, only works with the On Spawn In setup
            SpeakString("NW_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);
            //Shout that I was attacked
            SpeakString("NW_I_WAS_ATTACKED", TALKVOLUME_SILENT_TALK);
        }
    }

    if(GetSpawnInCondition(NW_FLAG_ATTACK_EVENT))
    {
        SignalEvent(OBJECT_SELF, EventUserDefined(1005));
    }
}

