/*--------------------------------------------------------

Script Name: sc_object_attack
----------------------------------------------------------
Created By: Genisys(Guile)
Created On: 4/23/09
----------------------------------------------------------

This script spawns in the Justice to tell the PC of
their abomidable offenses, the second time he attacks
and kills them, and the last time he just jails them..

----------------------------------------------------------*/

//Spawn in supercop OnPhysicalAttack

void main()
{
object oPC = GetLastAttacker(OBJECT_SELF);

if (!GetIsPC(oPC))
{
 //if It's a DM stop here..
 if(GetIsDMPossessed(oPC))
 { return; }
 if(GetIsDM(oPC))
 { return; }

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

}

object oPlayer = oPC;

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

//Do Only Once / 30 Seconds
int Do1Time = GetLocalInt(oPC, GetTag(OBJECT_SELF));
if (Do1Time==TRUE) return;

SetLocalInt(oPC, GetTag(OBJECT_SELF), TRUE);
DelayCommand(30.0, SetLocalInt(oPC, GetTag(OBJECT_SELF), FALSE));


object oSpawn;
location lTarget;
lTarget = GetLocation(oPlayer);

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

}