// Passive Talent Handler.
// Worthless Bums 2013.


// Initialize all class passive talent tooltips.
function initializeClassPassiveTalentTooltips ()
{//echo("initializeClassPassiveTalentTooltips()");
	initializeLeaderPassiveTalentTooltips();
	initializeScoutPassiveTalentTooltips();
	initializeGrenadierPassiveTalentTooltips();
	initializeSupportPassiveTalentTooltips();
	initializeEngineerPassiveTalentTooltips();
}

// Initialize Leader class passive talent tooltips.
function initializeLeaderPassiveTalentTooltips ()
{//echo("initializeLeaderPassiveTalentTooltips()");
	$LeaderPfcPassiveTalent = "Iron Resolve: Reduces physical damage by 25%";
	$LeaderLCplPassiveTalent = "Flak Rounds: Shots reduce enemy physical armor by " @ $flakRoundsReduction;
	$LeaderCPLPassiveTalent = "Firefighter: Reduces fire damage taken by " @ $fireFighterReduction @ "%";
	$LeaderSgtPassiveTalent = "Vigilance: Entire squad gets +" @ $vigilanceEvasion @ "% evasion.";
}
// Initialize Scout class passive talent tooltips.
function initializeScoutPassiveTalentTooltips ()
{//echo("initializeScoutPassiveTalentTooltips()");
	$ScoutPfcPassiveTalent = "Second Skin: " @ $secondSkinAPRatio @ "% of max AP counts as physical armor";
	$ScoutLCplPassiveTalent = "Stealthy: +" @ $stealthyEvasion @ "% Evasion and reduced chance to be targeted by enemies";
	$ScoutCPLPassiveTalent = "Autoloader: Reloading only takes " @ $autoloaderLoadCost @ " AP";
	$ScoutSgtPassiveTalent = "Biohazard: +" @ $biohazardDamageBoost @ " damage against organics";
}
// Initialize Grenadier class passive talent tooltips.
function initializeGrenadierPassiveTalentTooltips ()
{//echo("initializeGrenadierPassiveTalentTooltips()");
	$GrenadierPfcPassiveTalent = "Annihilation: Aoe attacks can kill secondary targets";
	$GrenadierLCplPassiveTalent = "Minesweeper: Weapon destroys land mines";
	$GrenadierCPLPassiveTalent = "Ablative Armor: Reduces all non-physical damage by 25%";
	$GrenadierSgtPassiveTalent = "Smart Bombs: Aoe no longer deals friendly fire";
}
// Initialize Support class passive talent tooltips.
function initializeSupportPassiveTalentTooltips ()
{//echo("initializeSupportPassiveTalentTooltips()");
	$SupportPfcPassiveTalent = "Hulk: Melee attacks have knockback";
	$SupportLCplPassiveTalent = "Shark Rounds: Shots ignore " @ $sharkRoundsIgnoreArmor @ "% of target physical armor";
	$SupportCPLPassiveTalent = "Sentry: Guard Mode shots always hit";
	$SupportSgtPassiveTalent = "Flanker: Flanking shots always hit";
}
// Initialize Engineer class passive talent tooltips.
function initializeEngineerPassiveTalentTooltips ()
{//echo("initializeEngineerPassiveTalentTooltips()");
	$EngineerPfcPassiveTalent = "Stun Shots: +" @ $stunShotsDamageBoost @ " damage to robotic targets";
	$EngineerLCplPassiveTalent = "Hackery: Hack consoles and modify PDAs";
	$EngineerCPLPassiveTalent = "Active Targeting: +" @ $activeTargetingAccuracyBoost @ "% accuracy";
	$EngineerSgtPassiveTalent = "Tech Upgrade: increased laser/plasma power";
}

// Apply Passive Talent effects on hit.
function applyPassiveTalentOnHitEffects (%characterIndex, %monster)
{//echo("applyPassiveTalentOnHitEffects()");
	switch ($playerSquad[%characterIndex].characterClass)
	{
		case 0:	// Leader.
			// Flak Rounds.
			if (getWord($playerSquad[%characterIndex].talents, 3) == 1)
			{
				%monster.armorRating -= $flakRoundsReduction;
				if (%monster.armorRating < 0)
				{
					%monster.armorRating = 0;
				}
			}
		
		case 1:	// Scout.
			// Stasis.
			if ($squadStasis	&&
				getWord($playerSquad[%characterIndex].talents, 6) == 1)		// Sanity check! Redundant since $squadStasis shouldn't be set anyway, but check just in case.
			{
				%monster.stasis = createStasisAnimation(%monster);
				$squadStasis = false;
			}
		
		case 2:	// Grenadier.
		
		case 3:	// Support.
		
		case 4:	// Engineer.
		
	}
}

// Apply armor resistances to mitigate damage.
function applyArmorResistances (%characterIndex, %damage, %damageType)
{//echo("applyArmorResistances()");
	%appliedDamage = %damage;
	switch$ (%damageType)
	{
		case "fire":		%appliedDamage -= $playerSquad[%characterIndex].armor.fireResistance;
		case "frost":		%appliedDamage -= $playerSquad[%characterIndex].armor.frostResistance;
		case "acid":		%appliedDamage -= $playerSquad[%characterIndex].armor.acidResistance;
		case "explosive":	%appliedDamage -= $playerSquad[%characterIndex].armor.explosiveResistance;
	}
	if (%appliedDamage < 0)
	{
		%appliedDamage = 0;
	}
	return %appliedDamage;
}

// Apply passive talent damage reductions.
function applyPassiveTalentDamageReduction (%characterIndex, %damage, %damageType)
{//echo("applyPassiveTalentDamageReduction()");echo("%damageType =" SPC %damageType);
	%appliedDamage = applyArmorResistances(%characterIndex, %damage, %damageType);
	
	switch ($playerSquad[%characterIndex].characterClass)
	{
		case 0:	// Leader.
			switch$ (%damageType)
			{
				case "physical":
					// Iron Resolve.
					if (getWord($playerSquad[%characterIndex].talents, 1) == 1)
					{
						%appliedDamage = mRound(%appliedDamage * ((100 - $ironResolveReduction) / 100));
					}
				
				case "fire":
					// Firefighter.
					if (getWord($playerSquad[%characterIndex].talents, 5) == 1)
					{
						%appliedDamage = mRound(%appliedDamage * ((100 - $fireFighterReduction) / 100));
					}
					
				
				case "acid":
					
			}
		
		case 1:	// Scout.
			switch$ (%damageType)
			{
				case "physical":
					// Second Skin.
					if (getWord($playerSquad[%characterIndex].talents, 1) == 1)
					{
						%appliedDamage = %appliedDamage - mRound($playerSquad[%characterIndex].maxActionPoints * ($secondSkinAPRatio / 100));
						if (%appliedDamage < 0)
						{
							%appliedDamage = 0;
						}
					}
				
				case "fire":
					
				
				case "acid":
					
			}
		
		case 2:	// Grenadier.
			switch$ (%damageType)
			{
				case "physical":
					
				
				case "fire":
					// Ablative Armor.
					if (getWord($playerSquad[%characterIndex].talents, 5) == 1)
					{
						%appliedDamage = mRound(%appliedDamage * ((100 - $ablativeArmorReduction) / 100));
					}
				
				case "acid":
					// Ablative Armor.
					if (getWord($playerSquad[%characterIndex].talents, 5) == 1)
					{
						%appliedDamage = mRound(%appliedDamage * ((100 - $ablativeArmorReduction) / 100));
					}
			}
		
		case 3:	// Support.
			switch$ (%damageType)
			{
				case "physical":
					
				
				case "fire":
					
				
				case "acid":
					
			}
		
		case 4:	// Engineer.
			switch$ (%damageType)
			{
				case "physical":
					
				
				case "fire":
					
				
				case "acid":
					
			}
	}
	
	return %appliedDamage;
}