summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/Frontend.cpp100
-rw-r--r--src/peds/PedAI.cpp28
-rw-r--r--src/peds/PlayerPed.cpp106
3 files changed, 110 insertions, 124 deletions
diff --git a/src/core/Frontend.cpp b/src/core/Frontend.cpp
index 3bd359c8..6806230d 100644
--- a/src/core/Frontend.cpp
+++ b/src/core/Frontend.cpp
@@ -312,12 +312,33 @@ const char* MenuFilenames[][2] = {
m_nMenuFadeAlpha = 0; \
} while(0)
-#define PREPARE_MENU_HEADER \
+#define SET_FONT_FOR_MENU_HEADER \
CFont::SetColor(CRGBA(HEADER_COLOR.r, HEADER_COLOR.g, HEADER_COLOR.b, FadeIn(255))); \
CFont::SetRightJustifyOn(); \
CFont::SetScale(MENU_X(MENUHEADER_WIDTH), MENU_Y(MENUHEADER_HEIGHT)); \
CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
+#define RESET_FONT_FOR_NEW_PAGE \
+ CFont::SetBackgroundOff(); \
+ CFont::SetScale(MENU_X(MENUACTION_SCALE_MULT), MENU_Y(MENUACTION_SCALE_MULT)); \
+ CFont::SetPropOn(); \
+ CFont::SetCentreOff(); \
+ CFont::SetJustifyOn(); \
+ CFont::SetRightJustifyOff(); \
+ CFont::SetBackGroundOnlyTextOn(); \
+ CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN)); \
+ CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(MENU_X_MARGIN - 2.0f));
+
+#define SET_FONT_FOR_HELPER_TEXT \
+ CFont::SetCentreOn(); \
+ CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE)); \
+ CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
+
+#define SET_FONT_FOR_LIST_ITEM \
+ CFont::SetRightJustifyOff(); \
+ CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE)); \
+ CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
+
#define ProcessSlider(value, increaseAction, decreaseAction, hoverStartX, hoverEndX) \
do { \
lastActiveBarX = DisplaySlider(MENU_X_RIGHT_ALIGNED(MENUSLIDER_X + columnWidth), MENU_Y(bitAboveNextItemY), MENU_Y(smallestSliderBar), MENU_Y(usableLineHeight), MENU_X(MENUSLIDER_UNK), value); \
@@ -512,6 +533,7 @@ CMenuManager::ProcessList(bool &goBack, bool &optionSelected)
m_nTotalListRow = m_nSkinsTotal;
}
if (m_nCurrScreen == MENUPAGE_KEYBOARD_CONTROLS) {
+ // GetNumOptionsCntrlConfigScreens would have been a better choice
m_nTotalListRow = m_ControlMethod == CONTROL_CLASSIC ? 30 : 25;
if (m_nSelectedListRow > m_nTotalListRow)
m_nSelectedListRow = m_nTotalListRow - 1;
@@ -932,10 +954,7 @@ CMenuManager::DisplayHelperText()
alpha = m_nHelperTextAlpha > 255 ? 255 : m_nHelperTextAlpha;
}
- CFont::SetCentreOn();
- CFont::SetScale(SCREEN_SCALE_X(SMALLESTTEXT_X_SCALE), SCREEN_SCALE_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
-
+ SET_FONT_FOR_HELPER_TEXT
// TODO: name this cases?
switch (m_nHelperTextMsgId) {
case 0:
@@ -1065,7 +1084,7 @@ CMenuManager::Draw()
#endif
if (aScreens[m_nCurrScreen].m_ScreenName[0] != '\0') {
- PREPARE_MENU_HEADER
+ SET_FONT_FOR_MENU_HEADER
CFont::PrintString(PAGE_NAME_X(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName));
// Weird place to put that.
@@ -1876,6 +1895,7 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
int controllerAction = PED_FIREWEAPON;
// GetStartOptionsCntrlConfigScreens();
int numOptions = GetNumOptionsCntrlConfigScreens();
+ int nextY = MENU_Y(yStart);
int bindingMargin = MENU_X(3.0f);
float rowHeight;
switch (m_ControlMethod) {
@@ -1890,9 +1910,10 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
}
// MENU_Y(rowHeight * 0.0f + yStart);
- for (int optionIdx = 0, nextY = MENU_Y(yStart); optionIdx < numOptions; nextY = MENU_Y(++optionIdx * rowHeight + yStart)) {
+ for (int optionIdx = 0; optionIdx < numOptions; nextY = MENU_Y(++optionIdx * rowHeight + yStart)) {
int nextX = xStart;
int bindingsForThisOpt = 0;
+ int contSetOrder = SETORDER_1;
CFont::SetColor(CRGBA(LIST_OPTION_COLOR.r, LIST_OPTION_COLOR.g, LIST_OPTION_COLOR.b, FadeIn(LIST_OPTION_COLOR.a)));
if (column == CONTSETUP_PED_COLUMN) {
@@ -2112,7 +2133,7 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
// Print bindings, including seperator (-) between them
CFont::SetScale(MENU_X(0.25f), MENU_Y(0.6f));
- for (int contSetOrder = SETORDER_1; contSetOrder < MAX_SETORDERS && controllerAction != -1; contSetOrder++) {
+ for (; contSetOrder < MAX_SETORDERS && controllerAction != -1; contSetOrder++) {
wchar *settingText = ControlsManager.GetControllerSettingTextWithOrderNumber((e_ControllerAction)controllerAction, (eContSetOrder)contSetOrder);
if (settingText) {
++bindingsForThisOpt;
@@ -2176,9 +2197,7 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
CFont::SetColor(CRGBA(55, 55, 55, FadeIn(255)));
CFont::PrintString(nextX, nextY, TheText.Get("FEC_QUE")); // "???"
}
- CFont::SetCentreOn();
- CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
+ SET_FONT_FOR_HELPER_TEXT
CFont::SetColor(CRGBA(255, 255, 255, FadeIn(255)));
if (m_bKeyChangeNotProcessed) {
CFont::PrintString(MENU_X_LEFT_ALIGNED(275.0f), SCREEN_SCALE_FROM_BOTTOM(114.0f), TheText.Get("FET_CIG")); // BACKSPACE TO CLEAR - LMB,RETURN TO CHANGE
@@ -2186,34 +2205,24 @@ CMenuManager::DrawControllerBound(int32 yStart, int32 xStart, int32 unused, int8
CFont::PrintString(MENU_X_LEFT_ALIGNED(275.0f), SCREEN_SCALE_FROM_BOTTOM(114.0f), TheText.Get("FET_RIG")); // SELECT A NEW CONTROL FOR THIS ACTION OR ESC TO CANCEL
}
- CFont::SetRightJustifyOff();
- CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
+ SET_FONT_FOR_LIST_ITEM
if (!m_bKeyIsOK)
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_SETTING_CHANGE, 0);
m_bKeyIsOK = true;
} else {
- CFont::SetCentreOn();
- CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
+ SET_FONT_FOR_HELPER_TEXT
CFont::SetColor(CRGBA(255, 255, 255, FadeIn(255)));
CFont::PrintString(MENU_X_LEFT_ALIGNED(275.0f), SCREEN_SCALE_FROM_BOTTOM(114.0f), TheText.Get("FET_CIG")); // BACKSPACE TO CLEAR - LMB,RETURN TO CHANGE
- CFont::SetRightJustifyOff();
- CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
+ SET_FONT_FOR_LIST_ITEM
m_bKeyIsOK = false;
m_bKeyChangeNotProcessed = false;
}
} else if (optionIdx == m_nSelectedListRow) {
- CFont::SetCentreOn();
- CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_LOCALE(FONT_HEADING));
+ SET_FONT_FOR_HELPER_TEXT
CFont::SetColor(CRGBA(55, 55, 55, FadeIn(255)));
CFont::PrintString(MENU_X_LEFT_ALIGNED(275.0f), SCREEN_SCALE_FROM_BOTTOM(114.0f), TheText.Get("FET_EIG")); // CANNOT SET A CONTROL FOR THIS ACTION
- CFont::SetRightJustifyOff();
- CFont::SetScale(MENU_X(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
+ SET_FONT_FOR_LIST_ITEM
}
}
}
@@ -2289,17 +2298,9 @@ CMenuManager::DrawControllerSetupScreen()
default:
break;
}
- CFont::SetBackgroundOff();
- CFont::SetScale(MENU_X(MENUACTION_SCALE_MULT), MENU_Y(MENUACTION_SCALE_MULT));
- CFont::SetPropOn();
- CFont::SetCentreOff();
- CFont::SetJustifyOn();
- CFont::SetRightJustifyOff();
- CFont::SetBackGroundOnlyTextOn();
- CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN));
- CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(MENU_X_MARGIN - 2.0f));
+ RESET_FONT_FOR_NEW_PAGE
- PREPARE_MENU_HEADER
+ SET_FONT_FOR_MENU_HEADER
switch (m_ControlMethod) {
case CONTROL_STANDARD:
@@ -2374,15 +2375,15 @@ CMenuManager::DrawControllerSetupScreen()
CFont::PrintString(MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_1_X), MENU_Y(CONTSETUP_LIST_TOP), TheText.Get("FET_CAC"));
CFont::PrintString(MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_2_X), MENU_Y(CONTSETUP_LIST_TOP), TheText.Get("FET_CFT"));
CFont::PrintString(MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_3_X), MENU_Y(CONTSETUP_LIST_TOP), TheText.Get("FET_CCR"));
- CFont::SetRightJustifyOff();
- CFont::SetScale(MENU_X_LEFT_ALIGNED(SMALLESTTEXT_X_SCALE), MENU_Y(SMALLESTTEXT_Y_SCALE));
- CFont::SetFontStyle(FONT_LOCALE(FONT_BANK));
+ SET_FONT_FOR_LIST_ITEM
+
int yStart;
if (m_ControlMethod == CONTROL_CLASSIC)
- yStart = CONTSETUP_LIST_HEADER_HEIGHT + 29;
+ yStart = CONTSETUP_LIST_TOP + CONTSETUP_LIST_HEADER_HEIGHT + 1;
else
- yStart = CONTSETUP_LIST_HEADER_HEIGHT + 34;
+ yStart = CONTSETUP_LIST_TOP + CONTSETUP_LIST_HEADER_HEIGHT + 5;
+ float optionYBottom = yStart + rowHeight;
for (int i = 0; i < ARRAY_SIZE(actionTexts); ++i) {
wchar *actionText = actionTexts[i];
if (!actionText)
@@ -2391,8 +2392,7 @@ CMenuManager::DrawControllerSetupScreen()
if (m_nMousePosX > MENU_X_LEFT_ALIGNED(CONTSETUP_LIST_LEFT + 2.0f) &&
m_nMousePosX < MENU_X_LEFT_ALIGNED(CONTSETUP_COLUMN_3_X + CONTSETUP_BOUND_COLUMN_WIDTH)) {
- float curOptY = i * rowHeight + yStart;
- if (m_nMousePosY > MENU_Y(curOptY) && m_nMousePosY < MENU_Y(rowHeight + curOptY)) {
+ if (m_nMousePosY > MENU_Y(i * rowHeight + yStart) && m_nMousePosY < MENU_Y(i * rowHeight + optionYBottom)) {
if (m_nOptionMouseHovering != i && m_nCurrExLayer == HOVEROPTION_LIST)
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0);
@@ -3042,17 +3042,9 @@ CMenuManager::DrawFrontEndNormal()
void
CMenuManager::DrawPlayerSetupScreen()
{
- CFont::SetBackgroundOff();
- CFont::SetScale(MENU_X(MENUACTION_SCALE_MULT), MENU_Y(MENUACTION_SCALE_MULT));
- CFont::SetPropOn();
- CFont::SetCentreOff();
- CFont::SetJustifyOn();
- CFont::SetRightJustifyOff();
- CFont::SetBackGroundOnlyTextOn();
- CFont::SetWrapx(MENU_X_RIGHT_ALIGNED(MENU_X_MARGIN));
- CFont::SetRightJustifyWrap(MENU_X_LEFT_ALIGNED(MENU_X_MARGIN - 2.0f));
+ RESET_FONT_FOR_NEW_PAGE
- PREPARE_MENU_HEADER
+ SET_FONT_FOR_MENU_HEADER
CFont::PrintString(PAGE_NAME_X(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get("FET_PS"));
@@ -4018,7 +4010,7 @@ CMenuManager::PrintStats()
// ::Draw already does that.
/*
- PREPARE_MENU_HEADER
+ SET_FONT_FOR_MENU_HEADER
CFont::PrintString(PAGE_NAME_X(MENUHEADER_POS_X), SCREEN_SCALE_FROM_BOTTOM(MENUHEADER_POS_Y), TheText.Get(aScreens[m_nCurrScreen].m_ScreenName));
*/
CFont::SetScale(MENU_X(MENU_TEXT_SIZE_X), MENU_Y(MENU_TEXT_SIZE_Y));
diff --git a/src/peds/PedAI.cpp b/src/peds/PedAI.cpp
index 38303473..62b27134 100644
--- a/src/peds/PedAI.cpp
+++ b/src/peds/PedAI.cpp
@@ -972,9 +972,9 @@ CPed::ProcessObjective(void)
}
CWeaponInfo *wepInfo = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
float wepRange = wepInfo->m_fRange;
- float wepRangeAdjusted;
+ float maxDistToKeep;
if (GetWeapon()->m_eWeaponType != WEAPONTYPE_UNARMED) {
- wepRangeAdjusted = wepRange / 3.0f;
+ maxDistToKeep = wepRange / 3.0f;
} else {
if (m_nPedState == PED_FIGHT) {
if (!IsPlayer() && !(m_pedStats->m_flags & STAT_CAN_KICK))
@@ -982,10 +982,10 @@ CPed::ProcessObjective(void)
} else {
wepRange = 1.3f;
}
- wepRangeAdjusted = wepRange;
+ maxDistToKeep = wepRange;
}
- if (m_pedInObjective->m_getUpTimer > CTimer::GetTimeInMilliseconds() && wepRangeAdjusted < 2.5f) {
- wepRangeAdjusted = 2.5f;
+ if (m_pedInObjective->m_getUpTimer > CTimer::GetTimeInMilliseconds() && maxDistToKeep < 2.5f) {
+ maxDistToKeep = 2.5f;
}
if (m_pedInObjective->IsPlayer() && m_nPedType != PEDTYPE_COP
&& CharCreatedBy != MISSION_CHAR && FindPlayerPed()->m_pWanted->m_CurrentCops) {
@@ -1086,7 +1086,7 @@ CPed::ProcessObjective(void)
|| distWithTargetSc > m_distanceToCountSeekDone && !CanSeeEntity(m_pedInObjective)) {
if (m_pedInObjective->EnteringCar())
- wepRangeAdjusted = 2.0f;
+ maxDistToKeep = 2.0f;
if (bUsePedNodeSeek) {
CVector bestCoords(0.0f, 0.0f, 0.0f);
@@ -1100,7 +1100,7 @@ CPed::ProcessObjective(void)
SetSeek(m_vecSeekPos, m_distanceToCountSeekDone);
} else {
- SetSeek(m_pedInObjective, wepRangeAdjusted);
+ SetSeek(m_pedInObjective, maxDistToKeep);
}
bCrouchWhenShooting = false;
if (m_pedInObjective->m_pCurrentPhysSurface && distWithTargetSc < 5.0f) {
@@ -1172,7 +1172,7 @@ CPed::ProcessObjective(void)
SetShootTimer(CGeneral::GetRandomNumberInRange(500.0f, 2000.0f));
int time;
- if (distWithTargetSc <= wepRangeAdjusted)
+ if (distWithTargetSc <= maxDistToKeep)
time = CGeneral::GetRandomNumberInRange(100.0f, 500.0f);
else
time = CGeneral::GetRandomNumberInRange(1500.0f, 3000.0f);
@@ -1230,17 +1230,17 @@ CPed::ProcessObjective(void)
if (m_nPedType == PEDTYPE_COP) {
if (GetWeapon()->m_eWeaponType > WEAPONTYPE_COLT45
|| m_fleeFrom && m_fleeFrom->IsObject()) {
- wepRangeAdjusted = 6.0f;
+ maxDistToKeep = 6.0f;
} else if (m_fleeFrom && m_fleeFrom->IsVehicle()) {
- wepRangeAdjusted = 4.0f;
+ maxDistToKeep = 4.0f;
} else {
- wepRangeAdjusted = 2.0f;
+ maxDistToKeep = 2.0f;
}
} else {
- wepRangeAdjusted = 2.0f;
+ maxDistToKeep = 2.0f;
}
}
- if (distWithTargetSc <= wepRangeAdjusted) {
+ if (distWithTargetSc <= maxDistToKeep) {
SetMoveState(PEDMOVE_STILL);
bIsPointingGunAt = true;
if (m_nPedState != PED_AIM_GUN && !bDuckAndCover) {
@@ -1251,7 +1251,7 @@ CPed::ProcessObjective(void)
if (m_nPedState != PED_SEEK_ENTITY && m_nPedState != PED_SEEK_POS
&& !bStopAndShoot && !killPlayerInNoPoliceZone && !bKindaStayInSamePlace) {
Say(SOUND_PED_ATTACK);
- SetSeek(m_pedInObjective, wepRangeAdjusted);
+ SetSeek(m_pedInObjective, maxDistToKeep);
bIsRunning = true;
}
}
diff --git a/src/peds/PlayerPed.cpp b/src/peds/PlayerPed.cpp
index fa865aec..f23aa378 100644
--- a/src/peds/PlayerPed.cpp
+++ b/src/peds/PlayerPed.cpp
@@ -113,14 +113,10 @@ CPlayerPed::AnnoyPlayerPed(bool annoyedByPassingEntity)
{
if (m_pedStats->m_temper < 52) {
m_pedStats->m_temper++;
- } else {
- if (annoyedByPassingEntity) {
- if (m_pedStats->m_temper < 55) {
- m_pedStats->m_temper++;
- } else {
- m_pedStats->m_temper = 46;
- }
- }
+ } else if (annoyedByPassingEntity && m_pedStats->m_temper < 55) {
+ m_pedStats->m_temper++;
+ } else if (annoyedByPassingEntity) {
+ m_pedStats->m_temper = 46;
}
}
@@ -215,7 +211,7 @@ CPlayerPed::ReApplyMoveAnims(void)
for(int i = 0; i < ARRAY_SIZE(moveAnims); i++) {
CAnimBlendAssociation *curMoveAssoc = RpAnimBlendClumpGetAssociation(GetClump(), moveAnims[i]);
if (curMoveAssoc) {
- if (strcmp(CAnimManager::GetAnimAssociation(m_animGroup, moveAnims[i])->hierarchy->name, curMoveAssoc->hierarchy->name) != 0) {
+ if (CGeneral::faststrcmp(CAnimManager::GetAnimAssociation(m_animGroup, moveAnims[i])->hierarchy->name, curMoveAssoc->hierarchy->name)) {
CAnimBlendAssociation *newMoveAssoc = CAnimManager::AddAnimation(GetClump(), m_animGroup, moveAnims[i]);
newMoveAssoc->blendDelta = curMoveAssoc->blendDelta;
newMoveAssoc->blendAmount = curMoveAssoc->blendAmount;
@@ -288,7 +284,7 @@ CPlayerPed::SetRealMoveAnim(void)
if (!curIdleAssoc)
curIdleAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FIGHT_IDLE);
- if ((!curRunStopAssoc || !(curRunStopAssoc->IsRunning())) && (!curRunStopRAssoc || !(curRunStopRAssoc->IsRunning()))) {
+ if (!((curRunStopAssoc && curRunStopAssoc->IsRunning()) || (curRunStopRAssoc && curRunStopRAssoc->IsRunning()))) {
if (curRunStopAssoc && curRunStopAssoc->blendDelta >= 0.0f || curRunStopRAssoc && curRunStopRAssoc->blendDelta >= 0.0f) {
if (curRunStopAssoc) {
@@ -340,8 +336,8 @@ CPlayerPed::SetRealMoveAnim(void)
CAnimManager::BlendAnimation(GetClump(), m_animGroup, ANIM_IDLE_STANCE, 4.0f);
}
}
-
m_nMoveState = PEDMOVE_STILL;
+
} else {
if (curIdleAssoc) {
if (curWalkStartAssoc) {
@@ -394,6 +390,7 @@ CPlayerPed::SetRealMoveAnim(void)
}
if (curSprintAssoc && (m_nMoveState != PEDMOVE_SPRINT || m_fMoveSpeed < 0.4f)) {
+ // Stop sprinting in various conditions
if (curSprintAssoc->blendAmount == 0.0f) {
curSprintAssoc->blendDelta = -1000.0f;
curSprintAssoc->flags |= ASSOC_DELETEFADEDOUT;
@@ -417,8 +414,8 @@ CPlayerPed::SetRealMoveAnim(void)
curRunAssoc->flags &= ~ASSOC_RUNNING;
curRunAssoc->blendAmount = 0.0f;
curRunAssoc->blendDelta = 0.0f;
- } else if (curSprintAssoc->blendDelta >= 0.0f) {
+ } else if (curSprintAssoc->blendDelta >= 0.0f) {
// Stop sprinting when tired
curSprintAssoc->flags |= ASSOC_DELETEFADEDOUT;
curSprintAssoc->blendDelta = -1.0f;
@@ -428,7 +425,9 @@ CPlayerPed::SetRealMoveAnim(void)
curSprintAssoc->blendDelta = -8.0f;
curRunAssoc->blendDelta = 8.0f;
}
+
} else if (curWalkStartAssoc) {
+ // Walk start and walk/run shouldn't run at the same time
curWalkAssoc->flags &= ~ASSOC_RUNNING;
curRunAssoc->flags &= ~ASSOC_RUNNING;
curWalkAssoc->blendAmount = 0.0f;
@@ -436,11 +435,13 @@ CPlayerPed::SetRealMoveAnim(void)
} else if (m_nMoveState == PEDMOVE_SPRINT) {
if (curSprintAssoc) {
+ // We have anim, do it
if (curSprintAssoc->blendDelta < 0.0f) {
curSprintAssoc->blendDelta = 2.0f;
curRunAssoc->blendDelta = -2.0f;
}
} else {
+ // Transition between run-sprint
curWalkAssoc->blendAmount = 0.0f;
curRunAssoc->blendAmount = 1.0f;
curSprintAssoc = CAnimManager::BlendAnimation(GetClump(), m_animGroup, ANIM_SPRINT, 2.0f);
@@ -703,14 +704,7 @@ CPlayerPed::PlayerControl1stPersonRunAround(CPad *padUsed)
float padMove = CVector2D(leftRight, upDown).Magnitude();
float padMoveInGameUnit = padMove / PAD_MOVE_TO_GAME_WORLD_MOVE;
if (padMoveInGameUnit > 0.0f) {
-#ifdef FREE_CAM
- if (!CCamera::bFreeCam)
- m_fRotationDest = CGeneral::LimitRadianAngle(TheCamera.Orientation);
- else
- m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints(0.0f, 0.0f, -leftRight, upDown) - TheCamera.Orientation;
-#else
m_fRotationDest = CGeneral::LimitRadianAngle(TheCamera.Orientation);
-#endif
m_fMoveSpeed = Min(padMoveInGameUnit, 0.07f * CTimer::GetTimeStep() + m_fMoveSpeed);
} else {
m_fMoveSpeed = 0.0f;
@@ -718,8 +712,7 @@ CPlayerPed::PlayerControl1stPersonRunAround(CPad *padUsed)
if (m_nPedState == PED_JUMP) {
if (bIsInTheAir) {
- if (bUsesCollision && !bHitSteepSlope &&
- (!bHitSomethingLastFrame || m_vecDamageNormal.z > 0.6f)
+ if (bUsesCollision && !bHitSteepSlope && (!bHitSomethingLastFrame || m_vecDamageNormal.z > 0.6f)
&& m_fDistanceTravelled < CTimer::GetTimeStep() * 0.02 && m_vecMoveSpeed.MagnitudeSqr() < 0.01f) {
float angleSin = Sin(m_fRotationCur); // originally sin(DEGTORAD(RADTODEG(m_fRotationCur))) o_O
@@ -730,8 +723,7 @@ CPlayerPed::PlayerControl1stPersonRunAround(CPad *padUsed)
m_fMoveSpeed = 0.0f;
}
}
- if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy)
- && padUsed->GetSprint()) {
+ if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy) && padUsed->GetSprint()) {
m_nMoveState = PEDMOVE_SPRINT;
}
if (m_nPedState != PED_FIGHT)
@@ -856,10 +848,9 @@ CPlayerPed::FindNextWeaponLockOnTarget(CEntity *previousTarget, bool lookToLeft)
{
CEntity *nextTarget = nil;
float weaponRange = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_fRange;
- // nextTarget = nil;
+ // nextTarget = nil; // duplicate
float lastCloseness = -10000.0f;
- // unused
- // CGeneral::GetATanOfXY(GetForward().x, GetForward().y);
+ // CGeneral::GetATanOfXY(GetForward().x, GetForward().y); // unused
CVector distVec = previousTarget->GetPosition() - GetPosition();
float referenceBeta = CGeneral::GetATanOfXY(distVec.x, distVec.y);
@@ -907,7 +898,7 @@ CPlayerPed::FindWeaponLockOnTarget(void)
}
}
- // nextTarget = nil;
+ // nextTarget = nil; // duplicate
float lastCloseness = -10000.0f;
float referenceBeta = CGeneral::GetATanOfXY(GetForward().x, GetForward().y);
for (int h = CPools::GetPedPool()->GetSize() - 1; h >= 0; h--) {
@@ -1105,7 +1096,7 @@ CPlayerPed::ProcessPlayerWeapon(CPad *padUsed)
m_fRotationCur += (limitedRotDest - m_fRotationCur) / 2;
}
}
- } else if (weaponInfo->m_bCanAimWithArm)
+ } else if (weaponInfo->m_bCanAimWithArm && m_nPedState != PED_ATTACK)
ClearPointGunAt();
}
}
@@ -1212,8 +1203,7 @@ CPlayerPed::PlayerControlZelda(CPad *padUsed)
if (m_nPedState == PED_JUMP) {
if (bIsInTheAir) {
- if (bUsesCollision && !bHitSteepSlope &&
- (!bHitSomethingLastFrame || m_vecDamageNormal.z > 0.6f)
+ if (bUsesCollision && !bHitSteepSlope && (!bHitSomethingLastFrame || m_vecDamageNormal.z > 0.6f)
&& m_fDistanceTravelled < CTimer::GetTimeStep() * 0.02 && m_vecMoveSpeed.MagnitudeSqr() < 0.01f) {
float angleSin = Sin(m_fRotationCur); // originally sin(DEGTORAD(RADTODEG(m_fRotationCur))) o_O
@@ -1225,8 +1215,7 @@ CPlayerPed::PlayerControlZelda(CPad *padUsed)
}
}
- if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy)
- && padUsed->GetSprint()) {
+ if (!(CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType)->m_bHeavy) && padUsed->GetSprint()) {
m_nMoveState = PEDMOVE_SPRINT;
}
if (m_nPedState != PED_FIGHT)
@@ -1291,25 +1280,26 @@ CPlayerPed::ProcessControl(void)
if (m_nPedState == PED_DRIVING && m_objective != OBJECTIVE_LEAVE_CAR) {
if (m_pMyVehicle->IsCar() && ((CAutomobile*)m_pMyVehicle)->Damage.GetDoorStatus(DOOR_FRONT_LEFT) == DOOR_STATUS_SWINGING) {
CAnimBlendAssociation *rollDoorAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_CAR_ROLLDOOR);
- if (!rollDoorAssoc) {
- rollDoorAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_CAR_ROLLDOOR_LOW);
- }
-
- // These comparisons are wrong, they return uint16
- if (m_pMyVehicle->m_nGettingOutFlags & CAR_DOOR_FLAG_LF || rollDoorAssoc || padUsed
- && (padUsed->GetAccelerate() != 0.0f || padUsed->GetSteeringLeftRight() != 0.0f
- || padUsed->GetBrake() != 0.0f)) {
+ if (m_pMyVehicle->m_nGettingOutFlags & CAR_DOOR_FLAG_LF || rollDoorAssoc || (rollDoorAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_CAR_ROLLDOOR_LOW))) {
if (rollDoorAssoc)
m_pMyVehicle->ProcessOpenDoor(CAR_DOOR_LF, ANIM_CAR_ROLLDOOR, rollDoorAssoc->currentTime);
+
} else {
- m_pMyVehicle->m_nGettingOutFlags |= CAR_DOOR_FLAG_LF;
- if (m_pMyVehicle->bLowVehicle)
- rollDoorAssoc = CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_ROLLDOOR_LOW);
- else
- rollDoorAssoc = CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_ROLLDOOR);
+ // These comparisons are wrong, they return uint16
+ if (padUsed && (padUsed->GetAccelerate() != 0.0f || padUsed->GetSteeringLeftRight() != 0.0f || padUsed->GetBrake() != 0.0f)) {
+ if (rollDoorAssoc)
+ m_pMyVehicle->ProcessOpenDoor(CAR_DOOR_LF, ANIM_CAR_ROLLDOOR, rollDoorAssoc->currentTime);
+
+ } else {
+ m_pMyVehicle->m_nGettingOutFlags |= CAR_DOOR_FLAG_LF;
+ if (m_pMyVehicle->bLowVehicle)
+ rollDoorAssoc = CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_ROLLDOOR_LOW);
+ else
+ rollDoorAssoc = CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_CAR_ROLLDOOR);
- rollDoorAssoc->SetFinishCallback(PedAnimDoorCloseRollingCB, this);
+ rollDoorAssoc->SetFinishCallback(PedAnimDoorCloseRollingCB, this);
+ }
}
}
return;
@@ -1338,12 +1328,18 @@ CPlayerPed::ProcessControl(void)
case PED_FIGHT:
case PED_AIM_GUN:
if (!RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_BLOCK)) {
- if (TheCamera.Cams[0].Using3rdPersonMouseCam()) {
+ if (TheCamera.Cams[0].Using3rdPersonMouseCam()
+#ifdef FREE_CAM
+ && !CCamera::bFreeCam
+#endif
+ ) {
if (padUsed)
PlayerControl1stPersonRunAround(padUsed);
+
} else if (m_nPedState == PED_FIGHT) {
if (padUsed)
PlayerControlFighter(padUsed);
+
} else if (padUsed) {
PlayerControlZelda(padUsed);
}
@@ -1415,6 +1411,7 @@ CPlayerPed::ProcessControl(void)
if (FindPlayerPed()->GetWeapon()->m_eWeaponType == WEAPONTYPE_M16) {
if (padUsed)
PlayerControlM16(padUsed);
+
} else if (padUsed) {
PlayerControlSniper(padUsed);
}
@@ -1477,20 +1474,17 @@ CPlayerPed::ProcessControl(void)
m_lookTimer = 0;
float camAngle = CGeneral::LimitRadianAngle(TheCamera.Cams[TheCamera.ActiveCam].Front.Heading());
float angleBetweenPlayerAndCam = Abs(camAngle - m_fRotationCur);
- if (m_nPedState != PED_ATTACK
- && angleBetweenPlayerAndCam > DEGTORAD(30.0f) && angleBetweenPlayerAndCam < DEGTORAD(330.0f)) {
+ if (m_nPedState != PED_ATTACK && angleBetweenPlayerAndCam > DEGTORAD(30.0f) && angleBetweenPlayerAndCam < DEGTORAD(330.0f)) {
if (angleBetweenPlayerAndCam > DEGTORAD(150.0f) && angleBetweenPlayerAndCam < DEGTORAD(210.0f)) {
float rightTurnAngle = CGeneral::LimitRadianAngle(m_fRotationCur - DEGTORAD(150.0f));
float leftTurnAngle = CGeneral::LimitRadianAngle(DEGTORAD(150.0f) + m_fRotationCur);
- if (m_fLookDirection != 999999.0f) {
- if (Abs(rightTurnAngle - m_fLookDirection) < Abs(leftTurnAngle - m_fLookDirection))
- camAngle = rightTurnAngle;
- else
- camAngle = leftTurnAngle;
- } else {
+ if (m_fLookDirection == 999999.0f)
camAngle = rightTurnAngle;
- }
+ else if (Abs(rightTurnAngle - m_fLookDirection) < Abs(leftTurnAngle - m_fLookDirection))
+ camAngle = rightTurnAngle;
+ else
+ camAngle = leftTurnAngle;
}
SetLookFlag(camAngle, true);
SetLookTimer(CTimer::GetTimeStepInMilliseconds() * 5.0f);