/*   Script generated by
Lilac Soul's NWN Script Generator, v. 1.6
(and modified by chris meggitt)

For download info, please visit:
http://www.lilacsoul.revility.com    */

//Put this OnUsed
void Unsum2(object oPC)
{
object oTarget1, oTarget2;

effect eEffect = EffectVisualEffect(VFX_IMP_UNSUMMON);
oTarget1 = GetObjectByTag("starfall2");
RemoveHenchman(oPC, oTarget1);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eEffect, GetLocation(oTarget1));
DestroyObject(GetObjectByTag("starfall2"));
oTarget2 = GetObjectByTag("diablo");
RemoveHenchman(oPC, oTarget2);
ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eEffect, GetLocation(oTarget2));
DestroyObject(GetObjectByTag("diablo"));
}


void main()
{
object oMod = GetModule();
object oPC = GetLastSpeaker();
object oArea = GetArea(OBJECT_SELF);

if (!GetIsPC(oPC)) return;

int oS0 = GetLocalInt(oMod, "challenge");
int oS1 = GetLocalInt(oMod, "sw_hw");
int oS2 = GetLocalInt(oMod, "sw_dr");
int oS3 = GetLocalInt(oMod, "sw_bl");
int oS4 = GetLocalInt(oMod, "sw_pf");
int oS5 = GetLocalInt(oMod, "sw_df");
int oS6 = GetLocalInt(oMod, "sw_pm");
int oS7 = GetLocalInt(oMod, "sw_bm");
int oS8 = GetLocalInt(oMod, "sw_lm");
int oS9 = GetLocalInt(oMod, "sw_ll");
int oS10 = GetLocalInt(oMod, "sw_xx");
int nInt = GetLocalInt(oMod, "challenge");
int nInt2 = GetLocalInt(oMod, "duel_on");
int oChest = GetLocalInt(oMod, "chest_here");
int oGameMode = GetLocalInt(oMod, "gamemode");
int oModMode = GetLocalInt(oMod, "mod_mode");
int iHwar = GetLocalInt(oMod, "hwar_on");
int iStatus = GetLocalInt(oMod, "war_won");

if (oModMode!=1)
   {
    if (iHwar==1)
    {
     if (iStatus!=1)
        {
         SpeakString("Wait until after the Holy War!");
         return;
        }
     else if (iStatus==1)
        {
         SpeakString("Clear the arena first please!");
         return;
        }
    }
    if (oChest!=1)
       {
        if ((nInt!=1)&&(nInt2!=1)&&(oS1!=1)&&(oS2!=1)&&(oS3!=1)
           &&(oS4!=1)&&(oS5!=1)&&(oS6!=1)&&(oS7!=1)&&(oS8!=1)
           &&(oS9!=1)&&(oS0!=1)&&(oS10!=1))
           {
            object oMonster = GetNearestCreature(CREATURE_TYPE_IS_ALIVE, TRUE, oPC);
            if ((!GetIsEnemy(oPC, oMonster))||(oMonster==OBJECT_INVALID))
               {
                if (oGameMode==1)
                   {
                    SetLocalInt(oPC, "npc_duel2", 0);
                    SetLocalInt(oPC, "npc_duel", 0);
                    PlayVoiceChat(VOICE_CHAT_HELLO, OBJECT_SELF);
                    ActionStartConversation(oPC);
                   }
                else
                   {
                    SetLocalInt(oPC, "npc_duel2", 0);
                    SetLocalInt(oPC, "npc_duel", 0);
                    PlayVoiceChat(VOICE_CHAT_HELLO, OBJECT_SELF);
                    ActionStartConversation(oPC);
                   }
               }
            else
               {
                SpeakString("You should finish your battle first!");
                return;
               }
           }
        else
           {
            if (nInt==1)
               {
                SpeakString("You should finish your super challenge first!");
               }
            else if (nInt2==1)
               {
                SpeakString("You should finish your duel challenge first!");
               }
            else
               {
                SpeakString("You should finish your battle first!");
               }
           }
       }
    else
       {
        SpeakString("You must loot your reward chest first!");
       }
    }
 else
    {
     SpeakString("I don't deal with players in campaign manager mode!");
    }
}