Pararena2/Sources/CommonPerson.c

1 line
12 KiB
C
Raw Normal View History

//============================================================ //============================================================ //== == //== Common Person Handling Routines == //== == //============================================================ //============================================================ //======================================================== Includes #include "Globals.h" #include "UnivUtilities.h" #include "CommonPerson.h" #include "SoundUtils.h" #include "Dynamics.h" #include "Computer.h" #include "Human.h" #include "PlayUtils.h" #include "Ball.h" #include "Render.h" //======================================================== Functions //======================================================== PersonRectFromPosition void PersonRectFromPosition (playerType *who) { short rootHeight, actualHeight; short indexX, absoluteX, fractionalX; short indexZ, fractionalZ; who->isRect.left = (who->xPos / 64) - 16 + displayHCenter; who->isRect.right = who->isRect.left + 32; absoluteX = who->xPos; if (absoluteX < 0) absoluteX = -absoluteX; indexX = absoluteX / 512; fractionalX = absoluteX % 512; indexZ = (who->zPos / 512) + 40; fractionalZ = who->zPos % 512; rootHeight = vertTable[indexX][indexZ]; actualHeight = rootHeight + (fractionalX * (vertTable[indexX + 1][indexZ] - rootHeight)) / 512; actualHeight += (fractionalZ * (vertTable[indexX][indexZ + 1] - rootHeight)) / 512; who->isRect.bottom = actualHeight + 4; who->isRect.top = who->isRect.bottom - 44; if ((who->isRect.bottom > screenHigh) || (who->isRect.top < 0) || (who->isRect.right > screenWide) || (who->isRect.left < 0)) { who->isRect = who->wasRect; } } //======================================================== ResetPerson void ResetPerson (playerType *who) { if (who->selector == kPlayerSelector) { who->dirFlagSrc = kFacingRested; who->postFlagSrc = kStanding; who->arrayFlagMask = kFadeMask; who->dirFlagMask = fadeMaskSequence[0]; who->postFlagMask = kStanding; } else { who->dirFlagSrc = kFacingRested; who->postFlagSrc = kStanding; who->arrayFlagMask = kFadeMask; who->dirFlagMask = fadeMaskSequence[0]; who->postFlagMask = kStanding; } who->xPos = who->initXPos; who->zPos = who->initZPos; who->xVel = 0; who->zVel = 0; who->direction = kFacingRested; who->mode = kInStasis; who->posture = kStanding; who->flag = kLengthOfPenalty; who->justHitWall = 0; who->justHitBall = 0; who->justHitOpponent = 0; who->loopsBallHeld = 0; who->brakeApplied = FALSE; who->bashApplied = FALSE; if ((who->persona == kHumanPlayer) || (who->persona == kNetHuman)) who->mouseWasLetUp = TRUE; PersonRectFromPosition(who); } //======================================================== StartPersonBeamOut void StartPersonBeamOut (playerType *who) { PlaySoundSMS(kBeamOutSound); who->mode = kBeamingOut; who->flag = 0; } //======================================================== MovePerson void MovePerson (playerType *who) { short indexX, indexZ; short signX, signZ; short forceX, forceZ; short frictionX, frictionZ; indexX = who->xPos; if (indexX < 0) { indexX = -indexX; signX = -1; } else { signX = 1; } indexX /= 512; indexZ = who->zPos; if (indexZ < 0) { indexZ = -indexZ; signZ = -1; } else { signZ = 1; } indexZ /= 512; if (who->xPos < 0) { switch (leftGoalLeague) { case kLittleLeague: forceX = *(littleForceTable + indexX * 82 + indexZ * 2 + kXComponent); break; case kJuniorVarsity: forceX = *(juniorForceTable + indexX * 82 + indexZ * 2 + kXComponent); break; case kVarsity: forceX = *(varsityForceTable + indexX * 82 + indexZ * 2 + kXComponent); break; case kMinorLeague: forceX = *(minorForceTable + indexX * 82 + indexZ * 2 + kXComponent); break; case kProfessional: forceX = *(proForceTable + indexX * 82 + indexZ * 2 + kXComponent); break; default: forceX = 0; break; } } else { switch (rightGoalLeague)