//::///////////////////////////////////////////////
//:: Default:On Death
//:: NW_C2_DEFAULT7
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
    Shouts to allies that they have been killed
*/
//:://////////////////////////////////////////////
//:: Created By: Preston Watamaniuk
//:: Created On: Oct 25, 2001
//:://////////////////////////////////////////////
#include "NW_I0_GENERIC"

void main()
{
    int nClass = GetLevelByClass(CLASS_TYPE_COMMONER);
    int nAlign = GetAlignmentGoodEvil(OBJECT_SELF);
    if(nClass > 0 && (nAlign == ALIGNMENT_GOOD || nAlign == ALIGNMENT_NEUTRAL))
    {
        object oKiller = GetLastKiller();
        AdjustAlignment(oKiller, ALIGNMENT_EVIL, 5);
    }

    SpeakString("NW_I_AM_DEAD", TALKVOLUME_SILENT_TALK);
    //Shout Attack my target, only works with the On Spawn In setup
    SpeakString("NW_ATTACK_MY_TARGET", TALKVOLUME_SILENT_TALK);
    if(GetSpawnInCondition(NW_FLAG_DEATH_EVENT))
    {
        SignalEvent(OBJECT_SELF, EventUserDefined(1007));
    }

//  Modified By: Dalantriel Jul 22, 2002
//  Raze the temple if killed by a non-PC

    object oKiller = GetLastKiller();

    if(!(GetIsPC(oKiller)))
    {
    DestroyObject(GetObjectByTag("FloorDesignsStyletemple"));
    DestroyObject(GetObjectByTag("AltarShrineGoodHelm"));

    location loc = GetLocation(GetObjectByTag("ai_horde018"));
    CreateObject(OBJECT_TYPE_PLACEABLE, "flamelarge", loc, TRUE);

    object oflame = GetObjectByTag("POST_TownGuard001");
    loc = GetLocation(oflame);
    CreateObject(OBJECT_TYPE_PLACEABLE, "flamelarge", loc, TRUE);

    oflame = GetObjectByTag("POST_TownGuard002");
    loc = GetLocation(oflame);
    CreateObject(OBJECT_TYPE_PLACEABLE, "flamelarge", loc, TRUE);

    oflame = GetObjectByTag("POST_TownGuard009");
    loc = GetLocation(oflame);
    CreateObject(OBJECT_TYPE_PLACEABLE, "flamelarge", loc, TRUE);

    oflame = GetObjectByTag("POST_wardog");
    loc = GetLocation(oflame);
    CreateObject(OBJECT_TYPE_PLACEABLE, "flamelarge", loc, TRUE);

    oflame = GetObjectByTag("POST_Henrick");
    loc = GetLocation(oflame);
    CreateObject(OBJECT_TYPE_PLACEABLE, "flamelarge", loc, TRUE);

    SoundObjectStop(GetObjectByTag("templefountain"));
    SoundObjectPlay(GetObjectByTag("FireTemple1"));
    SoundObjectPlay(GetObjectByTag("FireTemple2"));

// Add evil effects
    loc = GetLocation(GetObjectByTag("centreofgood"));
    CreateObject(OBJECT_TYPE_PLACEABLE, "unholylight", loc, TRUE);
    CreateObject(OBJECT_TYPE_PLACEABLE, "unholyfloor", loc, TRUE);

// Set Good NPC to dead and add Journal Entry
    object oTrashCan = GetObjectByTag("TrashCan");
    SetLocalInt(oTrashCan, "nGoodNPCDead", 1);


        AddJournalQuestEntry("Category000", 9, GetFirstPC(), TRUE, TRUE);


    }

// Else add PC killed Henrick to Journal
    else
    {

    AddJournalQuestEntry("Category000", 8, GetFirstPC(), TRUE, TRUE);

    }
    // Set Good NPC to dead and add Journal Entry
    object oTrashCan = GetObjectByTag("TrashCan");
    SetLocalInt(oTrashCan, "nGoodNPCDead", 1);
}