////////////////////////////////////
//Created by Genisys / Guile
//1/11/08 to 8/10/08 (Big Project!)
////////////////////////////////////
/*

This is my premier OnPlayerDeath Module Event Script which I designed
specifically for all my modules, it's rather nice and is part of
multiple systems, so do not edit ANYTHING you do not know what it's for!

*/
////////////////////////////////////

//Rquired Includes..  (Don't touch!)
#include "nw_i0_plot"
#include "x2_inc_compon"
#include "setxp_inc"

///////////////////////////////////////////////////////////////////////////
/////////////////IMPORTANT OPTIONAL SETTINGS///////////////////////////////
//The constant intergal below allows you to choose where or not to utilize
//the PVP Death System I have scripted, please read below to learn more..
//FALSE = Disabled / TRUE = Enabled
const int nPVP = FALSE;

//This constant will decide whether or not you want to send a PVP message
//to all players when PVP transpires (This is for PVP Servers)
//FALSE = Disabled / TRUE = Enabled
const int nPVPMessage = FALSE;

//If you wish to restrict PVP to the arena only, then..
//Set the below setting to TRUE / FALSE = Deactivated (Default)
const int nArenaOnly = TRUE;

//This determines the level difference allowed in PVP (default 5)
//If set to 5 players within 4 levels of each other will not be
//Penalized for Killing one another. (Works both ways!)
//Add +1 for the level you want so if you want 8 level difference make it 9!
//(Set this whether you allow PVP or not!)
const int nDif = 5; //(Between 5 - 40) / (40 = Disabled)

//This is how you set the reward for XP given to the player for
//fair PVP Kills, this # is multiplied by the level difference!
const int nReward1 = 80;    //(ie. if 3 Levels difference / 80 X 3)

//This is how you set the reward for Gold given to the player for
//fair PVP Kills, this # is multiplied by the level difference!
const int nReward2 = 800;

//Set this to how many seconds you want immortals to lay dead
const float fImmo = 80.0; //Default = 80 seconds

/////////OPTIONS END//////////////////////////////////////////////////

////DO NOT TOUCH ANYTHING BELOW UNLESS IT SAYS - ///OPTION////

//////////////////////////////////////////////////////////////////////
///// This Part was Created by: bushido
///// Developed by: Wouter Dhondt
///// Modified by: Genisys / Guile For Persistency..
////////////////////////////////////////////////////////
//This is the PVP Stats (Used to keep track of PVP Activity)
//This allows DMs and Players to see PVP Activity.
void AdjustPlayerStats()
{

//Delare Variables
object oDied = GetLastPlayerDied();
object oAttacker = GetLastHostileActor(oDied);
object oKiller;

//Only if the player who died is a PC
if(GetIsPC(GetLastPlayerDied()))
{
 //Let's make sure we properly identify who the Attacker is...
 if (GetIsPC(GetMaster(oAttacker)))
 {
 oKiller = GetMaster(oAttacker);
 }

 else
 {
  //Let's make sure the Killer is a PC
  if(GetIsPC(oAttacker))
  {
  oKiller = oAttacker;
  }
 }

    // Increment or set the death variable
    int iDied = GetCampaignInt("PVP_SCORE", "iDied", oDied);
    int nCount = iDied + 1;
    SetCampaignInt("PVP_SCORE", "iDied", nCount, oDied);
    // Is this object a PC?
    if (GetIsPC(oKiller) == TRUE)
    {
        // Increment or set the killer var
        int iKilled = GetCampaignInt("PVP_SCORE", "iKilled", oKiller);
        int nDeaths = iKilled + 1;
        SetCampaignInt("PVP_SCORE", "iKilled", nDeaths, oKiller);
    }
 }

//AdjustPlayerStats End..
}
///////////////////////////////////////////////////////////////
// Raise OnDeath function (Standard Bioware Function)
void Raise(object oPlayer)
{
        effect eVisual = EffectVisualEffect(VFX_IMP_RESTORATION);

        effect eBad = GetFirstEffect(oPlayer);
        ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectResurrection(),oPlayer);
        ApplyEffectToObject(DURATION_TYPE_INSTANT,EffectHeal(GetMaxHitPoints(oPlayer)), oPlayer);

        //Search for negative effects
        while(GetIsEffectValid(eBad))
        {
            if (GetEffectType(eBad) == EFFECT_TYPE_ABILITY_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_AC_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_ATTACK_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_DAMAGE_IMMUNITY_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_SAVING_THROW_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_SPELL_RESISTANCE_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_SKILL_DECREASE ||
                GetEffectType(eBad) == EFFECT_TYPE_BLINDNESS ||
                GetEffectType(eBad) == EFFECT_TYPE_DEAF ||
                GetEffectType(eBad) == EFFECT_TYPE_PARALYZE ||
                GetEffectType(eBad) == EFFECT_TYPE_NEGATIVELEVEL)
                {
                    //Remove effect if it is negative.
                    RemoveEffect(oPlayer, eBad);
                }
            eBad = GetNextEffect(oPlayer);
        }
        //Fire cast spell at event for the specified target
        SignalEvent(oPlayer, EventSpellCastAt(OBJECT_SELF, SPELL_RESTORATION, FALSE));
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVisual, oPlayer);

        object oDeath = GetItemPossessedBy(oPlayer, "death");
        DestroyObject(oDeath, 0.0f);
}

// Respawn/Teleporter OnDeath function (By Bushido / Modified By Genisys)
// Optionally you can create the waypoints described to send the dead player
// to that location.  You must create an item named arenatoken (tag & resref name)
//Then you must use give it to them & take it away from them on enter/exit of
//an area by a script, this will deem that area as the arena.
void Respawn(object oPlayer)
{

    string waiting = "<c B+>The gods show you favor, your life is restored.";

    if (GetIsDead(oPlayer))
    {
        object oPC = oPlayer;

        if (GetItemPossessedBy(oPC, "arenatoken")!= OBJECT_INVALID)
        {
            //Create a way point and tagname it "arenawp"
            object oTarget = GetWaypointByTag("arenawp");
            effect eTeleport = EffectVisualEffect(VFX_FNF_HOWL_WAR_CRY);

            ApplyEffectToObject(DURATION_TYPE_INSTANT, eTeleport, oPlayer);

            //Tell the player why they are being restored.
            FloatingTextStringOnCreature(waiting, oPC);

            //Resurrect the player
            Raise(oPlayer);

            //Teleport the raised player to the arena spawn point.
            DelayCommand(0.1, AssignCommand(oPlayer, ClearAllActions()));
            DelayCommand(0.2, AssignCommand(oPlayer, JumpToObject(oTarget)));
        }
        else
        {
         CreateItemOnObject("death", oPC, 1);
        }

    }
}

////////////////////////////////////////////////////////////////////////
////////////////////////Main Script/////////////////////////////////////
////////////////////////////////////////////////////////////////////////
void main()
{
     ExecuteScript("prc_ondeath", OBJECT_SELF);
    //Declare Major Variables...
    object oPlayer = GetLastPlayerDied();
    object oPC = GetLastPlayerDied();
    object oTarget = oPlayer;
    object oToken = GetItemPossessedBy(oPlayer, "death");
    object oItem;
    object oPP = oPlayer;
    string sArea = GetTag(GetArea(oPlayer));
    string sName = GetName(GetModule());
    location lDead = GetLocation(oPlayer);
    int MULTI_PLAYER = GetLocalInt(GetModule(), "multi");
    effect eKill = EffectDeath(TRUE);
    effect eVis = EffectVisualEffect(VFX_FNF_MYSTICAL_EXPLOSION);


   //Define who oKiller is..
   //Define the attacker & dead guy
   //PVP Variables..
    object oDead = GetLastPlayerDied();
    object oKiller = GetLastHostileActor(oDead);
    object oDied = oPlayer;
    object oVictor;
    object oAttacker;
    object oDumbo;


     //If the player is being tortured, ressurect them...
     object hell = GetArea(oPlayer);
     object helltest = GetArea(GetObjectByTag("satan1"));
     if (hell == helltest)
     {
     DelayCommand(0.1, ApplyEffectToObject(DURATION_TYPE_INSTANT, EffectResurrection(), oPlayer));
     return;
     }

///////////////////////////////////////////////////////////////////
//Determine who the killer is..

 //Define who the attacker is first!
 //Let's make sure the Killer is a PC
  if(GetIsPC(oAttacker))
  {
   oKiller = GetLastHostileActor(oDead);
  }
 if(GetIsDM(oAttacker))
  {
   //Do not define the killer!
  }
  //Let's make sure we properly identify who the Attacker is...
 else if (GetIsPC(GetMaster(oAttacker)))
 {
  oKiller = GetMaster(oAttacker);
 }

 else
 {
  //otherwise it's a monster, so don't define the killer!
 }

    //Define the other now known Variables for PVP
    int nInt;
    int kLvl = GetHitDice(oKiller);
    int pLvl = GetHitDice(oDead);
    int dLvl = kLvl - pLvl;
    int aLvl = pLvl - kLvl;

////////////END VARIABLES////////////////////////////////////

//Save the PC's character instantly.. (If it's a multiplayer game..)
if(MULTI_PLAYER)
{
//ExportSingleCharacter(oPC);
}

//Clear the PC's Reputation immediately...
if(GetIsPC(oPlayer))
{

    AssignCommand(oPlayer, ClearAllActions());

    //Clear Reputation of PC
    if (GetStandardFactionReputation(STANDARD_FACTION_COMMONER, oPlayer) <= 10)
    {   SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
        SetStandardFactionReputation(STANDARD_FACTION_COMMONER, 80, oPlayer);
    }
    if (GetStandardFactionReputation(STANDARD_FACTION_MERCHANT, oPlayer) <= 10)
    {   SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
        SetStandardFactionReputation(STANDARD_FACTION_MERCHANT, 80, oPlayer);
    }
    if (GetStandardFactionReputation(STANDARD_FACTION_DEFENDER, oPlayer) <= 10)
    {   SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
        SetStandardFactionReputation(STANDARD_FACTION_DEFENDER, 80, oPlayer);
    }

 }

///////////GUILD DEATH LOCATION SAVING///////////////////////////////

    //If the pc has a Guile Pass then store their death location..
    if(GetItemPossessedBy(oDead, "guildstone") != OBJECT_INVALID)
    {
     //Store their location into the database for later as well..
     SetCampaignLocation("LOCATIONS", "dth_stored_loc", lDead, oPlayer);
    }

//(leave this alone) */
//////////////////////////////////////////////////////////////

//////////////////////////////////////////////////////////////////////////

    //Fancy death visual effect when they die.
    location lSelf = GetLocation(oPC);
    effect eVis2 = EffectVisualEffect(234);
    ApplyEffectAtLocation(DURATION_TYPE_INSTANT, eVis2, lSelf);

/////////PRE-RESPAWN-ACTIONS/////////

//If the player is in the arena, always respawn them..
if(GetItemPossessedBy(oPC, "arenatoken") != OBJECT_INVALID)
{
 //Lets auto ressurect anyone in the arena and give death tokens to the others.
    Respawn(oPlayer);

    // * make friendly to Each of the 3 common factions
    AssignCommand(oPlayer, ClearAllActions());

    // * Note: waiting for Sophia to make SetStandardFactionReptuation to clear all personal reputation
    if (GetStandardFactionReputation(STANDARD_FACTION_COMMONER, oPlayer) <= 10)
    {   SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
        SetStandardFactionReputation(STANDARD_FACTION_COMMONER, 80, oPlayer);
    }
    if (GetStandardFactionReputation(STANDARD_FACTION_MERCHANT, oPlayer) <= 10)
    {   SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
        SetStandardFactionReputation(STANDARD_FACTION_MERCHANT, 80, oPlayer);
    }
    if (GetStandardFactionReputation(STANDARD_FACTION_DEFENDER, oPlayer) <= 10)
    {   SetLocalInt(oPlayer, "NW_G_Playerhasbeenbad", 10); // * Player bad
        SetStandardFactionReputation(STANDARD_FACTION_DEFENDER, 80, oPlayer);
    }

    //Count up & Store in Database the kills and deaths
    AdjustPlayerStats();

}

/////////////////////////////////////////////////////////////////////////////

   //Have the player tell everyone around them
   //they are dying (technically they are already dead :)
   AssignCommand(oPlayer, ActionSpeakString("I'm dying, help!",
   TALKVOLUME_TALK));

////////////////////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////////////////////////

 //If the player is not immortal & doesn't have an Arena Token...
 //Pop up the Death GUI Panel only if they don't meet the following..

 //If the player is not immortal
 if(GetItemPossessedBy(oPC, "immotoken") == OBJECT_INVALID)
 {
 //If the player does not have an arena token
  if(GetItemPossessedBy(oPC, "arenatoken") == OBJECT_INVALID)
  {
    //Show the player the Death Panel
    DelayCommand(2.0, PopUpGUIPanel(oPlayer,GUI_PANEL_PLAYER_DEATH));

    //Prevent Loggin out to cheat death...
    SetCampaignInt(GetName(GetModule()), "DEATH_LOG", 1, oPC);

  }
 }
 //Otherwise it's an immortal, let's raise them!
 else
 {
   DelayCommand(fImmo, ExecuteScript("raise_immo", oPC));
 }

//////////////////////////////////////////////////////////////////////

////////////////////DETERMINE WHO IS KILLING WHO//////////////////////
//////////////////////////////////////////////////////////////////////

//NOTE: We don't want the script to run for Monsters or DMs!

//If it's not a PC let's make sure an associate of a PC
//has not killed the PC or that's it's not a monster or DM..
if(!GetIsPC(oKiller))
{
 //Let's get the master of the asscoiate..
 if(GetIsPC(GetMaster(oKiller)))
 {
  oDumbo = GetMaster(oKiller);
 }
 //If it's a DM or Monster stop the script here!
 else
 {
  //Stop the rest of the script from firing all together!
  return;
 }

}

//Otherwise let's make sure the Attacker is a PC..
else
{

 if(GetIsPC(oKiller))
 {
  oDumbo = oKiller;
 }
 //If they haven't passed the test for PC or associate of PC stop here!
 else
 {
  return;
 }

//End else
}

//If it's not a PC or Associate of the PC STOP HERE!
if(!GetIsPC(oDumbo))
{
 return;
}

////////////////////////////////////////////////////////////////////////

////////////////////////PVP MESSAGE//////////////////////////////////////
///////See the const int nPVPMessage above to turn on/off)///////////////

if(nPVPMessage == TRUE)
{
    oVictor = oDumbo;
    ////Send PVP Stats Messages to all PCs./////////
    //This shouts whever a player has died, who killed them and also
    //alerts DMs of any pvp action going on! (Though done below as well.)
    //This can also alert DM's not playing as a DM as well too!
    oPC = GetFirstPC();
    int count = 0;
    int nVictims = GetCampaignInt("PVP_SCORE", "iKilled", oKiller);
    int vLvl = GetHitDice(oVictor);
    int dLvl = GetHitDice(oPlayer);
    string sKilled;
    //Send Message to all PC's
    sKilled =  "<cá >";
    sKilled += GetName(oPlayer);
    sKilled += "<c ��> ";
    sKilled += "Lvl ";
    sKilled += IntToString(dLvl);
    sKilled += "<c r�>  Was slain by - ";
    sKilled += "<c�  >";
    sKilled += GetName(oVictor);
    sKilled += "<c ��> ";
    sKilled += "Lvl - ";
    sKilled += IntToString(vLvl);
    sKilled += "<c�  > ";
    sKilled += GetName(oVictor);
    sKilled += "<cP� > has ";
    sKilled += IntToString(nVictims);
    sKilled += "<c�  > kills. </c>";

   //Lets make sure the killer is a PC
   if(GetIsPC(oVictor))
   {

    //Write the PVP Information in the log file. (For those not allowing PVP)
    WriteTimestampedLogEntry("**The Following Player: ");
    WriteTimestampedLogEntry(GetPCPlayerName(oVictor));
    WriteTimestampedLogEntry(" - ");
    WriteTimestampedLogEntry(GetPCPublicCDKey(oVictor));
    WriteTimestampedLogEntry(" - ");
    WriteTimestampedLogEntry(GetPCIPAddress(oVictor));
    WriteTimestampedLogEntry(" ** Has Killed This Player: ");
    WriteTimestampedLogEntry(GetName(oPlayer));
    WriteTimestampedLogEntry(" - ");
    WriteTimestampedLogEntry(GetPCPlayerName(oPlayer));

    while (GetIsPC(oPC) == TRUE)
    {
        SendMessageToPC(oPC, sKilled);
        oPC = GetNextPC();
    }

   }

  //end PVP message function
 }

/////////////////////////////////////////////////////////////////////////

//////////////////IF NO PVP ON THE SERVER IS ALLOWED!/////////////////////

//IF PVP IS NOT ALLOWED!
if(nPVP == FALSE)
{

  //Let's Double Check to make sure it's a PC who killed the PC.
  if(GetIsPC(oDumbo))
  {

   //Apply the respawn penalty to the Killer instead!!
   ApplyRespawnPenalty(oDumbo);

        //Raise the Player Who Died without a penalty
        //Note these must be delayed because of GUI Panel!
        DelayCommand(2.1,
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oDead));

        DelayCommand(2.2, Raise(oDead));



  string sBadPC = GetName(oDumbo);
  sBadPC += " / ";
  sBadPC += GetPCPlayerName(oDumbo);
  sBadPC += " / ";
  sBadPC += GetPCPublicCDKey(oDumbo);
  sBadPC += " Has killed - ";
  sBadPC += GetName(oPC);
  sBadPC += " In the ";
  sBadPC += GetName(GetArea(oPC));
  sBadPC += " Area.";

  //Send Message to All DMs about the Attack..
  SendMessageToAllDMs(sBadPC);
  }

//End No PVP Check..
}

//////////IF PVP IS RESTRICTED TO THE ARENA//////////////

if(nArenaOnly == TRUE)
{
 //If a PC kills a PC outside of the arena..
 if(GetItemPossessedBy(oDead, "arenatoken")==OBJECT_INVALID)
 {
  if(GetIsPC(oDumbo))
  {
        //Raise the Player Who Died
        DelayCommand(2.3,
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oDead));

        DelayCommand(2.4, Raise(oDead));

        SetCampaignInt(GetName(GetModule()), "DEATH_LOG", 0, oDead);

  //Kill the offender and alert the DMs!
  //Type // below at the start of the line to deactivate!
  ApplyEffectToObject(DURATION_TYPE_INSTANT,eKill,oKiller);

  //Apply the respawn penalty to the Killer instead!!
  ApplyRespawnPenalty(oKiller);

 //Send Message to All DMs about the Attack..
 string sArena;
 sArena = GetName(oKiller);
 sArena += " / ";
 sArena += GetPCPlayerName(oKiller);
 sArena += " ";
 sArena += "Has killed - ";
 sArena += GetName(oDead);
 sArena += "Outside of the Arena!";

  SendMessageToAllDMs(sArena);

 //End PC Check
 }

 //End Arena Token Check
 }

//End Arena Check
}
///////////////////////////////////////////////////////////////////////////
//////////////////PVP SCRIPT FUNCTIONS/////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////PVP Option (See the const int nPVP above to turn on/off)///////
if (nPVP == TRUE)
{

//////Start PVP Reward/Penalty Function//////

//If it's not a PC or Asscoiate of the PC Stop here!
if(!GetIsPC(oDumbo))
{
 return;
}

//Only continue if the killer is a PC!
if(GetIsPC(oKiller) == TRUE)
{

    //More PVP Variables

    //Get the Killer's HD + nDif + 1
    int nAdj = GetHitDice(oKiller) + 1;
    int nCheck = nAdj + nDif;
    //Will return 1 or less if they are more than nDif levels
    //lower than the person they killed
    int nDeed = nCheck - pLvl;

   //Ok, this part rewards players for killing players who kill low
   //level players, if they are flagged for killing low level players,
   //and anyone can easially recognized them by the flag on thier back.
  if(GetLocalInt(oDead, "effer") >=1)
  {
    //Lower their effy score by one.
    nInt = GetLocalInt(oDead, "effer");
    nInt -= 1;
    //Decrement thier effer status (because they got killed)
    SetLocalInt(oDead, "effer", nInt);

//If they are at 0 Effy Kills, Remove the flag from them
//Otherwise they can be killed again!!! (After it's been lowered!)
   if (GetLocalInt(oDead, "effer") <=0)
   {
    effect eEffect;
    eEffect = GetFirstEffect(oDead);
    while (GetIsEffectValid(eEffect))
    {
     if (GetEffectType(eEffect)==EFFECT_TYPE_VISUALEFFECT)
     {
      //Note sure about this one!
      if (EFFECT_TYPE_VISUALEFFECT == VFX_DUR_FLAG_RED)
      {
      RemoveEffect(oDead, eEffect);
      eEffect = GetNextEffect(oDead);
      }
     }

    }

   //Now reward the Killer of the bad player with the flag.
   //Adjust to your likings.
   GiveGoldToCreature(oKiller, 5000);
   GiveXPToCreature(oKiller, 500);

   }
  }

    //If the player is too low of a level
    //Punish them for killing a much high level player.
    //This is to prevent lower level players from killing higher
    //level players (which allows the higher levels to ignore them!)
 if (nDeed <=1)
 {
    //Flag them as an Effy Killer (Because they are picking fights!)
    nInt = GetLocalInt(oKiller, "effer");
    nInt += 1;

    int nKind;
    nKind = GetObjectType(oKiller);

    if (nKind != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_FLAG_RED), oKiller);
    else ApplyEffectAtLocation(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_FLAG_RED), GetLocation(oKiller));

    SetLocalInt(oKiller, "effer", nInt);

        //Raise the Player Who Died without a penalty
        //Note these must be delayed because of GUI Panel!
        DelayCommand(2.1,
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oDead));

        DelayCommand(2.2, Raise(oDead));

        //Kill the offender & take xp/gold
        //Type // below at the start of the line to deactivate!
        ApplyEffectToObject(DURATION_TYPE_INSTANT,eKill,oKiller);

        //Penalize the killer Gold / XP
        ApplyRespawnPenalty(oKiller);

        AssignCommand(oKiller, ClearAllActions());
        AssignCommand(oKiller, ActionSpeakString("I have offended the Gods and must be punished!!!", TALKVOLUME_SHOUT));

    //Notify the DMs
    SendMessageToAllDMs("We have an effy kill in progress, please investigate"
    + GetName(oKiller) + ". Has Killed Player " + GetName(oDead));
 //end low level check.
 }

 //If the killer is 5 levels higher than the player they kill
 int aCheck = dLvl;
 if(aCheck >= nDif)
  {
    //Flag them as an Effy Killer
    int nInt;
    nInt = GetLocalInt(oKiller, "effer");
    nInt += 1;

    int nKind;
    nKind = GetObjectType(oKiller);

    if (nKind != OBJECT_TYPE_WAYPOINT) ApplyEffectToObject(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_FLAG_RED), oKiller);
    else ApplyEffectAtLocation(DURATION_TYPE_PERMANENT, EffectVisualEffect(VFX_DUR_FLAG_RED), GetLocation(oKiller));

    SetLocalInt(oDead, "effer", nInt);

        //Raise the Player Who Died
        //This must be delayed due to the GUI Panel that pops up.
        DelayCommand(2.1,
        ApplyEffectToObject(DURATION_TYPE_INSTANT, eVis, oDead));

        DelayCommand(2.2, Raise(oDead));

       SetCampaignInt(GetName(GetModule()), "DEATH_LOG", 0, oDead);

        //Kill the offender & take xp/gold
        //Type // below at the start of the line to deactivate!
        ApplyEffectToObject(DURATION_TYPE_INSTANT,eKill,oKiller);

        //Take XP & Gold from the Offending Killer
        if (GetHitDice(oKiller)<40)//Only if less than level 40
        {
        SetXP(oKiller,GetXP(oKiller)-1000);//NOTE: They can Lose a Level!
        }

        //Remove Gold / XP from the Offender
        ApplyRespawnPenalty(oKiller);

        //Make them shout that they have been bad...
        AssignCommand(oKiller, ClearAllActions());
        AssignCommand(oKiller, ActionSpeakString
        ("I have offended the Gods and must be punished!!!", TALKVOLUME_SHOUT));

    //Notify the DMs
    SendMessageToAllDMs("We have a low level bashing in progress, please investigate"
    + GetName(oKiller) + ". Has Killed Player " + GetName(oPlayer));

//End Effy Check..
 }

//This is the reward of fair PVP

   //Lets make sure the killer is at least 1 level
   //lower than the player they kill
   else if(aLvl >= 1)
     {
    //award xp/gold by level difference,
    //If the player is 1 to nDif levels lower than the player they kill
        if (aLvl <=nDif)
        {
        //Adjust this to your likings..
        int nXP = aLvl * nReward1;
        int nGold = aLvl * nReward2;

        GiveXPToCreature(oKiller,nXP);
        GiveGoldToCreature(oKiller,nGold);
        //The dead guy shouts how he lost badly. :)
        AssignCommand(oDead, ActionSpeakString("I got pwned!!", TALKVOLUME_SHOUT));
        }

      }

     //If the killer is at least 1 level higher than the player they kill
     else if (dLvl <=nDif)
     {
     //Lets make sure the killer is within 1-4 Level difference
     if (dLvl >=1)
       {
        int nXP = dLvl * nReward1;
        int nGold = dLvl * nReward2;

        GiveXPToCreature(oKiller,nXP);
        GiveGoldToCreature(oKiller,nGold);
        //The dead guy shouts how he lost badly. :)
        AssignCommand(oDead, ActionSpeakString("I got pwned!!", TALKVOLUME_SHOUT));
       }
     }
  //end pc check
  }
 //end pvp function
 }

/////////////////////////////////////////////////////////////////////////

//Script End WOOSH!!
}