📄 player.java
字号:
for(int i = 0; i < 5; i++)
{
int fGuardPosY = m_pOpponents[i].GetPosY()* m_iOffenseDir;
if(fGuardPosY > fPosY || fGuardPosY >(35 << 10))
iDefendersBack++;
}
if(iDefendersBack <= 1)
{
DriveToHole();
return true;
}
return false;
}
boolean ChkShotClockAI()
{
if(Basketball.hGameWnd.m_iShotSecs < 3000 || Basketball.hGameWnd.m_iQtrTime < 3000)
{
AttemptShot();
return true;
}
return false;
}
boolean ChkReallyCloseToBasket()
{
if(m_iManhattanShotDist < 8)
{
if(CalcGoodShotAI()== true)
{
AttemptShot();
return true;
}
}
return false;
}
boolean ChkUnguarded()
{
if(m_fPos[1]* m_iOffenseDir < 13000)
return false;
for(int i = 0; i < 5; i++)
{
int iDistX = Basketball.ABS(m_fPos[0]- m_pOpponents[i].GetPosX())>> 10;
int iDistY = Basketball.ABS(m_fPos[1]- m_pOpponents[i].GetPosY())>> 10;
if(iDistX + iDistY < 9)
return false;
}
return true;
}
boolean ChkWideAssOpen()
{
if(ChkUnguarded()== false)
return false;
int iRand = Basketball.GetRand()% 100;
if(iRand > 35)
{
AttemptShot();
return true;
}
else
{
DriveToHole();
}
return false;
}
void updateOffenseNextPlayPosAI()
{
try
{
int fOutboundX = 0;
int fOutboundY = 0;
int pPlay_Pos[];
switch(m_iAIOffenseTeamState)
{
case 16 :
pPlay_Pos = OUTBOUNDS_POS[m_iAIPlayerState][m_iPlayerType];
fOutboundX = Basketball.hGameWnd.GetOutbound(0);
fOutboundY = Basketball.hGameWnd.GetOutbound(1);
break;
case 17 :
pPlay_Pos = USROUTBOUNDS_POS[m_iAIPlayerState][m_iPlayerType];
fOutboundX = Basketball.hGameWnd.GetOutbound(0);
fOutboundY = Basketball.hGameWnd.GetOutbound(1);
break;
case 11 :
pPlay_Pos = INBOUND_POS[m_iAIPlayerState][m_iPlayerType];
fOutboundY = Basketball.hGameWnd.GetPosY();
break;
case 15 :
pPlay_Pos = USERINBOUND_POS[m_iAIPlayerState][m_iPlayerType];
fOutboundY = Basketball.hGameWnd.GetPosY();
break;
case 13 :
pPlay_Pos = FASTBREAK_POS[m_iAIPlayerState][m_iPlayerType];
break;
case 14 :
pPlay_Pos = SLOWBREAK_POS[m_iAIPlayerState][m_iPlayerType];
break;
case 0 :
pPlay_Pos = ISOLATION_POS[m_iAIPlayerState][m_iPlayerType];
break;
case 1 :
pPlay_Pos = HIGHSCRN_POS[m_iAIPlayerState][m_iPlayerType];
break;
case 2 :
pPlay_Pos = LOWSCRN_POS[m_iAIPlayerState][m_iPlayerType];
break;
case 3 :
pPlay_Pos = HIGHPST_POS[m_iAIPlayerState][m_iPlayerType];
break;
case 4 :
pPlay_Pos = LOWPST_POS[m_iAIPlayerState][m_iPlayerType];
break;
case 5 :
pPlay_Pos = PICKNROLL_POS[m_iAIPlayerState][m_iPlayerType];
break;
case 6 :
pPlay_Pos = PIKFNCE_POS[m_iAIPlayerState][m_iPlayerType];
break;
case 7 :
pPlay_Pos = GIVNGO_POS[m_iAIPlayerState][m_iPlayerType];
break;
case 8 :
pPlay_Pos = CORNER3_POS[m_iAIPlayerState][m_iPlayerType];
break;
case 9 :
default :
pPlay_Pos = PERIMETER_POS[m_iAIPlayerState][m_iPlayerType];
break;
}
int iSideX = 1;
if(fOutboundX < 0)
iSideX = -1;
int iSideY = 1;
if(fOutboundY < 0)
iSideY = -1;
m_fTargetPos[0]= iSideX *(pPlay_Pos[0]<< 10);
m_fTargetPos[1]= iSideY *(pPlay_Pos[1]<< 10);
m_fTargetPos[1]*=(fOutboundY == 0)? m_iOffenseDir : 1;
m_fTargetPos[1]+=(fOutboundX != 0)? CalcOutboundYOffset(fOutboundY): 0;
m_iAIDelayCounter = pPlay_Pos[2];
m_iAIScriptedSpecial = pPlay_Pos[3];
m_iAIScriptedTarget = pPlay_Pos[4];
m_iInPosDelta = pPlay_Pos[5];
m_iAIPlayState = m_iAIPlayerState;
}
catch(Exception e)
{
}
}
int CalcOutboundYOffset(int fOutboundY)
{
if(Basketball.ABS(m_fTargetPos[1]+ fOutboundY)>(((94 + 6)/ 2)<< 10))
return - fOutboundY;
return fOutboundY;
}
void updateDefenseAI()
{
if(ChkHighPriorityDefenseSituationAI()== true)
return;
switch(m_iAIDefenseTeamState)
{
case 1 :
updateZoneAI();
break;
case 2 :
case 0 :
default :
updateManToManAI();
break;
}
FaceDir(m_pGuard.GetPosX(), m_pGuard.GetPosY(), false);
}
boolean ChkHighPriorityDefenseSituationAI()
{
if(m_iPlayerType == 3 || m_iPlayerType == 4)
{
Player pBallHandler = Basketball.hGameWnd.GetControlPlayer();
if(pBallHandler != null && pBallHandler != m_pGuard)
{
if(pBallHandler.GetDistBasket()< 8 || pBallHandler.GetGuardPlayer().GetJukeDelay()> 0)
{
if(pBallHandler.GetDistBasket()< 8)
CalcGuardPositionAI(pBallHandler.GetPosX(), pBallHandler.GetPosY());
else
{
GoToBasketDefense();
ChkGuardSpecial(pBallHandler);
FaceDir(pBallHandler.GetPosX(), pBallHandler.GetPosY(), false);
return true;
}
}
}
}
return false;
}
void updateReboundAI()
{
if(m_bReboundBall == false)
return;
if(Basketball.hGameWnd.GetPosZ()>(25 << 10)&& Basketball.hGameWnd.GetVelZ()< 0)
{
int fBouncePosX = Basketball.hGameWnd.GetNextBounceX();
int fBouncePosY = Basketball.hGameWnd.GetNextBounceY();
int iDistX = Basketball.ABS((fBouncePosX - m_fPos[0])>> 10);
int iDistY = Basketball.ABS((fBouncePosY - m_fPos[1])>> 10);
int iDist =(iDistX * iDistX)+(iDistY * iDistY);
if(iDist < 6)
{
AttemptRebound();
}
else
{
m_fTargetPos[0]= fBouncePosX;
m_fTargetPos[1]= fBouncePosY;
}
}
else
{
m_fTargetPos[0]= Basketball.hGameWnd.GetPosX();
m_fTargetPos[1]= Basketball.hGameWnd.GetPosY();
}
FaceDir(Basketball.hGameWnd.GetPosX(), Basketball.hGameWnd.GetPosY(), false);
}
void updateLooseBallAI()
{
m_fTargetPos[0]= Basketball.hGameWnd.GetPosX();
m_fTargetPos[1]= Basketball.hGameWnd.GetPosY();
}
void updateManToManAI()
{
int fGuardX = m_pGuard.GetPosX();
int fGuardY = m_pGuard.GetPosY();
if(m_iAIDefenseTeamState == 0 && fGuardY * m_iOffenseDir > 0)
{
GoToPosition();
return;
}
else
{
CalcGuardPositionAI(fGuardX, fGuardY);
}
if(m_pGuard.GetHasBall()== true)
{
ChkGuardSpecial(m_pGuard);
}
}
void updateZoneAI()
{
Player pBallHandler = Basketball.hGameWnd.GetControlPlayer();
if(pBallHandler == null)
{
GoToPosition();
return;
}
int fGuardX = pBallHandler.GetPosX();
int fGuardY = pBallHandler.GetPosY();
int iDistX = Basketball.ABS((fGuardX - m_fPos[0])>> 10);
int iDistY = Basketball.ABS((fGuardY - m_fPos[1])>> 10);
int iDist =(iDistX * iDistX)+(iDistY * iDistY);
if(fGuardY * m_iOffenseDir > 0)
{
GoToPosition();
}
else if(iDist < 16)
{
ChkGuardSpecial(pBallHandler);
}
else if(iDist < 16 * 2 || m_pGuard.GetHasBall())
{
CalcGuardPositionAI(fGuardX, fGuardY);
}
else
{
GoToPosition();
}
}
int CalcDirectionAI(int iDeltaX, int iDeltaY)
{
int iDir;
if(iDeltaX > 0)
{
if(iDeltaY > 0)
{
if(Basketball.ABS(iDeltaX)> 2 * Basketball.ABS(iDeltaY))
iDir = 4;
else if(Basketball.ABS(iDeltaY)> 2 * Basketball.ABS(iDeltaX))
iDir = 2;
else
iDir = 3;
}
else
{
if(Basketball.ABS(iDeltaX)> 2 * Basketball.ABS(iDeltaY))
iDir = 4;
else if(Basketball.ABS(iDeltaY)> 2 * Basketball.ABS(iDeltaX))
iDir = 6;
else
iDir = 5;
}
}
else
{
if(iDeltaY > 0)
{
if(Basketball.ABS(iDeltaX)> 2 * Basketball.ABS(iDeltaY))
iDir = 0;
else if(Basketball.ABS(iDeltaY)> 2 * Basketball.ABS(iDeltaX))
iDir = 2;
else
iDir = 1;
}
else
{
if(Basketball.ABS(iDeltaX)> 2 * Basketball.ABS(iDeltaY))
iDir = 0;
else if(Basketball.ABS(iDeltaY)> 2 * Basketball.ABS(iDeltaX))
iDir = 6;
else
iDir = 7;
}
}
return iDir;
}
void CalcGuardPositionAI(int fGuardX, int fGuardY)
{
int fDeltaX =(0 << 10)- fGuardX;
int fDeltaY =((42 << 10)* -m_iOffenseDir)- fGuardY;
int iDir = CalcDirectionAI(fDeltaX, fDeltaY);
int fVel[]= new int[2];
CalcVelocityAI(iDir, fVel);
int iDistRatio = 3;
m_fTargetPos[0]= fGuardX +(iDistRatio * fVel[0])/ 8;
m_fTargetPos[1]= fGuardY +(iDistRatio * fVel[1])/ 8;
}
boolean ChkGuardSpecial(Player pPlayer)
{
int fGuardX = pPlayer.GetPosX();
int fGuardY = pPlayer.GetPosY();
int iDistX = Basketball.ABS((fGuardX - m_fPos[0])>> 10);
int iDistY = Basketball.ABS((fGuardY - m_fPos[1])>> 10);
int iDist =(iDistX * iDistX)+(iDistY * iDistY);
if(iDist < 16 && m_iManhattanShotDist < pPlayer.GetManhattanDist())
{
int iGuardState = pPlayer.GetAnimState();
if(iGuardState == 2 || iGuardState == 7 || iGuardState == 9)
{
AttemptBlock();
}
else
{
m_fTargetPos[0]= m_fPos[0];
m_fTargetPos[1]= m_fPos[1];
m_iAnimState = 4;
}
return true;
}
return false;
}
int CalcShotTypeAI(int iShotDist)
{
if(iShotDist < 8)
{
int iDeltaX =(0 << 10)- m_fPos[0];
int iDeltaY =(m_iOffenseDir *(42 << 10))- m_fPos[1];
int iDir = CalcDirectionAI(iDeltaX, iDeltaY);
if((m_iOffenseDir > 0 &&(iDir == 6 || iDir == 5 || iDir == 7))||(m_iOffenseDir < 0 &&(iDir == 1 || iDir == 2 || iDir == 3)))
return 2;
int iRand = Basketball.GetRand()% 10;
if(iRand >=((m_bUserTeam)? 10 : 11)- m_iDunkRating)
return 9;
if(iRand > 1)
return 7;
}
return 2;
}
boolean CalcShotMissAI()
{
int iRand = Basketball.GetRand()% 100;
int iMinMakeVal = 0;
int iAICatchUpModifier = 0;
int iDifferential = Basketball.hGameWnd.GetTotalScore(m_pGuard.GetTeam())- Basketball.hGameWnd.GetTotalScore(m_iTeamIndex);
if(iDifferential > 15)
iAICatchUpModifier = 15;
else if(iDifferential > 10)
iAICatchUpModifier = 10;
else if(iDifferential > 5)
iAICatchUpModifier = 5;
int iDefModifier = 0;
int iMaxDRangeX =(m_bUserTeam)? 4 + 1 : 4;
int iMaxDRangeY =(m_bUserTeam)? 4 + 1 : 4;
for(int i = 0; i < 5; i++)
{
int iDistX = Basketball.ABS(m_fPos[0]- m_pOpponents[i].GetPosX())>> 10;
int iDistY = Basketball.ABS(m_fPos[1]- m_pOpponents[i].GetPosY())>> 10;
if(iDistX <= iMaxDRangeX && iDistY <= iMaxDRangeY && m_pOpponents[i].GetManhattanDist()<= m_iManhattanShotDist)
{
iDefModifier += m_pOpponents[i].GetDefModifier()*((m_bUserTeam)? 4 : 4);
}
}
int iPosX = Basketball.ABS(m_fPos[0])>> 10;
int iPosY = Basketball.ABS(m_fPos[1])>> 10;
int iVal =(THREEPOINTRANGE[iPosX]>= iPosY || m_iShotDist > 27)? 3 : 2;
int iComputerModifier =(m_bUserTeam)? 0 :(iVal == 3)? 1 : 4;
switch(m_iAnimState)
{
case 9 :
break;
case 7 :
iMinMakeVal =((10 - m_i2ptShotRating - iComputerModifier)* 2)- iAICatchUpModifier;
break;
case 2 :
if(iVal == 3)
{
iMinMakeVal = CalcJumpShotMake(m_i3ptShotRating - 2 - iComputerModifier, 22, iDefModifier)- iAICatchUpModifier;
}
else
{
iMinMakeVal = CalcJumpShotMake(m_i2ptShotRating - iComputerModifier, 8, iDefModifier)- iAICatchUpModifier;
}
default :
break;
}
if(iRand > iMinMakeVal)
return true;
return false;
}
int CalcJumpShotMake(int iRating, int iDistMark, int iDefModifier)
{
int iStepSize = 3;
if(iDistMark == 22)
iStepSize = 1;
int iDistModifier =((m_iShotDist - iDistMark)/ iStepSize)* 5;
iDistModifier =(m_iShotDist > 30)? 80 : 0;
int iRatsModifier =(10 - iRating)* 6;
return iDistModifier + iRatsModifier + iDefModifier;
}
boolean CalcGoodShotAI()
{
int iRand = Basketball.GetRand()% 100;
CalcShotDistAI();
int iMinMakeVal;
int iDefModifier = 0;
for(int i = 0; i < 5; i++)
{
int iDistX = Basketball.ABS(m_fPos[0]- m_pOpponents[i].GetPosX())>> 10;
int iDistY = Basketball.ABS(m_fPos[1]- m_pOpponents[i].GetPosY())>> 10;
if(iDistX < 4 && iDistY < 4 && m_iManhattanShotDist < m_pOpponents[i].GetManhattanDist())
{
iDefModifier += m_pOpponents[i].GetDefModifier()* 4;
}
}
if(m_iShotDist > 30)
{
return false;
}
else if(m_iShotDist > 27)
{
iMinMakeVal = CalcJumpShotMake(m_i3ptShotRating - 2, 22, iDefModifier);
}
else if(m_iShotDist > 22)
{
iMinMakeVal = CalcJumpShotMake(m_i3ptShotRating - 2, 22, iDefModifier);
}
else
{
iMinMakeVal = CalcJumpShotMake(m_i3ptShotRating - 2, 22, iDefModifier);
}
iMinMakeVal +=(m_iPlayerType == 0)? 20 : 0;
if(iRand > iMinMakeVal)
return true;
return false;
}
void CalcDunkDistAI()
{
int fRimPosY =(42 << 10)- 2000;
int fRimPosX =(0 << 10);
if(m_iOffenseDir == -1)
fRimPosY = -fRimPosY;
if(m_fPos[0]> 2000)
fRimPosX = 1000;
else if(m_fPos[0]< -2000)
fRimPosX = -1000;
m_fShotDistX = fRimPosX - m_fPos[0];
m_fShotDistY = fRimPosY - m_fPos[1];
int iShotDistX = m_fShotDistX >> 10;
int iShotDistY = m_fShotDistY >> 10;
m_iShotDist = Basketball.sqrtN(((iShotDistX * iShotDistX)+(iShotDistY * iShotDistY)));
}
void CalcShotDistAI()
{
m_fShotDistX =(0 << 10)- m_fPos[0];
m_fShotDistY =(m_iOffenseDir *(42 << 10))- m_fPos[1];
int iShotDistX = m_fShotDistX >> 10;
int iShotDistY = m_fShotDistY >> 10;
m_iShotDist = Basketball.sqrtN(((iShotDistX * iShotDistX)+(iShotDistY * iShotDistY)));
}
int CalcManhattanShotDistAI()
{
int iShotDistY;
int iShotDistX = Basketball.ABS((0 << 10)- m_fPos[0])>> 10;
if(m_bTeamHasBall)
iShotDistY = Basketball.ABS((m_iOffenseDir *(42 << 10))- m_fPos[1])>> 10;
else
iShotDistY = Basketball.ABS((- m_iOffenseDir *(42 << 10))- m_fPos[1])>> 10;
m_iManhattanShotDist = iShotDistX + iShotDistY;
return m_iManhattanShotDist;
}
int CalcIndexFromTargetAI(int iTarget)
{
int iIndex = iTarget;
if(iTarget > m_iPlayerType)
iIndex -= 1;
return iIndex;
}
void CalcVelocityAI(int iDir, int fVel[])
{
switch(iDir)
{
case 0 :
fVel[0]= -1 * m_iSpeed90;
fVel[1]= 0 * m_iSpeed90;
break;
case 1 :
fVel[0]= -1 * m_iSpeed45;
fVel[1]= 1 * m_iSpeed45;
break;
case 2 :
fVel[0]= 0 * m_iSpeed90;
fVel[1]= 1 * m_iSpeed90;
break;
case 3 :
fVel[0]= 1 * m_iSpeed45;
fVel[1]= 1 * m_iSpeed45;
break;
case 4 :
fVel[0]= 1 * m_iSpeed90;
fVel[1]= 0 * m_iSpeed90;
break;
case 5 :
fVel[0]= 1 * m_iSpeed45;
fVel[1]= -1 * m_iSpeed45;
break;
case 6 :
fVel[0]= 0 * m_iSpeed90;
fVel[1]= -1 * m_iSpeed90;
break;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -