#library "ZDSPREE"
#include "zcommon.acs"

str SpreeMessage[6];
str MultiKillMessage[7];
str MultiKillSound[7];
str EndSpreeMessage;
str SelfKillSpreeMessage;
bool spreesDisabled[32];
bool OnSpree[32];

int MultiKillTimer[32];
int gotDoubleKill[32];
int gotMultiKill[32];
int gotMegaKill[32];
int gotUltraKill[32];
int gotMonsterKill[32];
int gotLudicrousKill[32];

#define SPREE_KILLING_SPREE 0
#define SPREE_RAMPAGE 1
#define SPREE_DOMINATING 2
#define SPREE_UNSTOPPABLE 3
#define SPREE_GODLIKE 4
#define SPREE_WICKED_SICK 5

#define MULTI_DOUBLE_KILL 6
#define MULTI_MULTI_KILL 7
#define MULTI_MEGA_KILL 8
#define MULTI_ULTRA_KILL 9
#define MULTI_MONSTER_KILL 10
#define MULTI_LUDICROUS_KILL 11
#define MULTI_HOLY_SHIT 12

Script 585 Open
{
    SpreeMessage[0] = "\cnKilling Spree";
    SpreeMessage[1] = "\cnRampage!";
    SpreeMessage[2] = "\cnDominating!";
    SpreeMessage[3] = "\cnUnstoppable!";
    SpreeMessage[4] = "\cnGODLIKE!";
    SpreeMessage[5] = "\cnWICKED SICK!";
    EndSpreeMessage = "\cn's killing spree was ended by \ch";
}

Script 586 Enter
{
    int player_number = PlayerNumber();

    OnSpree[player_number]=false;

    Thing_ChangeTID(0,586+player_number);

    SetThingSpecial(0,226,589,0,player_number,0,0);
}

Script 587 Respawn
{
    Thing_ChangeTID(0,586+PlayerNumber());

    SetThingSpecial(0,226,589,0,PlayerNumber(),0,0);

}

Script 588 (void) NET
{
    int who = PlayerNumber();

    if(!PlayerInGame(who))
    terminate;

    if(spreesDisabled[who])
    spreesDisabled[who]=false;
	
    else
    spreesDisabled[who]=true;
}

Script 589 (int who)
{
    if(GetActorProperty(0, APROP_Health) > 0)
    {
    ACS_ExecuteAlways(590,0,0,0,0);
    ACS_ExecuteAlways(594,0,0,0,0);
    }
 
    if(OnSpree[who])
    {
        SetFont("SMALLFONT");
        if(who==PlayerNumber() || PlayerNumber()==-1)
        suicideMessage(who);
 
    else
        HudMessageBold(n:(who+1), s:EndSpreeMessage, n:0; HUDMSG_FADEOUT,0,CR_Blue,0.5,0.35,1.0,3.0);
       
    OnSpree[who]=false;
    }
       
}
 
function void suicideMessage(int pnum)
{
    if( GetPlayerInfo(pnum, PLAYERINFO_GENDER) == 0 )
        HudMessageBold(n:(pnum+1), s:"\cn was lookin' good until he killed himself"; HUDMSG_FADEOUT,0,CR_Blue,0.5,0.35,1.0,3.0);
 
    else if( GetPlayerInfo(pnum, PLAYERINFO_GENDER) == 1 )
        HudMessageBold(n:(pnum+1), s:"\cn was lookin' good until she killed herself"; HUDMSG_FADEOUT,0,CR_Blue,0.5,0.35,1.0,3.0);
 
    else
        HudMessageBold(n:(pnum+1), s:"\cn was lookin' good until it killed itself"; HUDMSG_FADEOUT,0,CR_Blue,0.5,0.35,1.0,3.0);
}

Script 590 (VOID)
{
    GiveInventory("SpreeCheck",1);

    If(CheckInventory("SpreeCheck") == 5 && CheckInventory("Spree1") != 1)
    {
        OnSpree[PlayerNumber()]=true;
        SetFont("SMALLFONT");
        HudMessageBold(n:0, s:"\cn is on a ", s:SpreeMessage[0];HUDMSG_FADEOUT,1,CR_Blue,0.5,0.3,1.0,3.0);
	GiveInventory("Spree1",1);
	If(spreesDisabled[PlayerNumber()])
		terminate;
        SetFont("BIGFONT");
        HudMessage(s:SpreeMessage[0];HUDMSG_FADEOUT,0,CR_LightBlue,1.5,0.2,3.0,0.5);
        ACS_ExecuteAlways(597, 0, SPREE_KILLING_SPREE);
    }
    Else If(CheckInventory("SpreeCheck") == 10 && CheckInventory("Spree2") != 1)
    {
        SetFont("SMALLFONT");
        HudMessageBold(n:0, s:"\cn is on a ", s:SpreeMessage[1];HUDMSG_FADEOUT,1,CR_Blue,0.5,0.3,1.0,3.0);
	GiveInventory("Spree2",1);
	If(spreesDisabled[PlayerNumber()])
		terminate;
        SetFont("BIGFONT");
        HudMessage(s:SpreeMessage[1];HUDMSG_FADEOUT,0,CR_LightBlue,1.5,0.2,3.0,0.5);
        ACS_ExecuteAlways(597, 0, SPREE_RAMPAGE);
    }
    Else If(CheckInventory("SpreeCheck") == 15 && CheckInventory("Spree3") != 1)

    {
        SetFont("SMALLFONT");
        HudMessageBold(n:0, s:"\cn is ", s:SpreeMessage[2];HUDMSG_FADEOUT,1,CR_Blue,0.5,0.3,1.0,3.0);
	GiveInventory("Spree3",1);
	If(spreesDisabled[PlayerNumber()])
		terminate;
        SetFont("BIGFONT");
        HudMessage(s:SpreeMessage[2];HUDMSG_FADEOUT,0,CR_LightBlue,1.5,0.2,3.0,0.5);
        ACS_ExecuteAlways(597, 0, SPREE_DOMINATING);
    }
    Else If(CheckInventory("SpreeCheck") == 20 && CheckInventory("Spree4") != 1)

    {
        SetFont("SMALLFONT");
        HudMessageBold(n:0, s:"\cn is ", s:SpreeMessage[3];HUDMSG_FADEOUT,1,CR_Blue,0.5,0.3,1.0,3.0);
	GiveInventory("Spree4",1);
	If(spreesDisabled[PlayerNumber()])
		terminate;
        SetFont("BIGFONT");
        HudMessage(s:SpreeMessage[3];HUDMSG_FADEOUT,0,CR_LightBlue,1.5,0.2,3.0,0.5);
        ACS_ExecuteAlways(597, 0, SPREE_UNSTOPPABLE);
    }
    Else If(CheckInventory("SpreeCheck") == 25 && CheckInventory("Spree5") != 1)
    {
        SetFont("SMALLFONT");
        HudMessageBold(n:0, s:"\cn is ", s:SpreeMessage[4];HUDMSG_FADEOUT,1,CR_Blue,0.5,0.3,1.0,3.0);
	GiveInventory("Spree5",1);
	If(spreesDisabled[PlayerNumber()])
		terminate;
        SetFont("BIGFONT");
        HudMessage(s:SpreeMessage[4];HUDMSG_FADEOUT,0,CR_LightBlue,1.5,0.2,3.0,0.5);
        ACS_ExecuteAlways(597, 0, SPREE_GODLIKE);
    }
    Else If(CheckInventory("SpreeCheck") == 30 && CheckInventory("Spree6") != 1)
    {
        SetFont("SMALLFONT");
        HudMessageBold(n:0, s:"\cn is ", s:SpreeMessage[5];HUDMSG_FADEOUT,1,CR_Blue,0.5,0.3,1.0,3.0);
	GiveInventory("Spree6",1);
	If(spreesDisabled[PlayerNumber()])
		terminate;
        SetFont("BIGFONT");
        HudMessage(s:SpreeMessage[5];HUDMSG_FADEOUT,0,CR_LightBlue,1.5,0.2,3.0,0.5);
        ACS_ExecuteAlways(597, 0, SPREE_WICKED_SICK);
    }
}

Script 595 Enter
{
If(PlayerIsBot(PlayerNumber())) {Terminate;} Else {

If( MultiKillTimer[PlayerNumber()] > 0)
  {
  MultiKillTimer[PlayerNumber()]--;
  }
Else
  {
  If( MultiKillTimer[PlayerNumber()] == 0 )
    {
    TakeInventory("MultiKill", 999);
    gotDoubleKill[PlayerNumber()] = 0;
    gotMultiKill[PlayerNumber()] = 0;
    gotMegaKill[PlayerNumber()] = 0;
    gotUltraKill[PlayerNumber()] = 0;
    gotMonsterKill[PlayerNumber()] = 0;
    gotLudicrousKill[PlayerNumber()] = 0;
    }
  }

If( GetActorProperty(0, APROP_Health) <= 0 )
  {
    TakeInventory("MultiKill", 999);
    gotDoubleKill[PlayerNumber()] = 0;
    gotMultiKill[PlayerNumber()] = 0;
    gotMegaKill[PlayerNumber()] = 0;
    gotUltraKill[PlayerNumber()] = 0;
    gotMonsterKill[PlayerNumber()] = 0;
    gotLudicrousKill[PlayerNumber()] = 0;
    Terminate;
  }

  Delay(1); Restart;
}
}

Script 596 Respawn
{
If(PlayerIsBot(PlayerNumber())) {Terminate;} Else {

If( MultiKillTimer[PlayerNumber()] > 0)
  {
  MultiKillTimer[PlayerNumber()]--;
  }
Else
  {
  If( MultiKillTimer[PlayerNumber()] == 0 )
    {
    TakeInventory("MultiKill", 999);
    gotDoubleKill[PlayerNumber()] = 0;
    gotMultiKill[PlayerNumber()] = 0;
    gotMegaKill[PlayerNumber()] = 0;
    gotUltraKill[PlayerNumber()] = 0;
    gotMonsterKill[PlayerNumber()] = 0;
    gotLudicrousKill[PlayerNumber()] = 0;
    }
  }

If( GetActorProperty(0, APROP_Health) <= 0 )
  {
    TakeInventory("MultiKill", 999);
    gotDoubleKill[PlayerNumber()] = 0;
    gotMultiKill[PlayerNumber()] = 0;
    gotMegaKill[PlayerNumber()] = 0;
    gotUltraKill[PlayerNumber()] = 0;
    gotMonsterKill[PlayerNumber()] = 0;
    gotLudicrousKill[PlayerNumber()] = 0;
    Terminate;
  }

  Delay(1); Restart;
}
}

Script 594 (VOID)
{
If(PlayerIsBot(PlayerNumber())) {Terminate;} Else {

  If(spreesDisabled[PlayerNumber()])
	terminate;

  MultiKillTimer[PlayerNumber()]=120;
  GiveInventory("MultiKill", 1);
 
  If( CheckInventory("MultiKill") == 2 && gotDoubleKill[PlayerNumber()] == 0 )
    {
      SetFont("BIGFONT");
      HudMessage(s:"\cgDouble Kill!";  HUDMSG_FADEOUT, 5+PlayerNumber() ,CR_Red, 1.5, 0.8, 3.0, 0.5);
      ACS_ExecuteAlways(597, 0, MULTI_DOUBLE_KILL);
      gotDoubleKill[PlayerNumber()] = 1;
    }
 
  If( CheckInventory("MultiKill") == 3 && gotMultiKill[PlayerNumber()] == 0 )
    {
      SetFont("BIGFONT");
      HudMessage(s:"\cgMulti Kill!";  HUDMSG_FADEOUT, 5+PlayerNumber() ,CR_Red, 1.5, 0.8, 3.0, 0.5);
      ACS_ExecuteAlways(597, 0, MULTI_MULTI_KILL);
      gotMultiKill[PlayerNumber()] = 1;
    }
 
  If( CheckInventory("MultiKill") == 4 && gotMegaKill[PlayerNumber()] == 0 )
    {
      SetFont("BIGFONT");
      HudMessage(s:"\cgMEGA Kill!!";  HUDMSG_FADEOUT, 5+PlayerNumber() ,CR_Red, 1.5, 0.8, 3.0, 0.5);
      ACS_ExecuteAlways(597, 0, MULTI_MEGA_KILL);
      gotMegaKill[PlayerNumber()] = 1;
    }
 
  If( CheckInventory("MultiKill") == 5 && gotUltraKill[PlayerNumber()] == 0 )
    {
      SetFont("BIGFONT");
      HudMessage(s:"\cgULTRA Kill!!";  HUDMSG_FADEOUT, 5+PlayerNumber() ,CR_Red, 1.5, 0.8, 3.0, 0.5);
      ACS_ExecuteAlways(597, 0, MULTI_ULTRA_KILL);
      gotUltraKill[PlayerNumber()] = 1;
    }
 
  If( CheckInventory("MultiKill") == 6 && gotMonsterKill[PlayerNumber()] == 0 )
    {
      SetFont("BIGFONT");
      HudMessage(s:"\cgMONSTER Kill!!!";  HUDMSG_FADEOUT, 5+PlayerNumber() ,CR_Red, 1.5, 0.8, 3.0, 0.5);
      ACS_ExecuteAlways(597, 0, MULTI_MONSTER_KILL);
      gotMonsterKill[PlayerNumber()] = 1;
    }
 
  If( CheckInventory("MultiKill") == 7 && gotLudicrousKill[PlayerNumber()] == 0 )
    {
      SetFont("BIGFONT");
      HudMessage(s:"\cgLUDICROUS Kill!!!";  HUDMSG_FADEOUT, 5+PlayerNumber() ,CR_Red, 1.5, 0.8, 3.0, 0.5);
      ACS_ExecuteAlways(597, 0, MULTI_LUDICROUS_KILL);
      gotLudicrousKill[PlayerNumber()] = 1;
    }
 
  If( CheckInventory("MultiKill") >= 8 )
    {
      SetFont("BIGFONT");
      HudMessage(s:"\cgH O L Y  S H I T !";  HUDMSG_FADEOUT, 5+PlayerNumber() ,CR_Red, 1.5, 0.8, 3.0, 0.5);
      ACS_ExecuteAlways(597, 0, MULTI_HOLY_SHIT);
    }
}
}


script 597 (int playSound) CLIENTSIDE   //Plays announcer sound it's passed
{
    if( playSound == SPREE_KILLING_SPREE )
    {
        if( GetCVar("spreevar") == 0 ) { LocalAmbientSound("spree/1", 100); LocalAmbientSound("spree/1", 100); }

        if( GetCVar("spreevar") == 1 ) { LocalAmbientSound("spree/11", 100); LocalAmbientSound("spree/11", 100); }

        if( GetCVar("spreevar") == 2 ) { LocalAmbientSound("spree/21", 110); LocalAmbientSound("spree/21", 110); }

        if( GetCVar("spreevar") == 3 ) { LocalAmbientSound("spree/31", 100); LocalAmbientSound("spree/31", 100); }
    }

    if( playSound == SPREE_RAMPAGE )
    {
        if( GetCVar("spreevar") == 0 ) { LocalAmbientSound("spree/2", 100); LocalAmbientSound("spree/2", 100); }

        if( GetCVar("spreevar") == 1 ) { LocalAmbientSound("spree/12", 100); LocalAmbientSound("spree/12", 100); }

        if( GetCVar("spreevar") == 2 ) { LocalAmbientSound("spree/22", 110); LocalAmbientSound("spree/22", 110); }

        if( GetCVar("spreevar") == 3 ) { LocalAmbientSound("spree/32", 100); LocalAmbientSound("spree/32", 100); }
    }

    if( playSound == SPREE_DOMINATING )
    {
        if( GetCVar("spreevar") == 0 ) { LocalAmbientSound("spree/3", 100); LocalAmbientSound("spree/3", 100); }

        if( GetCVar("spreevar") == 1 ) { LocalAmbientSound("spree/13", 100); LocalAmbientSound("spree/13", 100); }

        if( GetCVar("spreevar") == 2 ) { LocalAmbientSound("spree/23", 110); LocalAmbientSound("spree/23", 110); }

        if( GetCVar("spreevar") == 3 ) { LocalAmbientSound("spree/33", 100); LocalAmbientSound("spree/33", 100); }
    }

    if( playSound == SPREE_UNSTOPPABLE )
    {
        if( GetCVar("spreevar") == 0 ) { LocalAmbientSound("spree/4", 100); LocalAmbientSound("spree/4", 100); }

        if( GetCVar("spreevar") == 1 ) { LocalAmbientSound("spree/14", 100); LocalAmbientSound("spree/14", 100); }

        if( GetCVar("spreevar") == 2 ) { LocalAmbientSound("spree/24", 110); LocalAmbientSound("spree/24", 110); }

        if( GetCVar("spreevar") == 3 ) { LocalAmbientSound("spree/34", 100); LocalAmbientSound("spree/34", 100); }
    }

    if( playSound == SPREE_GODLIKE )
    {
        if( GetCVar("spreevar") == 0 ) { LocalAmbientSound("spree/5", 100); LocalAmbientSound("spree/5", 100); }

        if( GetCVar("spreevar") == 1 ) { LocalAmbientSound("spree/15", 100); LocalAmbientSound("spree/15", 100); }

        if( GetCVar("spreevar") == 2 ) { LocalAmbientSound("spree/25", 110); LocalAmbientSound("spree/25", 110); }

        if( GetCVar("spreevar") == 3 ) { LocalAmbientSound("spree/35", 100); LocalAmbientSound("spree/35", 100); }
    }

    if( playSound == SPREE_WICKED_SICK )
    {
        if( GetCVar("spreevar") == 0 ) { LocalAmbientSound("spree/6", 100); LocalAmbientSound("spree/6", 100); }

        if( GetCVar("spreevar") == 1 ) { LocalAmbientSound("spree/16", 100); LocalAmbientSound("spree/16", 100); }

        if( GetCVar("spreevar") == 2 ) { LocalAmbientSound("spree/26", 110); LocalAmbientSound("spree/26", 110); }

        if( GetCVar("spreevar") == 3 ) { LocalAmbientSound("spree/36", 100); LocalAmbientSound("spree/36", 100); }
    }

    if( playSound == MULTI_DOUBLE_KILL )
    {
        if( GetCVar("spreevar") == 0 ) { LocalAmbientSound("multi/2", 100); LocalAmbientSound("multi/2", 100); }

        if( GetCVar("spreevar") == 1 ) { LocalAmbientSound("multi/12", 100); LocalAmbientSound("multi/12", 100); }

        if( GetCVar("spreevar") == 2 ) { LocalAmbientSound("multi/22", 110); LocalAmbientSound("multi/22", 110); }

        if( GetCVar("spreevar") == 3 ) { LocalAmbientSound("multi/32", 100); LocalAmbientSound("multi/32", 100); }
    }

    if( playSound == MULTI_MULTI_KILL )
    {
        if( GetCVar("spreevar") == 0 ) { LocalAmbientSound("multi/3", 100); LocalAmbientSound("multi/3", 100); }

        if( GetCVar("spreevar") == 1 ) { LocalAmbientSound("multi/13", 100); LocalAmbientSound("multi/13", 100); }

        if( GetCVar("spreevar") == 2 ) { LocalAmbientSound("multi/23", 110); LocalAmbientSound("multi/23", 110); }

        if( GetCVar("spreevar") == 3 ) { LocalAmbientSound("multi/33", 100); LocalAmbientSound("multi/33", 100); }
    }

    if( playSound == MULTI_MEGA_KILL )
    {
        if( GetCVar("spreevar") == 0 ) { LocalAmbientSound("multi/4", 100); LocalAmbientSound("multi/4", 100); }

        if( GetCVar("spreevar") == 1 ) { LocalAmbientSound("multi/14", 100); LocalAmbientSound("multi/14", 100); }

        if( GetCVar("spreevar") == 2 ) { LocalAmbientSound("multi/24", 110); LocalAmbientSound("multi/24", 110); }

        if( GetCVar("spreevar") == 3 ) { LocalAmbientSound("multi/34", 100); LocalAmbientSound("multi/34", 100); }
    }

    if( playSound == MULTI_ULTRA_KILL )
    {
        if( GetCVar("spreevar") == 0 ) { LocalAmbientSound("multi/5", 100); LocalAmbientSound("multi/5", 100); }

        if( GetCVar("spreevar") == 1 ) { LocalAmbientSound("multi/15", 100); LocalAmbientSound("multi/15", 100); }

        if( GetCVar("spreevar") == 2 ) { LocalAmbientSound("multi/25", 110); LocalAmbientSound("multi/25", 110); }

        if( GetCVar("spreevar") == 3 ) { LocalAmbientSound("multi/35", 100); LocalAmbientSound("multi/35", 100); }
    }

    if( playSound == MULTI_MONSTER_KILL )
    {
        if( GetCVar("spreevar") == 0 ) { LocalAmbientSound("multi/6", 100); LocalAmbientSound("multi/6", 100); }

        if( GetCVar("spreevar") == 1 ) { LocalAmbientSound("multi/16", 100); LocalAmbientSound("multi/16", 100); }

        if( GetCVar("spreevar") == 2 ) { LocalAmbientSound("multi/26", 110); LocalAmbientSound("multi/26", 110); }

        if( GetCVar("spreevar") == 3 ) { LocalAmbientSound("multi/36", 100); LocalAmbientSound("multi/36", 100); }
    }

    if( playSound == MULTI_LUDICROUS_KILL )
    {
        if( GetCVar("spreevar") == 0 ) { LocalAmbientSound("multi/7", 100); LocalAmbientSound("multi/7", 100); }

        if( GetCVar("spreevar") == 1 ) { LocalAmbientSound("multi/17", 100); LocalAmbientSound("multi/17", 100); }

        if( GetCVar("spreevar") == 2 ) { LocalAmbientSound("multi/27", 110); LocalAmbientSound("multi/27", 110); }

        if( GetCVar("spreevar") == 3 ) { LocalAmbientSound("multi/37", 100); LocalAmbientSound("multi/37", 100); }
    }

    if( playSound == MULTI_HOLY_SHIT )
    {
        if( GetCVar("spreevar") == 0 ) { LocalAmbientSound("multi/8", 100); LocalAmbientSound("multi/8", 100); }

        if( GetCVar("spreevar") == 1 ) { LocalAmbientSound("multi/18", 100); LocalAmbientSound("multi/18", 100); }

        if( GetCVar("spreevar") == 2 ) { LocalAmbientSound("multi/28", 110); LocalAmbientSound("multi/28", 110); }

        if( GetCVar("spreevar") == 3 ) { LocalAmbientSound("multi/38", 100); LocalAmbientSound("multi/38", 100); }
    }
}