Pararena2/Sources/Computer.c

1 line
41 KiB
C
Raw Normal View History

//============================================================ //============================================================ //== == //== Computer Persona Handling Routines == //== == //============================================================ //============================================================ //======================================================== Includes #include "Globals.h" #include "UnivUtilities.h" #include "Computer.h" #include "Dynamics.h" #include "SoundUtils.h" //======================================================== Functions //======================================================== DiagonalToPlayer short DiagonalToPerson (playerType *who) { short newDirection; if (who->selector == kOpponentSelector) { if (thePlayer.xPos > theOpponent.xPos) { if (thePlayer.zPos > theOpponent.zPos) newDirection = kFacingNorthEast; else newDirection = kFacingSouthEast; } else { if (thePlayer.zPos > theOpponent.zPos) newDirection = kFacingNorthWest; else newDirection = kFacingSouthWest; } } else { if (theOpponent.xPos > thePlayer.xPos) { if (theOpponent.zPos > thePlayer.zPos) newDirection = kFacingNorthEast; else newDirection = kFacingSouthEast; } else { if (theOpponent.zPos > thePlayer.zPos) newDirection = kFacingNorthWest; else newDirection = kFacingSouthWest; } } return (newDirection); } //======================================================== DiagonalToBall short DiagonalToBall (playerType *who) { short newDirection; if (theBall.xPos > who->xPos) { if (theBall.zPos > who->zPos) newDirection = kFacingNorthEast; else newDirection = kFacingSouthEast; } else { if (theBall.zPos > who->zPos) newDirection = kFacingNorthWest; else newDirection = kFacingSouthWest; } return (newDirection); } //======================================================== OctalToPoint short OctalToPoint (playerType *who, register short xPos, register short zPos) { register long rise, run; short newDirection; if (xPos > who->xPos) { if (zPos > who->zPos) newDirection = kFacingNorthEast; else newDirection = kFacingSouthEast; } else { if (zPos > who->zPos) newDirection = kFacingNorthWest; else newDirection = kFacingSouthWest; } switch (newDirection) { case kFacingNorthEast: rise = (long)zPos - (long)who->zPos; run = (long)xPos - (long)who->xPos; if ((rise * 2) < run) { newDirection = kFacingEast; } else if (rise > (run * 2)) { newDirection = kFacingNorth; } else { newDirection = kFacingNorthEast; } break; case kFacingNorthWest: rise = (long)zPos - (long)who->zPos; run = (long)who->xPos - (long)xPos; if ((rise * 2) < run) { newDirection = kFacingWest; } else if (rise > (run * 2)) { newDirection = kFacingNorth; } else { newDirection = kFacingNorthWest; } break; case kFacingSouthEast: rise = (long)who->zPos - (long)zPos; run = (long)xPos - (long)who->xPos; if ((rise * 2) < run) { newDirection = kFacingEast; } else if (rise > (run * 2)) { newDirection = kFacingSouth; } else { newDirection = kFacingSouthEast; } break; case kFacingSouthWest: rise = (long)who->zPos - (long)zPos; run = (long)who->xPos - (long)xPos; if ((rise * 2) < run) { newDirection = kFacingWest; } else if (rise > (run * 2)) { newDirection = kFacingSouth; } else { newDirection = kFacingSouthWest; } break; } return (newDirection); } //======================================================== LookUpBoardForce void LookUpBoardForce (playerType *who) { short boardXForce, boardZForce; if ((who->justHitWall == 0) && (who->justHitOpponent == 0)) { boardXForce = boardForceTable[who->direction][kXComponent]; boardZForce = boardForceTable[who->direction][kZComponent]; if (who->bashApplied) { boardXForce *= 4; // 200% inc in board force