//:://////////////////////////////////////////////////
//:: prc_pwonspawn
/*
*  PRC8 onSpawn catch-all script.
 */
//:://////////////////////////////////////////////////

/*
    Updated for Project Q IV v4.00 30 May 2022 by Pstemarie: setup OC trolls to use Qv4 user defined events (only killable by fire/acid damage)

    Updated for Project Q IV v4.00 5 Jun 2022 by Pstemarie: remove the skin from OC trolls - their regeneration is handled by the OnUserDefined script

*/
#include "x0_i0_anims"

void main()
{

    //* Pstemarie - set the custom AI scripts and user defined events
    if (GetResRef(OBJECT_SELF) == "nw_troll" ||
        GetResRef(OBJECT_SELF) == "nw_trollchief" ||
        GetResRef(OBJECT_SELF) == "nw_trollboss" ||
        GetResRef(OBJECT_SELF) == "nw_trollwiz" )
    {
        SetSpawnInCondition(NW_FLAG_HEARTBEAT_EVENT);        //* Fire OnUserDefined Event 1001
        SetSpawnInCondition(NW_FLAG_DAMAGED_EVENT);          //* Fire OnUserDefined Event 1006

        SetEventScript(OBJECT_SELF, EVENT_SCRIPT_CREATURE_ON_DEATH, "q_troll_death");
        SetEventScript(OBJECT_SELF, EVENT_SCRIPT_CREATURE_ON_USER_DEFINED_EVENT, "q_troll_userdefn");

        //* Pstemarie - remove the skin item which has the Regeneration(5) itemproperty
        object oSkin = GetItemInSlot(INVENTORY_SLOT_CARMOUR);
        if (GetIsObjectValid(oSkin))
        {
            if (GetResRef(oSkin) == "nw_it_creitem042")
            {
                DestroyObject(oSkin, 1.0);
            }
        }
    }
}