//Script Name: sc_object_spelld
//////////////////////////////////////////
//Created By: Genisys (Guile)
//Created On:   8/19/08
/////////////////////////////////////////
/*
This will spawn in the Super Cop on
the PC for casting a spell on an
object which is protected.
*/
////////////////////////////////////////
//This include is used to penalize the PC
#include "setxp_inc"

//Main Script
void main()
{
  //Declare Major Variables..
  object oPlayer = GetLastSpellCaster();
  if(GetIsDM(oPlayer) || GetIsDMPossessed(oPlayer))
  { return; }
  object oTarget;
  object oSpawn;
  location lTarget;

  //Let's make sure we define just who killed the NPC clearly..
if(!GetIsPC(oPlayer))
{
 //if It's a DM stop here..
 if(GetIsDMPossessed(oPlayer))
 { return; }
 if(GetIsDM(oPlayer))
 { return; }

 //IF It truly was an associate who attacked..
 if(GetMaster(oPlayer)!=OBJECT_INVALID)
 {
 oPlayer = GetMaster(oPlayer);
 }
}


if(GetIsPC(oPlayer))
{

 //Only Once Ever 30 Seconds!
 int Do1Time = GetLocalInt(oPlayer, GetTag(OBJECT_SELF) + "SC");

 if (Do1Time==TRUE) {return;}

 SetLocalInt(oPlayer, GetTag(OBJECT_SELF) + "SC", TRUE);
 DelayCommand(30.0, SetLocalInt(oPlayer, GetTag(OBJECT_SELF) + "SC", FALSE));

 //Penalize the player!
  ApplyRespawnPenalty(oPlayer);

  oTarget = oPlayer;

  lTarget = GetLocation(oTarget);

  oSpawn = CreateObject(OBJECT_TYPE_CREATURE, "supercop", lTarget);


    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);
    }


}

//Main Script End
}