📄 player.java
字号:
case 7 :
fVel[0]= -1 * m_iSpeed45;
fVel[1]= -1 * m_iSpeed45;
break;
}
}
Player CalcClosestTeamMateAI(boolean bInDir, int iDir, int fPosX, int fPosY)
{
int iCurDist = 99999;
int iIndex = 0;
boolean bNoDir = true;
if(bInDir == true)
{
for(int i = 0; i < 4; i++)
{
if(m_pTeamMates[i].GetSpecialAI()== 3)
continue;
int iDistX =(m_pTeamMates[i].GetPosX()- fPosX)>> 10;
int iDistY =(m_pTeamMates[i].GetPosY()- fPosY)>> 10;
int iDirDif = CalcDirectionAI(iDistX, iDistY)- iDir;
if((iDirDif < 2 && iDirDif > -2)||(iDirDif > 6 || iDirDif < -6))
{
int iDist =(iDistX * iDistX)+(iDistY * iDistY);
if(iDist < iCurDist)
{
iIndex = i;
iCurDist = iDist;
bNoDir = false;
}
}
}
}
if(bNoDir == true)
{
for(int i = 0; i < 4; i++)
{
if(m_pTeamMates[i].GetSpecialAI()== 3)
continue;
int iDistX =(m_pTeamMates[i].GetPosX()- fPosX)>> 10;
int iDistY =(m_pTeamMates[i].GetPosY()- fPosY)>> 10;
int iDist =(iDistX * iDistX)+(iDistY * iDistY);
if(iDist < iCurDist)
{
iIndex = i;
iCurDist = iDist;
}
}
}
return m_pTeamMates[iIndex];
}
boolean ChkValidTarget(int iPlayerIndex)
{
if(m_pTeamMates[iPlayerIndex].GetSpecialAI()!= 3
&&(m_fPos[1]* m_iOffenseDir < 0 ||
m_pTeamMates[iPlayerIndex].GetPosY()* m_iOffenseDir > 0))
{
return true;
}
return false;
}
Player CalcRandomTeamateAI()
{
int pSortOrder[]= new int[4];
pSortOrder[0]= 0;
pSortOrder[1]= 1;
pSortOrder[2]= 2;
pSortOrder[3]= 3;
for(int j = 0; j < 4; j++)
{
for(int i = 0; i < 3; i++)
{
if(m_pTeamMates[pSortOrder[i]].Get2ptShotRat()< m_pTeamMates[pSortOrder[i + 1]].Get2ptShotRat())
{
pSortOrder[i]= pSortOrder[i + 1];
pSortOrder[i + 1]= i;
}
}
}
int iRand = Basketball.GetRand()% 100;
if(iRand > 60 && ChkValidTarget(pSortOrder[0]))
return m_pTeamMates[pSortOrder[0]];
else if(iRand > 30 && ChkValidTarget(pSortOrder[1]))
return m_pTeamMates[pSortOrder[1]];
else if(iRand > 10 && ChkValidTarget(pSortOrder[2]))
return m_pTeamMates[pSortOrder[2]];
else if(iRand > 0 && ChkValidTarget(pSortOrder[3]))
return m_pTeamMates[pSortOrder[2]];
else
return null;
}
boolean ChkBlock()
{
int iRand = Basketball.GetRand()% 10;
if(iRand >(14 + 2 - m_iBlockRating))
{
DoRejection();
return true;
}
else if(iRand >(14 - m_iBlockRating))
{
DoTipp();
return true;
}
return false;
}
boolean ChkPlayerCol(Player pPlayer)
{
int fPosXA = m_fNextPos[0];
int fPosXB = pPlayer.GetNextPosX();
m_pColPlayer = pPlayer;
if(pPlayer.GetTeam()== m_iTeamIndex || Basketball.hGameWnd.ChkOBPlay(m_iTeamIndex)== true || Basketball.hGameWnd.ChkOBPlay(pPlayer.GetTeam())== true)
return false;
if(pPlayer.GetAnimState()== 4 && m_iAnimState == 1)
{
if(fPosXA +(3 << 10)>= fPosXB)
{
if(fPosXA -(3 << 10)<= fPosXB)
{
int fPosYA = m_fNextPos[1];
int fPosYB = pPlayer.GetNextPosY();
if(fPosYA +(3 << 10)>= fPosYB)
{
if(fPosYA -(3 << 10)<= fPosYB)
{
int iDirDif = CalcDirectionAI(fPosXB, fPosYB)- m_iMoveDir;
if((iDirDif < 2 && iDirDif > -2)||(iDirDif >= 6 || iDirDif <= -6))
{
HandlePlayerCol(pPlayer);
return true;
}
}
}
}
}
}
return false;
}
boolean ChkBallCol()
{
int iBallState = Basketball.hGameWnd.GetState();
if((iBallState != 0 && iBallState != 6 && iBallState != 5 && iBallState != 2 && iBallState != 8)
|| m_iAnimState == 8 || m_iAnimState == 16 || m_iAnimState == 9 || m_iAnimState == 7 || m_iAnimState == 2)
{
return false;
}
if(iBallState == 5)
{
if(m_iPlayerType != 1 || Basketball.hGameWnd.ChkOBPlay(m_iTeamIndex)== false || m_bTeamHasBall == false)
{
return false;
}
}
if(iBallState == 6 && m_bPassTarget == false)
return false;
int fBallX = Basketball.hGameWnd.GetPosX();
int fBallY = Basketball.hGameWnd.GetPosY();
int fBallZ = Basketball.hGameWnd.GetPosZ();
int fPlayerRad =(Basketball.hGameWnd.GetState()== 8)?(3 << 10)* 2 :(3 << 10);
if(m_fPos[0]+ fPlayerRad > fBallX -(512))
{
if(m_fPos[0]- fPlayerRad < fBallX +(512))
{
if(m_fPos[1]+ fPlayerRad > fBallY -(512))
{
if(m_fPos[1]- fPlayerRad < fBallY +(512))
{
if(m_iAnimState == 5)
{
if(m_fPos[2]+(45 << 10)> fBallZ -(512))
{
ChkBlock();
}
}
else if(m_fPos[2]+(20 << 10)> fBallZ -(512))
{
if(m_fPos[2]-(20 << 10)< fBallZ -(512))
{
m_iAssistCounter = 12;
CatchBall();
return true;
}
}
}
}
}
}
return false;
}
void ChkCourtBounds()
{
int fMaxX =(50 << 10)/ 2 - 1000;
int fMaxY =(94 << 10)/ 2;
if(Basketball.hGameWnd.ChkOBPlay(m_iTeamIndex))
{
fMaxX =(((50 + 6)/ 2)<< 10);
fMaxY =(((94 + 6)/ 2)<< 10);
}
if(m_fPos[2]< 0)
{
m_fPos[2]= 0;
}
if(Basketball.ABS(m_fPos[0])> fMaxX)
{
if(m_fPos[0]> 0)
m_fPos[0]= fMaxX;
else
m_fPos[0]= -fMaxX;
}
if(Basketball.ABS(m_fPos[1])> fMaxY)
{
if(m_fPos[1]> 0)
m_fPos[1]= fMaxY;
else
m_fPos[1]= -fMaxY;
}
}
boolean ChkAttemptSteal(Player pPlayer)
{
int iRand = Basketball.GetRand()% 10;
if(Basketball.ABS(iRand)> 6)
{
pPlayer.AttemptSteal();
return true;
}
return false;
}
void Action1()
{
int iBallState = Basketball.hGameWnd.GetState();
if(m_bAnimLock == true && m_iAnimState == 8)
{
if(m_pTarget != null)
{
m_pTarget.QueShot();
}
}
if(m_bAnimLock || ChkUserLockPlay())
return;
Player pBallHandler = Basketball.hGameWnd.GetControlPlayer();
int iBallHandlerState =(pBallHandler != null)? pBallHandler.GetAnimState(): 0;
if(m_bHasBall)
AttemptShot();
else if(iBallState == 1 || iBallState == 0 || iBallState == 7)
AttemptRebound();
else if(iBallHandlerState == 3 || iBallHandlerState == 1 || iBallHandlerState == 8 || iBallHandlerState == 14 || iBallHandlerState == 16)
AttemptSteal();
else if(m_bTeamHasBall == false)
AttemptBlock();
}
void Action2()
{
if(m_bAnimLock == true)
return;
if(ChkUserLockPlay()== true && m_iAIScriptedSpecial != 7)
return;
if(m_bHasBall == true)
{
int iTarget = - 999;
for(int i = 0; i < 4; i++)
{
if(m_pTeamMates[i].ChkCallForBall())
{
m_pTeamMates[i].SlowDownDefender();
if(i >= m_iPlayerType)
iTarget = i + 1;
else
iTarget = i;
break;
}
}
AttemptPass(iTarget); }
}
void Action3()
{
}
void CallForBall()
{
if(m_bUserTeam == false)
{
for(int i = 0; i < 4; i++)
{
if(m_pTeamMates[i].GetHasBall())
{
m_pTeamMates[i].AttemptPass(m_iPlayerType);
}
}
}
SetCallForPass(true);
}
void SetPassTarget(boolean bPassTarget, Player pPasser)
{
m_bPassTarget = bPassTarget;
if(m_bPassTarget == true)
{
m_pPassedFrom = pPasser;
for(int i = 0; i < 4; i++)
{
m_pTeamMates[i].SetPassTarget(false, null);
}
for(int j = 0; j < 5; j++)
{
m_pOpponents[j].SetPassTarget(false, null);
}
}
}
void StartAllyOOP()
{
CalcShotDistAI();
m_iAnimState = 16;
m_iAnimNum = 0;
m_bAnimLock = true;
FaceDir(m_pTarget.GetPosX(), m_pTarget.GetPosY(), true);
}
void EndAllyOOP()
{
if(m_bHasBall == false)
return;
int iTimeDistDelta = m_iShotDist / 7;
int iShotTime = 5 + iTimeDistDelta;
int fPosX = m_fPos[0];
int fPosY = m_fPos[1];
int fPosZ = m_fPos[2]+(m_iBallHandleY << 10);
int fVelX =(m_fShotDistX / iShotTime)* 8;
int fVelY =(m_fShotDistY / iShotTime)* 8;
int iGravity = 11000 * 2;
int fVelZ =((((30 << 10)- fPosZ)/ iShotTime)* 8)+((iGravity * iShotTime)/ 2);
Basketball.hGameWnd.SetVelocity(fVelX, fVelY, fVelZ);
Basketball.hGameWnd.SetPosition(fPosX, fPosY, fPosZ);
Basketball.hGameWnd.SetController(null);
Basketball.hGameWnd.SetState(8);
Basketball.hGameWnd.SetShotGood(false);
Basketball.hGameWnd.SetSpecialShot(true);
Basketball.hGameWnd.SetShotVal(2);
m_bHasBall = false;
}
void StartPass()
{
m_pTarget.SetPassTarget(true, this);
m_iAnimState = 8;
m_iAnimNum = 0;
m_bAnimLock = true;
FaceDir(m_pTarget.GetPosX(), m_pTarget.GetPosY(), true);
}
void EndPass()
{
if(m_bHasBall == false)
return;
int fPassDistX =(m_pTarget.GetPosX()- m_fPos[0]);
int fPassDistY =(m_pTarget.GetPosY()- m_fPos[1]);
int iDistX = fPassDistX >> 10;
int iDistY = fPassDistY >> 10;
int iDist = Basketball.sqrtN((iDistX * iDistX)+(iDistY * iDistY));
int iPassTime = 2 + iDist / 7;
int fPosX = m_fPos[0];
int fPosY = m_fPos[1];
int fPosZ = m_fPos[2]+(m_iBallHandleY << 10);
int fVelX =(fPassDistX / iPassTime)* 8;
int fVelY =(fPassDistY / iPassTime)* 8;
int fVelZ = 0;
Basketball.hGameWnd.SetVelocity(fVelX, fVelY, fVelZ);
Basketball.hGameWnd.SetPosition(fPosX, fPosY, fPosZ);
Basketball.hGameWnd.SetController(null);
Basketball.hGameWnd.SetState(6);
m_bHasBall = false;
FaceDir(m_pTarget.GetPosX(), m_pTarget.GetPosY(), true);
}
void AttemptShot()
{
if(m_bAnimLock == true)
return;
StartShot();
}
void AttemptPass(int iTarget)
{
if(m_bAnimLock == true)
return;
if(m_bHasBall == false)
return;
if(iTarget == - 99)
{
m_pTarget = CalcRandomTeamateAI();
if(m_pTarget == null)
return;
}
else if(iTarget == - 999)
{
m_pTarget = CalcClosestTeamMateAI(true, m_iDir, m_fPos[0], m_fPos[1]);
}
else
{
int iIndex = CalcIndexFromTargetAI(iTarget);
m_pTarget = m_pTeamMates[iIndex];
if(m_fPos[1]* m_iOffenseDir > 0 && m_pTarget.GetPosY()* m_iOffenseDir < 0)
return;
}
StartPass();
}
boolean AttemptSteal()
{
if(m_bAnimLock == true || Basketball.hGameWnd.ChkOBPlay(m_pGuard.GetTeam())== true)
return false;
Player pBallHandler = Basketball.hGameWnd.GetControlPlayer();
if(pBallHandler == null)
return false;
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(iDist > 16)
return false;
int iRand = Basketball.GetRand()% 10;
int iOffVal = pBallHandler.GetOffenseModifier();
int iStlVal = 6 - GetDefModifier()+ iOffVal;
m_fTargetPos[0]= m_fPos[0];
m_fTargetPos[1]= m_fPos[1];
m_iAnimState = 15;
m_iAnimNum = 0;
m_bAnimLock = true;
iStlVal +=(pBallHandler.GetPosY()* m_iOffenseDir > 0)? 0 : 2;
iStlVal +=(pBallHandler.GetManhattanDist()< 20)? -2 : 0;
if(iRand > iStlVal)
{
Basketball.hGameWnd.AddToTurnOvers(m_pGuard.GetTeam(), 1);
Basketball.hGameWnd.SetTurnOverFlag(m_pGuard.GetTeam(), true);
String pTmp;
iRand = Basketball.GetRand()& 0x0001;
switch(iRand)
{
case 0 :
pTmp = GetFamousName()+ " 断球";
break;
case 1 :
default :
pTmp = GetFamousName()+ " 断了他的球!";
break;
}
Basketball.hGameWnd.SetCommentary(pTmp);
m_iSteals++;
CatchBall();
m_bAnimLock = true;
}
else
{
SetJukedDelay(iOffVal);
}
return true;
}
void AttemptBlock()
{
if(m_bAnimLock == true)
return;
m_fTargetPos[0]= m_fPos[0];
m_fTargetPos[1]= m_fPos[1];
m_iAnimState = 5;
m_iAnimNum = 0;
m_bAnimLock = true;
Jump();
}
void AttemptRebound()
{
if(m_bAnimLock == true)
return;
int fPosX = Basketball.hGameWnd.GetPosX();
int fPosY = Basketball.hGameWnd.GetPosY();
int iDistX = Basketball.ABS((m_fPos[0]- fPosX)>> 10);
int iDistY = Basketball.ABS((m_fPos[1]- fPosY)>> 10);
int iDist =((iDistX * iDistX)+(iDistY * iDistY));
if(iDist < 16 || m_bUser)
{
m_fTargetPos[0]= m_fPos[0];
m_fTargetPos[1]= m_fPos[1];
m_iAnimState = 6;
m_iAnimNum = 0;
m_bAnimLock = true;
Jump();
}
}
void AttemptJuke()
{
int iRand = Basketball.GetRand()% 10;
int iDefVal =(m_pColPlayer != null)? m_pColPlayer.GetDefModifier(): 0;
int iJukeVal = 6 - m_iDribPassRating + iDefVal;
if(iRand > iJukeVal)
{
DoJuke();
DriveToHole();
}
else
{
DoStopped();
}
}
void StartShot()
{
CalcShotDistAI();
m_iAnimState = CalcShotTypeAI(m_iShotDist);
for(int i = 0; i < 2; i++)
{
m_fTargetPos[i]= m_fPos[i];
m_fNextPos[i]= m_fPos[i];
}
String pTmp;
int iRand = Basketball.GetRand()& 0x0003;
switch(m_iAnimState)
{
case 9 :
case 10 :
case 11 :
switch(iRand)
{
case 0 :
pTmp = GetFamousName()+ " 灌篮";
break;
case 1 :
pTmp = GetFamousName()+ " 灌篮!";
break;
case 2 :
pTmp = GetFamousName()+ " 灌篮!";
break;
case 3 :
default :
pTmp = GetFamousName()+ " 重扣!";
break;
}
Basketball.hGameWnd.SetCommentary(pTmp);
StartDunk();
break;
case 7 :
switch(iRand)
{
case 0 :
pTmp = m_pFirstName + " " + m_pLastName + " 跳投";
break;
case 1 :
pTmp = m_pFirstName + " " + m_pLastName + " 上篮!";
break;
case 2 :
pTmp = m_pFirstName + " " + m_pLastName + " 轻松得分!";
break;
case 3 :
default :
pTmp = m_pFirstName + " " + m_pLastName
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -