#library "COINACS"
#include "zcommon.acs"

int BlueCoins = 0;
int RedCoins = 0;
int BlueAnnouncerSpeak = 0;
int RedAnnouncerSpeak = 0;
int Leader = 0;

Script 50 (void) {
    If(PlayerTeam() == TEAM_BLUE) {
        If(CheckInventory("SkullCoin")) {
            Team_GivePoints(TEAM_BLUE,CheckInventory("SkullCoin"),0); // Team_GivePoints(TEAM_BLUE,0,1);
            BlueCoins += CheckInventory("SkullCoin");
			BlueAnnouncerSpeak += CheckInventory("SkullCoin");
            Print(s:"\chBLUE TEAM SCORES \cf+",i:CheckInventory("SkullCoin"),s:" COINS");
            TakeInventory("SkullCoin",CheckInventory("SkullCoin"));
			If(BlueAnnouncerSpeak >= 100) {
				If(Leader != 1 && BlueCoins > RedCoins) {
					AnnouncerSound("blueleads",0);
					Leader = 1;
				}
				Else {
					AnnouncerSound("bluescores",0);
				}
				While(BlueAnnouncerSpeak >= 100) {
					BlueAnnouncerSpeak -= 100;
					Delay(1);
				}
			}
        }
        Teleport(3,0,0);
    }
}

Script 51 (void) {
    If(PlayerTeam() == TEAM_RED) {
        If(CheckInventory("SkullCoin")) {
            Team_GivePoints(TEAM_RED,CheckInventory("SkullCoin"),0); //Team_GivePoints(TEAM_RED,0,1);
            RedCoins += CheckInventory("SkullCoin");
			RedAnnouncerSpeak += CheckInventory("SkullCoin");
            Print(s:"\cgRED TEAM SCORES \cf+",i:CheckInventory("SkullCoin"),s:" COINS");
            TakeInventory("SkullCoin",CheckInventory("SkullCoin"));
			If(RedAnnouncerSpeak >= 100) {
				If(Leader != 2 && RedCoins > BlueCoins) {
					AnnouncerSound("redleads",0);
					Leader = 2;
				}
				Else {
					AnnouncerSound("redscores",0);
				}
				While(RedAnnouncerSpeak >= 100) {
					RedAnnouncerSpeak -= 100;
					Delay(1);
				}
			}
        }
        Teleport(2,0,0);
    }
}

Script 52 OPEN {
	SetHudSize(320, 200, 0);
    SetFont("BIGFONT");
    If(BlueCoins == RedCoins)
        HudMessageBold(s:"\ch",i:BlueCoins,s:"\cj ---- \cg",i:RedCoins;HUDMSG_PLAIN,1,-1,160.4,0.1,0);
    If(BlueCoins > RedCoins)
        HudMessageBold(s:"\ch",i:BlueCoins,s:"\cj <<<< \cg",i:RedCoins;HUDMSG_PLAIN,1,-1,160.4,0.1,0);
    If(BlueCoins < RedCoins)
        HudMessageBold(s:"\ch",i:BlueCoins,s:"\cj >>>> \cg",i:RedCoins;HUDMSG_PLAIN,1,-1,160.4,0.1,0);
    Delay(1);
    Restart;
}

Script 53 ENTER {
	SetHudSize(320, 200, 0);
    SetFont("BIGFONT");
	HudMessage(s:"\cf$",i:CheckInventory("SkullCoin");HUDMSG_PLAIN,2,-1,160.4,16.1,0);
	If(GetActorProperty(0, APROP_Health) < 1) {
		Terminate;
	}
    Delay(1);
    Restart;
}

Script 54 RESPAWN {
	SetHudSize(320, 200, 0);
    SetFont("BIGFONT");
	HudMessage(s:"\cf$",i:CheckInventory("SkullCoin");HUDMSG_PLAIN,2,-1,160.4,16.1,0);
	If(GetActorProperty(0, APROP_Health) < 1) {
		Terminate;
	}
    Delay(1);
    Restart;
}