///////////////////////////////////////////////////
// BalancedWeapons
///////////////////////////////////////////////////
#Const Version		"2012-06-11"
#Const ScriptName	"BalancedWeapons.Script.txt"

#Include "Libs/Nadeo/ShootMania/SM.Script.txt" as SM

#Const		NoVictimRoundsRatios		[1., 1.2, 1.3, 1.35]

/* ------------------------------------- */
/** Return the version number of the script
 *
 *	@return		The version number of the script
 */
Text GetScriptVersion() {
	return Version;
}

/* ------------------------------------- */
/** Return the name of the script
 *
 *	@return		The name of the script
 */
Text GetScriptName() {
	return ScriptName;
}

Void MatchBegin() {}

Void RoundBegin() {	
	foreach(Player in Players) {
		declare Integer VictimCountBeforeOut for Player; 
		declare Integer NoVictimSpawnsInARow for Player; 
		NoVictimSpawnsInARow = 0;
		VictimCountBeforeOut = 0;
	}
}			

Void OnOut(CPlayer _Shooter, CPlayer _Victim) {
	if ( _Shooter != Null) {										
		declare Integer VictimCountThisRound for _Shooter; 
		VictimCountThisRound += 1;							
	}
	if( _Victim != Null) {
		declare Integer VictimCountBeforeOut for _Victim; 
		declare Integer NoVictimSpawnsInARow for _Victim; 
		if (VictimCountBeforeOut == 0) {
			NoVictimSpawnsInARow += 1;
		} else {						
			NoVictimSpawnsInARow = 0;							
		}		
		VictimCountBeforeOut = 0;
	}
}
	
Void SetPlayerWeapon(CSmPlayer _Player, Boolean _AutoSwitchWeapon) {		
	declare Ratio = 1.;
	declare Integer NoVictimSpawnsInARow for _Player; 
	if(NoVictimSpawnsInARow < NoVictimRoundsRatios.count)
		Ratio = NoVictimRoundsRatios[NoVictimSpawnsInARow];
	else 
		Ratio = NoVictimRoundsRatios[NoVictimRoundsRatios.count - 1];

	SM::SetPlayerWeapon(_Player, Ratio, _AutoSwitchWeapon);
}


Void RoundEnd() {}

Void MatchEnd() {}

