//::///////////////////////////////////////////////
//:: Name: Werewolf Transformation
//:: FileName: werewolf_heart
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
Transform any NPC into a Werewolf at night
and back to the original NPC by day.
*/
//:://////////////////////////////////////////////
//:: Created By: VorpalBlade
//:: Created On: 7/25/02
//:://////////////////////////////////////////////
// Create an NPC and a Werewolf template with the
// Creature Wizard and add this to the OnHeartbeat
// event of both. Then name the Tag of the NPC with
// ResRef of the Werewolf and the Tag of the Werewolf
// with the ResRef of the NPC. Make sure the Name of
// the Werewolf is "Werewolf".
// Do this for each NPC/Werewolf pair you would like
// in your module, so there is a template for each
// NPC and Werewolf.
// Any changes you make to these must be made to the
// templates or they will be lost after the
// transformation.
void ChangeWerewolf(object oObject, string sTemp);
void ChangeTo(string sTemp, location lLoc);
void main()
{
    int bDay = GetIsDay();
    string sMyName = GetName(OBJECT_SELF);
    string sChangeTo;
//    string sChangeTo = GetTag(OBJECT_SELF);
    if (bDay) {
      sChangeTo = "gobbel";
    } else {
      sChangeTo = "werewolfgobbel";
    }
    object oMe = OBJECT_SELF;
// If I'm a man and its night or I'm a WW and it is day.
    if (((sMyName != "Werewolf Gobbel") && (!bDay)) || ((sMyName == "Werewolf Gobbel") && (bDay))){
        AssignCommand(GetModule(), ChangeWerewolf(oMe, sChangeTo));  // Sent to module.
    }
// Sent to module because the DestroyObject(OBJECT_SELF) command
// Would kill the script before the other can be created.
}
void ChangeWerewolf(object oObject, string sTemp)
{
// Save the location of the Man/WW and destroy it and spawn it's counterpart.
    effect eVis = EffectVisualEffect(VFX_FNF_HOWL_MIND);
    location lLoc = GetLocation(oObject);
    ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eVis, lLoc, 2.0f);
    DestroyObject(oObject);
    DelayCommand(0.5f, ChangeTo(sTemp, lLoc));
}
void ChangeTo(string sTemp, location lLoc)
{
    CreateObject(OBJECT_TYPE_CREATURE, sTemp, lLoc);
    effect eVis = EffectVisualEffect(VFX_COM_CHUNK_RED_SMALL);
    ApplyEffectAtLocation(DURATION_TYPE_TEMPORARY, eVis, lLoc, 2.0f);
}