--/////////////////////////////////////////////////////////////////////////////// --// fighting.lua --// --// Comments: This file contains the scripting functions provided for tuning --// the fighting. --// --// Copyright 2003 Microsoft Corporation, All Rights Reserved --/////////////////////////////////////////////////////////////////////////////// --/////////////////////////////////////////////////////////////////////////////// --// --// --// PRE FIGHT --// --// --/////////////////////////////////////////////////////////////////////////////// --///////////////////////////////////////////////////////////////////////////// --// The match up is determined by who the opponents are. --// An Enforcer against an Enforcer has a very high chance --// that a fight will take place. Where a Sniper vs. an Enforcer is very low. --///////////////////////////////////////////////////////////////////////////// Matchup_Table = { Enforcer = { Enforcer = 70, Agitator = 60, Balanced = 60, Sniper = 60, Goalie = 0, }, Agitator = { Enforcer = 40, Agitator = 60, Balanced = 50, Sniper = 70, Goalie = 0, }, Balanced = { Enforcer = 50, Agitator = 50, Balanced = 50, Sniper = 50, Goalie = 0, } Sniper = { Enforcer = 20, Agitator = 30, Balanced = 30, Sniper = 40, Goalie = 0, }, Goalie = { Enforcer = 0, Agitator = 0, Balanced = 0, Sniper = 0, Goalie = 0, }, } --///////////////////////////////////////////////////////////////////////////// --// The fuse will be a modifier to the player Match up. --// A person that has a very high fuse will reduce the chance a fight takes place. --///////////////////////////////////////////////////////////////////////////// FuseLevel_Table = { Furious = 25, Frustrated = 15, Annoyed = 0, Normal = -10, Good = -20, Awesome = -30, } --///////////////////////////////////////////////////////////////////////////// --// The Composure will also be modifier that reduces or --// increase the chance of the AI wanting to fight. --///////////////////////////////////////////////////////////////////////////// ComposureLevel_Table = { {100, 0 }, {90, 0 }, {80, 0 }, {70, 0 }, {60, -5 }, {50, -10 }, {40, -20 }, {30, -30 }, {20, -40 }, {10, -50 }, } --///////////////////////////////////////////////////////////////////////////// --// If the AI opponent is tired or ready to go will affect the decision to fight. --///////////////////////////////////////////////////////////////////////////// StaminaLevel_Table = { { 100, 0 }, { 90, 0 }, { 80, 0 }, { 70, 0 }, { 60, -5 }, { 50, -10 }, { 40, -20 }, { 30, -30 }, { 20, -40 }, { 10, -50 }, { 0, -60 }, } --///////////////////////////////////////////////////////////////////////////// --// How tough are you. If the AI can take a punch and dish it out will affect --// the fight decision. --///////////////////////////////////////////////////////////////////////////// StrengthDifference_Table = { { 100, 50 }, { 90, 45 }, { 80, 40 }, { 70, 35 }, { 60, 30 }, { 50, 25 }, { 40, 20 }, { 30, 15 }, { 20, 10 }, { 10, 5 }, { 0, 0 }, {-10, -5 }, {-20, -10 }, {-30, -15 }, {-40, -20 }, {-50, -25 }, {-60, -30 }, {-70, -35 }, {-80, -40 }, {-90, -45 }, {-100, -50 }, } --///////////////////////////////////////////////////////////////////////////// --// AI Button press rate table --///////////////////////////////////////////////////////////////////////////// AIButtonPressRate_Table = { BeerLeague = 4, College = 4, Pro = 3, AllStar = 2, } --///////////////////////////////////////////////////////////////////////////// --// How much a button press affect the --///////////////////////////////////////////////////////////////////////////// PercEffectFightBar_Table = { BeerLeague = 10, College = 7.5, Pro = 7.5, AllStar = 5, } --///////////////////////////////////////////////////////////////////////////// --// --// Function : Fight_PreDoesAIWantToFight --// --// Purpose: --// Make fight decision Match Up + Fuse + Composure + Stamina + Strength rating = Fight Decision --// These numbers are derived from the players ratings and applied to the tables aboves --// --// Parameters: --// szAIPlayerRole - (string) The AIPlayer role name --// szAIPlayerFuse - (string) The AIPlayer fuse value --// iAIPlayerComposure - (int) The AIPlayer composure rating --// iAIPlayerStamina - (int) The AIPlayer stamina rating --// iAIPlayerStrength - (int) The AIPlayer strenght rating --// szOppPlayerRole - (string) The OppPlayer role name --// szOppPlayerFuse - (string) The OppPlayer fuse value --// iOppPlayerComposure - (int) The OppPlayer composure rating --// iOppPlayerStamina - (int) The OppPlayer stamina stamina --// iOppPlayerStrength - (int) The OppPlayer strength rating --// --// Returns: --// [1] - Boolean if the AI should fight or not --// --///////////////////////////////////////////////////////////////////////////// function Fight_PreDoesAIWantToFight( szAIPlayerRole, szAIPlayerFuse, iAIPlayerComposure, iAIPlayerStamina, iAIPlayerStrength, szOppPlayerRole, szOppPlayerFuse, iOppPlayerComposure, iOppPlayerStamina, iOppPlayerStrength ) --// Calculate the AIMatchup local iAIMatchup = Matchup_Table[szAIPlayerRole][szOppPlayerRole] --// Calculate the AIFuseLevel local iAIFuseLevel = FuseLevel_Table[szAIPlayerFuse] --// Calculate the AIComposure for iIndex = 1, table.getn(ComposureLevel_Table) do if( iAIPlayerComposure >= ComposureLevel_Table[iIndex][1] ) then iAIComposureLevel = ComposureLevel_Table[iIndex][2] break end end --// Calculate the AIStamina local iAIStaminaLevel for iIndex = 1, table.getn(StaminaLevel_Table) do if( iAIPlayerStamina >= StaminaLevel_Table[iIndex][1] ) then iAIStaminaLevel = StaminaLevel_Table[iIndex][2] break end end --// Calculate the AIStrengthDifference local iAIStrengthDifference for iIndex = 1, table.getn(StrengthDifference_Table) do if( (iAIPlayerStrength - iOppPlayerStrength) >= StrengthDifference_Table[iIndex][1] ) then iAIStrengthDifference = StrengthDifference_Table[iIndex][2] break end end --// Calculate the AI fight value local iAIFightValue = iAIMatchup + iAIFuseLevel + iAIComposureLevel + iAIStaminaLevel + iAIStrengthDifference --// Calculate the OppMatchup local iOppMatchup = Matchup_Table[szOppPlayerRole][szAIPlayerRole] --// Calculate the OppFuseLevel local iOppFuseLevel = FuseLevel_Table[szOppPlayerFuse] --// Calculate the OppComposure local iOppComposureLevel for iIndex = 1, table.getn(ComposureLevel_Table) do if( iOppPlayerComposure >= ComposureLevel_Table[iIndex][1] ) then iOppComposureLevel = ComposureLevel_Table[iIndex][2] break end end --// Calculate the OppStamina local iOppStaminaLevel for iIndex = 1, table.getn(StaminaLevel_Table) do if( iOppPlayerStamina >= StaminaLevel_Table[iIndex][1] ) then iOppStaminaLevel = StaminaLevel_Table[iIndex][2] break end end --// Calculate the OppStrengthDifference local iOppStrengthDifference for iIndex = 1, table.getn(StrengthDifference_Table) do if( (iOppPlayerStrength - iAIPlayerStrength) >= StrengthDifference_Table[iIndex][1] ) then iOppStrengthDifference = StrengthDifference_Table[iIndex][2] break end end --// Calculate the Opp fight value local iOppFightValue = iOppMatchup + iOppFuseLevel + iOppComposureLevel + iOppStaminaLevel + iOppStrengthDifference return (iAIFightValue > iOppFightValue) end --// function Fight_PreDoesAIWantToFight --///////////////////////////////////////////////////////////////////////////// --// --// Function : Fight_PrePercEffectFightBar --// --// Purpose: --// Retrieve the effect on the fight bar when we have a button press --// --// Parameters: --// DifficultyLevel - (string) The difficulty level --// --// Returns: --// [1] - The percentage effect of the fight bar --// --///////////////////////////////////////////////////////////////////////////// function Fight_PrePercEffectFightBar( DifficultyLevel ) return PercEffectFightBar_Table[DifficultyLevel] end --// function Fight_PrePercEffectFightBar --///////////////////////////////////////////////////////////////////////////// --// --// Function : Fight_PreAIButtonPressRate --// --// Purpose: --// Retrieve the effect on the fight bar when we have a button press --// --// Parameters: --// DifficultyLevel - (string) The difficulty level --// --// Returns: --// [1] - The AI Button press rate --// --///////////////////////////////////////////////////////////////////////////// function Fight_PreAIButtonPressRate( DifficultyLevel ) return AIButtonPressRate_Table[DifficultyLevel] end --// function Fight_PreAIButtonPressRate --/////////////////////////////////////////////////////////////////////////////// --// --// --// FIGHT! --// --// --/////////////////////////////////////////////////////////////////////////////// --// This is the tables from section 9.2.1 of the doc --// Determines how likely each player type is to block, punch, or do nothing --// This is a three dimensional table - Table[playerType][OtherPlayerType][ePunch] ActionDecision_Table = { Balanced = { Enforcer = { Punch = 60, Block = 30 }, Agitator = { Punch = 60, Block = 30 }, Balanced = { Punch = 60, Block = 30 }, Sniper = { Punch = 60, Block = 30 } }, Enforcer = { Enforcer = { Punch = 55, Block = 35 }, Agitator = { Punch = 55, Block = 35 }, Balanced = { Punch = 60, Block = 30 }, Sniper = { Punch = 30, Block = 70 } }, Agitator = { Enforcer = { Punch = 70, Block = 25 }, Agitator = { Punch = 70, Block = 20 }, Balanced = { Punch = 60, Block = 30 }, Sniper = { Punch = 40, Block = 60 } }, Sniper = { Enforcer = { Punch = 75, Block = 20 }, Agitator = { Punch = 75, Block = 20 }, Balanced = { Punch = 60, Block = 30 }, Sniper = { Punch = 50, Block = 50 } }, } PunchDecision_Table = { Balanced = { Enforcer = { Jab = 25, HeavyPunch = 30, Uppercut = 15, GrabAndPunch = 30 }, Agitator = { Jab = 40, HeavyPunch = 30, Uppercut = 10, GrabAndPunch = 20 }, Sniper = { Jab = 60, HeavyPunch = 20, Uppercut = 10, GrabAndPunch = 10 }, Balanced = { Jab = 30, HeavyPunch = 30, Uppercut = 20, GrabAndPunch = 20 } }, Enforcer = { Enforcer = { Jab = 25, HeavyPunch = 30, Uppercut = 20, GrabAndPunch = 25 }, Agitator = { Jab = 30, HeavyPunch = 25, Uppercut = 30, GrabAndPunch = 15 }, Sniper = { Jab = 35, HeavyPunch = 20, Uppercut = 25, GrabAndPunch = 20 }, Balanced = { Jab = 25, HeavyPunch = 30, Uppercut = 20, GrabAndPunch = 25 } }, Agitator = { Enforcer = { Jab = 25, HeavyPunch = 30, Uppercut = 15, GrabAndPunch = 30 }, Agitator = { Jab = 25, HeavyPunch = 30, Uppercut = 15, GrabAndPunch = 30 }, Sniper = { Jab = 35, HeavyPunch = 30, Uppercut = 15, GrabAndPunch = 20 }, Balanced = { Jab = 25, HeavyPunch = 30, Uppercut = 15, GrabAndPunch = 30 } }, Sniper = { Enforcer = { Jab = 25, HeavyPunch = 25, Uppercut = 15, GrabAndPunch = 35 }, Agitator = { Jab = 25, HeavyPunch = 30, Uppercut = 15, GrabAndPunch = 30 }, Sniper = { Jab = 25, HeavyPunch = 30, Uppercut = 15, GrabAndPunch = 30 }, Balanced = { Jab = 25, HeavyPunch = 30, Uppercut = 15, GrabAndPunch = 30 } }, } BlockDecision_Table = { Balanced = { Enforcer = { Block = 30, Duck = 30, Left = 10, Right = 10, Back = 20 }, Agitator = { Block = 30, Duck = 30, Left = 10, Right = 10, Back = 20 }, Sniper = { Block = 30, Duck = 30, Left = 10, Right = 10, Back = 20 }, Balanced = { Block = 30, Duck = 30, Left = 10, Right = 10, Back = 20 }, }, Enforcer = { Enforcer = { Block = 25, Duck = 30, Left = 7, Right = 8, Back = 30 }, Agitator = { Block = 25, Duck = 30, Left = 7, Right = 8, Back = 30 }, Sniper = { Block = 25, Duck = 30, Left = 7, Right = 8, Back = 30 }, Balanced = { Block = 25, Duck = 30, Left = 7, Right = 8, Back = 30 }, }, Agitator = { Enforcer = { Block = 40, Duck = 30, Left = 5, Right = 5, Back = 20 }, Agitator = { Block = 40, Duck = 30, Left = 5, Right = 5, Back = 20 }, Sniper = { Block = 40, Duck = 30, Left = 5, Right = 5, Back = 20 }, Balanced = { Block = 40, Duck = 30, Left = 5, Right = 5, Back = 20 }, }, Sniper = { Enforcer = { Block = 60, Duck = 20, Left = 5, Right = 5, Back = 10 }, Agitator = { Block = 60, Duck = 20, Left = 5, Right = 5, Back = 10 }, Sniper = { Block = 60, Duck = 20, Left = 5, Right = 5, Back = 10 }, Balanced = { Block = 60, Duck = 20, Left = 5, Right = 5, Back = 10 }, }, } --// --// Use to get whether the player blocks, punches, or nothing --// function Fight_AIDecision( szPlayerRole, szOppPlayerRole, szPunchOrBlock ) return ActionDecision_Table[szPlayerRole][szOppPlayerRole][szPunchOrBlock] end function Fight_AIPunchDecision( szPlayerRole, szOppPlayerRole, szPunchType ) return PunchDecision_Table[szPlayerRole][szOppPlayerRole][szPunchType] end function Fight_AIBlockDecision( szPlayerRole, szOppPlayerRole, szBlockType ) return BlockDecision_Table[szPlayerRole][szOppPlayerRole][szBlockType] end