Fixes from miami

This commit is contained in:
eray orçunus 2020-07-20 22:47:41 +03:00
parent efd49962d2
commit 70df13f9d3
6 changed files with 118 additions and 186 deletions

View File

@ -2823,9 +2823,8 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
UpdateCompareFlag(ped->IsWithinArea(x1, y1, x2, y2)); UpdateCompareFlag(ped->IsWithinArea(x1, y1, x2, y2));
else else
UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, x2, y2)); UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, x2, y2));
if (!ScriptParams[5]) if (ScriptParams[5])
return 0; CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
if (CTheScripts::DbgFlag) if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugSquare(x1, y1, x2, y2); CTheScripts::DrawDebugSquare(x1, y1, x2, y2);
return 0; return 0;
@ -2844,9 +2843,8 @@ int8 CRunningScript::ProcessCommands0To99(int32 command)
UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2)); UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2));
else else
UpdateCompareFlag(ped->IsWithinArea(x1, y1, z1, x2, y2, z2)); UpdateCompareFlag(ped->IsWithinArea(x1, y1, z1, x2, y2, z2));
if (!ScriptParams[7]) if (ScriptParams[7])
return 0; CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2);
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2);
if (CTheScripts::DbgFlag) if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2); CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2);
return 0; return 0;
@ -3425,9 +3423,8 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, x2, y2)); UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, x2, y2));
else else
UpdateCompareFlag(ped->IsWithinArea(x1, y1, x2, y2)); UpdateCompareFlag(ped->IsWithinArea(x1, y1, x2, y2));
if (!ScriptParams[5]) if (ScriptParams[5])
return 0; CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
if (CTheScripts::DbgFlag) if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugSquare(x1, y1, x2, y2); CTheScripts::DrawDebugSquare(x1, y1, x2, y2);
return 0; return 0;
@ -3452,9 +3449,8 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2)); UpdateCompareFlag(ped->m_pMyVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2));
else else
UpdateCompareFlag(ped->IsWithinArea(x1, y1, z1, x2, y2, z2)); UpdateCompareFlag(ped->IsWithinArea(x1, y1, z1, x2, y2, z2));
if (!ScriptParams[7]) if (ScriptParams[7])
return 0; CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2);
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2);
if (CTheScripts::DbgFlag) if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2); CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2);
return 0; return 0;
@ -3671,9 +3667,8 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
float x2 = *(float*)&ScriptParams[3]; float x2 = *(float*)&ScriptParams[3];
float y2 = *(float*)&ScriptParams[4]; float y2 = *(float*)&ScriptParams[4];
UpdateCompareFlag(vehicle->IsWithinArea(x1, y1, x2, y2)); UpdateCompareFlag(vehicle->IsWithinArea(x1, y1, x2, y2));
if (!ScriptParams[5]) if (ScriptParams[5])
return 0; CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
if (CTheScripts::DbgFlag) if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugSquare(x1, y1, x2, y2); CTheScripts::DrawDebugSquare(x1, y1, x2, y2);
return 0; return 0;
@ -3690,9 +3685,8 @@ int8 CRunningScript::ProcessCommands100To199(int32 command)
float y2 = *(float*)&ScriptParams[5]; float y2 = *(float*)&ScriptParams[5];
float z2 = *(float*)&ScriptParams[6]; float z2 = *(float*)&ScriptParams[6];
UpdateCompareFlag(vehicle->IsWithinArea(x1, y1, z1, x2, y2, z2)); UpdateCompareFlag(vehicle->IsWithinArea(x1, y1, z1, x2, y2, z2));
if (!ScriptParams[7]) if (ScriptParams[7])
return 0; CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2);
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2);
if (CTheScripts::DbgFlag) if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2); CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2);
return 0; return 0;
@ -4429,9 +4423,8 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
float y2 = *(float*)&ScriptParams[4]; float y2 = *(float*)&ScriptParams[4];
UpdateCompareFlag(pVehicle->GetStatus() == STATUS_WRECKED && UpdateCompareFlag(pVehicle->GetStatus() == STATUS_WRECKED &&
pVehicle->IsWithinArea(x1, y1, x2, y2)); pVehicle->IsWithinArea(x1, y1, x2, y2));
if (!ScriptParams[5]) if (ScriptParams[5])
return 0; CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
if (CTheScripts::DbgFlag) if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugSquare(x1, y1, x2, y2); CTheScripts::DrawDebugSquare(x1, y1, x2, y2);
return 0; return 0;
@ -4449,9 +4442,8 @@ int8 CRunningScript::ProcessCommands300To399(int32 command)
float z2 = *(float*)&ScriptParams[6]; float z2 = *(float*)&ScriptParams[6];
UpdateCompareFlag(pVehicle->GetStatus() == STATUS_WRECKED && UpdateCompareFlag(pVehicle->GetStatus() == STATUS_WRECKED &&
pVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2)); pVehicle->IsWithinArea(x1, y1, z1, x2, y2, z2));
if (!ScriptParams[7]) if (ScriptParams[7])
return 0; CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2);
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, (z1 + z2) / 2);
if (CTheScripts::DbgFlag) if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2); CTheScripts::DrawDebugCube(x1, y1, z1, x2, y2, z2);
return 0; return 0;
@ -7279,9 +7271,8 @@ int8 CRunningScript::ProcessCommands700To799(int32 command)
float x2 = *(float*)&ScriptParams[3]; float x2 = *(float*)&ScriptParams[3];
float y2 = *(float*)&ScriptParams[4]; float y2 = *(float*)&ScriptParams[4];
UpdateCompareFlag(pPed->bIsShooting && pPed->IsWithinArea(x1, y1, x2, y2)); UpdateCompareFlag(pPed->bIsShooting && pPed->IsWithinArea(x1, y1, x2, y2));
if (!ScriptParams[5]) if (ScriptParams[5])
return 0; CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
if (CTheScripts::DbgFlag) if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugSquare(x1, y1, x2, y2); CTheScripts::DrawDebugSquare(x1, y1, x2, y2);
return 0; return 0;
@ -7296,9 +7287,8 @@ int8 CRunningScript::ProcessCommands700To799(int32 command)
float x2 = *(float*)&ScriptParams[3]; float x2 = *(float*)&ScriptParams[3];
float y2 = *(float*)&ScriptParams[4]; float y2 = *(float*)&ScriptParams[4];
UpdateCompareFlag(pPed->bIsShooting && pPed->IsWithinArea(x1, y1, x2, y2)); UpdateCompareFlag(pPed->bIsShooting && pPed->IsWithinArea(x1, y1, x2, y2));
if (!ScriptParams[5]) if (ScriptParams[5])
return 0; CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
CTheScripts::HighlightImportantArea((uintptr)this + m_nIp, x1, y1, x2, y2, MAP_Z_LOW_LIMIT);
if (CTheScripts::DbgFlag) if (CTheScripts::DbgFlag)
CTheScripts::DrawDebugSquare(x1, y1, x2, y2); CTheScripts::DrawDebugSquare(x1, y1, x2, y2);
return 0; return 0;

View File

@ -956,10 +956,10 @@ CMenuManager::Draw()
CFont::SetDropShadowPosition(0); CFont::SetDropShadowPosition(0);
if (!CheckHover(MENU_X(30.0f), MENU_X(30.0f) + CFont::GetStringWidth(backTx), SCREEN_SCALE_FROM_BOTTOM(125.0f), SCREEN_SCALE_FROM_BOTTOM(105.0f))) { if (!CheckHover(MENU_X(30.0f), MENU_X(30.0f) + CFont::GetStringWidth(backTx), SCREEN_SCALE_FROM_BOTTOM(125.0f), SCREEN_SCALE_FROM_BOTTOM(105.0f))) {
m_nHoverOption = HOVEROPTION_NOT_HOVERING; m_nHoverOption = HOVEROPTION_NOT_HOVERING;
m_nCurrOption = m_nPrevOption = 0; m_nCurrOption = m_nOptionMouseHovering = 0;
} else { } else {
m_nHoverOption = HOVEROPTION_RANDOM_ITEM; m_nHoverOption = HOVEROPTION_RANDOM_ITEM;
m_nCurrOption = m_nPrevOption = 1; m_nCurrOption = m_nOptionMouseHovering = 1;
} }
return; return;
} }
@ -1256,7 +1256,7 @@ CMenuManager::Draw()
static int oldOption = -99; static int oldOption = -99;
static int oldScreen = m_nCurrScreen; static int oldScreen = m_nCurrScreen;
m_nPrevOption = rowToCheck; m_nOptionMouseHovering = rowToCheck;
if (m_nMouseOldPosX != m_nMousePosX || m_nMouseOldPosY != m_nMousePosY) { if (m_nMouseOldPosX != m_nMousePosX || m_nMouseOldPosY != m_nMousePosY) {
m_nCurrOption = rowToCheck; m_nCurrOption = rowToCheck;
m_bShowMouse = true; m_bShowMouse = true;
@ -1980,10 +1980,10 @@ CMenuManager::DrawControllerSetupScreen()
float curOptY = i * rowHeight + yStart; float curOptY = i * rowHeight + yStart;
if (m_nMousePosY > MENU_Y(curOptY) && m_nMousePosY < MENU_Y(rowHeight + curOptY)) { if (m_nMousePosY > MENU_Y(curOptY) && m_nMousePosY < MENU_Y(rowHeight + curOptY)) {
if (m_nPrevOption != i && m_nCurrExLayer == HOVEROPTION_LIST) if (m_nOptionMouseHovering != i && m_nCurrExLayer == HOVEROPTION_LIST)
DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0); DMAudio.PlayFrontEndSound(SOUND_FRONTEND_MENU_NAVIGATION, 0);
m_nPrevOption = i; m_nOptionMouseHovering = i;
if (m_nMouseOldPosX != m_nMousePosX || m_nMouseOldPosY != m_nMousePosY) { if (m_nMouseOldPosX != m_nMousePosX || m_nMouseOldPosY != m_nMousePosY) {
m_nCurrExLayer = HOVEROPTION_LIST; m_nCurrExLayer = HOVEROPTION_LIST;
m_nSelectedListRow = i; m_nSelectedListRow = i;
@ -2694,7 +2694,7 @@ CMenuManager::DrawPlayerSetupScreen()
if (m_nMousePosX > MENU_X_LEFT_ALIGNED(PLAYERSETUP_LIST_LEFT) && m_nMousePosX < MENU_X_RIGHT_ALIGNED(PLAYERSETUP_LIST_RIGHT)) { if (m_nMousePosX > MENU_X_LEFT_ALIGNED(PLAYERSETUP_LIST_LEFT) && m_nMousePosX < MENU_X_RIGHT_ALIGNED(PLAYERSETUP_LIST_RIGHT)) {
if (m_nMousePosY > MENU_Y(rowStartY) && m_nMousePosY < MENU_Y(rowEndY)) { if (m_nMousePosY > MENU_Y(rowStartY) && m_nMousePosY < MENU_Y(rowEndY)) {
m_nPrevOption = rowIdx; m_nOptionMouseHovering = rowIdx;
if (m_nMouseOldPosX != m_nMousePosX || m_nMouseOldPosY != m_nMousePosY) { if (m_nMouseOldPosX != m_nMousePosX || m_nMouseOldPosY != m_nMousePosY) {
m_nCurrExLayer = HOVEROPTION_LIST; m_nCurrExLayer = HOVEROPTION_LIST;
} }
@ -4025,7 +4025,7 @@ CMenuManager::ProcessButtonPresses(void)
if (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action == MENUACTION_RESUME && if (aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action == MENUACTION_RESUME &&
#endif #endif
(m_nHoverOption == HOVEROPTION_RANDOM_ITEM)) { (m_nHoverOption == HOVEROPTION_RANDOM_ITEM)) {
m_nCurrOption = m_nPrevOption; m_nCurrOption = m_nOptionMouseHovering;
optionSelected = true; optionSelected = true;
} }
} else if (CPad::GetPad(0)->GetLeftMouseJustDown()) { } else if (CPad::GetPad(0)->GetLeftMouseJustDown()) {
@ -4039,7 +4039,7 @@ CMenuManager::ProcessButtonPresses(void)
OutputDebugString("FRONTEND RADIO STATION CHANGED"); OutputDebugString("FRONTEND RADIO STATION CHANGED");
} else if (m_nHoverOption == HOVEROPTION_RANDOM_ITEM } else if (m_nHoverOption == HOVEROPTION_RANDOM_ITEM
&& aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action != MENUACTION_RESUME) { && aScreens[m_nCurrScreen].m_aEntries[m_nCurrOption].m_Action != MENUACTION_RESUME) {
m_nCurrOption = m_nPrevOption; m_nCurrOption = m_nOptionMouseHovering;
optionSelected = true; optionSelected = true;
} }
#else #else
@ -4126,7 +4126,7 @@ CMenuManager::ProcessButtonPresses(void)
break; break;
case HOVEROPTION_RANDOM_ITEM: case HOVEROPTION_RANDOM_ITEM:
if (((m_nCurrOption != 0) || (m_nCurrScreen != MENUPAGE_PAUSE_MENU)) { if (((m_nCurrOption != 0) || (m_nCurrScreen != MENUPAGE_PAUSE_MENU)) {
m_nCurrOption = m_nPrevOption; m_nCurrOption = m_nOptionMouseHovering;
optionSelected = true; optionSelected = true;
} }
break; break;

View File

@ -518,7 +518,7 @@ public:
int32 m_nHoverOption; int32 m_nHoverOption;
int32 m_nCurrScreen; int32 m_nCurrScreen;
int32 m_nCurrOption; int32 m_nCurrOption;
int32 m_nPrevOption; int32 m_nOptionMouseHovering;
int32 m_nPrevScreen; int32 m_nPrevScreen;
uint32 field_558; uint32 field_558;
int32 m_nCurrSaveSlot; int32 m_nCurrSaveSlot;

View File

@ -383,7 +383,7 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
weapon.m_nTimer = 0; weapon.m_nTimer = 0;
} }
m_lastFightMove = FIGHTMOVE_NULL; m_curFightMove = FIGHTMOVE_NULL;
GiveWeapon(WEAPONTYPE_UNARMED, 0); GiveWeapon(WEAPONTYPE_UNARMED, 0);
m_wepAccuracy = 60; m_wepAccuracy = 60;
m_lastWepDam = -1; m_lastWepDam = -1;
@ -471,7 +471,7 @@ CheckForPedsOnGroundToAttack(CPed *attacker, CPed **pedOnGround)
currentPedState = currentPed->m_nPedState; currentPedState = currentPed->m_nPedState;
if (currentPedState == PED_FALL || currentPedState == PED_GETUP || currentPedState == PED_DIE || currentPedState == PED_DEAD) { if (currentPed->OnGroundOrGettingUp()) {
if (distance < 2.0f && angleDiff < DEGTORAD(65.0f)) { if (distance < 2.0f && angleDiff < DEGTORAD(65.0f)) {
if (currentPedState == PED_DEAD) { if (currentPedState == PED_DEAD) {
foundDead = 1; foundDead = 1;
@ -1821,7 +1821,7 @@ void
CPed::PlayFootSteps(void) CPed::PlayFootSteps(void)
{ {
if (bDoBloodyFootprints) { if (bDoBloodyFootprints) {
if (m_bloodyFootprintCountOrDeathTime > 0 && m_bloodyFootprintCountOrDeathTime < 300) { if (m_bloodyFootprintCountOrDeathTime != 0 && m_bloodyFootprintCountOrDeathTime < 300) {
m_bloodyFootprintCountOrDeathTime--; m_bloodyFootprintCountOrDeathTime--;
if (m_bloodyFootprintCountOrDeathTime == 0) if (m_bloodyFootprintCountOrDeathTime == 0)
@ -2716,7 +2716,7 @@ CPed::SetObjective(eObjective newObj)
} }
*/ */
m_objective = newObj; m_objective = OBJECTIVE_NONE;
m_prevObjective = OBJECTIVE_NONE; m_prevObjective = OBJECTIVE_NONE;
} else if (m_prevObjective != newObj || m_prevObjective == OBJECTIVE_NONE) { } else if (m_prevObjective != newObj || m_prevObjective == OBJECTIVE_NONE) {
SetObjectiveTimer(0); SetObjectiveTimer(0);
@ -3364,9 +3364,7 @@ CPed::CheckForPointBlankPeds(CPed *pedToVerify)
if (neededTurn > PI) if (neededTurn > PI)
neededTurn = 2*PI - neededTurn; neededTurn = 2*PI - neededTurn;
PedState nearPedState = nearPed->m_nPedState; if (nearPed->OnGroundOrGettingUp() || nearPed->m_nPedState == PED_DIVE_AWAY)
if (nearPedState == PED_FALL || nearPedState == PED_GETUP || nearPedState == PED_DIE || nearPedState == PED_DEAD || nearPedState == PED_DIVE_AWAY)
return NO_POINT_BLANK_PED; return NO_POINT_BLANK_PED;
if (neededTurn < CAN_SEE_ENTITY_ANGLE_THRESHOLD) { if (neededTurn < CAN_SEE_ENTITY_ANGLE_THRESHOLD) {
@ -3652,56 +3650,7 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
case WEAPONTYPE_BASEBALLBAT: case WEAPONTYPE_BASEBALLBAT:
if (bMeleeProof) if (bMeleeProof)
return false; return false;
#ifdef VC_PED_PORTS
if (/*method != WEAPONTYPE_KATANA || */
damagedBy != FindPlayerPed()
|| FindPlayerPed()->m_nPedState != PED_FIGHT
/*|| FindPlayerPed()->m_lastFightMove != 28 && FindPlayerPed()->m_lastFightMove != 29 */
|| CGeneral::GetRandomNumber() & 3) {
if (m_nPedState == PED_FALL) {
if (IsPedHeadAbovePos(-0.3f)) {
dieAnim = NUM_ANIMS;
} else {
if (RpAnimBlendClumpGetFirstAssociation(GetClump(), ASSOC_FRONTAL))
dieAnim = ANIM_FLOOR_HIT_F;
else
dieAnim = ANIM_FLOOR_HIT;
dieDelta = dieDelta * 2.0f;
dieSpeed = 0.5f;
}
} else if (damagedBy != FindPlayerPed()) { // || FindPlayerPed()->m_lastFightMove != 29)
//if (damagedBy != FindPlayerPed() || FindPlayerPed()->m_lastFightMove != 30) {
switch (direction) {
case 0:
dieAnim = ANIM_KO_SKID_FRONT;
break;
case 1:
dieAnim = ANIM_KO_SPIN_R;
break;
case 2:
dieAnim = ANIM_KO_SKID_BACK;
break;
case 3:
dieAnim = ANIM_KO_SPIN_L;
break;
default:
break;
}
//} else {
// dieAnim = ANIM_KO_SHOT_STOM;
//}
} else {
dieAnim = ANIM_KO_SHOT_FACE;
}
} else {
dieAnim = ANIM_KO_SHOT_FACE;
// SpawnFlyingComponent in VC
RemoveBodyPart(PED_HEAD, direction);
headShot = true;
willLinger = true;
}
#else
if (m_nPedState == PED_FALL) { if (m_nPedState == PED_FALL) {
if (IsPedHeadAbovePos(-0.3f)) { if (IsPedHeadAbovePos(-0.3f)) {
dieAnim = NUM_ANIMS; dieAnim = NUM_ANIMS;
@ -3731,7 +3680,6 @@ CPed::InflictDamage(CEntity *damagedBy, eWeaponType method, float damage, ePedPi
break; break;
} }
} }
#endif
break; break;
case WEAPONTYPE_COLT45: case WEAPONTYPE_COLT45:
case WEAPONTYPE_UZI: case WEAPONTYPE_UZI:
@ -4853,11 +4801,11 @@ CPed::StartFightAttack(uint8 buttonPressure)
CPed *pedOnGround = nil; CPed *pedOnGround = nil;
if (IsPlayer() && CheckForPedsOnGroundToAttack(this, &pedOnGround) > PED_IN_FRONT_OF_ATTACKER) { if (IsPlayer() && CheckForPedsOnGroundToAttack(this, &pedOnGround) > PED_IN_FRONT_OF_ATTACKER) {
m_lastFightMove = FIGHTMOVE_GROUNDKICK; m_curFightMove = FIGHTMOVE_GROUNDKICK;
} else if (m_pedStats->m_flags & STAT_SHOPPING_BAGS) { } else if (m_pedStats->m_flags & STAT_SHOPPING_BAGS) {
m_lastFightMove = FIGHTMOVE_ROUNDHOUSE; m_curFightMove = FIGHTMOVE_ROUNDHOUSE;
} else { } else {
m_lastFightMove = FIGHTMOVE_STDPUNCH; m_curFightMove = FIGHTMOVE_STDPUNCH;
} }
if (pedOnGround && IsPlayer()) { if (pedOnGround && IsPlayer()) {
@ -4871,7 +4819,7 @@ CPed::StartFightAttack(uint8 buttonPressure)
SetLookFlag(pedOnGround, true); SetLookFlag(pedOnGround, true);
SetLookTimer(1500); SetLookTimer(1500);
} }
animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_lastFightMove].animId, 4.0f); animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_curFightMove].animId, 4.0f);
animAssoc->SetFinishCallback(FinishFightMoveCB, this); animAssoc->SetFinishCallback(FinishFightMoveCB, this);
m_fightState = FIGHTSTATE_NO_MOVE; m_fightState = FIGHTSTATE_NO_MOVE;
m_takeAStepAfterAttack = false; m_takeAStepAfterAttack = false;
@ -4999,9 +4947,9 @@ CPed::FightStrike(CVector &touchedNodePos)
for (int i = 0; i < m_numNearPeds; i++) { for (int i = 0; i < m_numNearPeds; i++) {
nearPed = m_nearPeds[i]; nearPed = m_nearPeds[i];
if (GetWeapon()->m_eWeaponType != WEAPONTYPE_UNARMED) if (GetWeapon()->m_eWeaponType != WEAPONTYPE_UNARMED)
maxDistanceToBeBeaten = nearPed->GetBoundRadius() + tFightMoves[m_lastFightMove].strikeRadius + 0.1f; maxDistanceToBeBeaten = nearPed->GetBoundRadius() + tFightMoves[m_curFightMove].strikeRadius + 0.1f;
else else
maxDistanceToBeBeaten = nearPed->GetBoundRadius() + tFightMoves[m_lastFightMove].strikeRadius; maxDistanceToBeBeaten = nearPed->GetBoundRadius() + tFightMoves[m_curFightMove].strikeRadius;
if (nearPed->bUsesCollision || nearPed->m_nPedState == PED_DEAD) { if (nearPed->bUsesCollision || nearPed->m_nPedState == PED_DEAD) {
CVector nearPedCentre; CVector nearPedCentre;
@ -5017,9 +4965,7 @@ CPed::FightStrike(CVector &touchedNodePos)
ourCol = ((CPedModelInfo *)CModelInfo::GetModelInfo(GetModelIndex()))->AnimatePedColModelSkinned(GetClump()); ourCol = ((CPedModelInfo *)CModelInfo::GetModelInfo(GetModelIndex()))->AnimatePedColModelSkinned(GetClump());
else else
#endif #endif
if (nearPed->m_nPedState == PED_FALL if (nearPed->OnGround() || !nearPed->IsPedHeadAbovePos(-0.3f)) {
|| nearPed->m_nPedState == PED_DEAD || nearPed->m_nPedState == PED_DIE
|| !nearPed->IsPedHeadAbovePos(-0.3f)) {
ourCol = &CTempColModels::ms_colModelPedGroundHit; ourCol = &CTempColModels::ms_colModelPedGroundHit;
} else { } else {
#ifdef ANIMATE_PED_COL_MODEL #ifdef ANIMATE_PED_COL_MODEL
@ -5034,7 +4980,7 @@ CPed::FightStrike(CVector &touchedNodePos)
attackDistance = nearPed->GetPosition() + ourCol->spheres[j].center; attackDistance = nearPed->GetPosition() + ourCol->spheres[j].center;
attackDistance -= touchedNodePos; attackDistance -= touchedNodePos;
CColSphere *ourPieces = ourCol->spheres; CColSphere *ourPieces = ourCol->spheres;
float maxDistanceToBeat = ourPieces[j].radius + tFightMoves[m_lastFightMove].strikeRadius; float maxDistanceToBeat = ourPieces[j].radius + tFightMoves[m_curFightMove].strikeRadius;
// We can beat him too // We can beat him too
if (sq(maxDistanceToBeat) > attackDistance.MagnitudeSqr()) { if (sq(maxDistanceToBeat) > attackDistance.MagnitudeSqr()) {
@ -5055,7 +5001,7 @@ CPed::FightStrike(CVector &touchedNodePos)
float oldVictimHealth = nearPed->m_fHealth; float oldVictimHealth = nearPed->m_fHealth;
CVector bloodPos = 0.5f * attackDistance + touchedNodePos; CVector bloodPos = 0.5f * attackDistance + touchedNodePos;
int damageMult = tFightMoves[m_lastFightMove].damage * ((CGeneral::GetRandomNumber() & 1) + 2) + 1; int damageMult = tFightMoves[m_curFightMove].damage * ((CGeneral::GetRandomNumber() & 1) + 2) + 1;
CVector2D diff (GetPosition() - nearPed->GetPosition()); CVector2D diff (GetPosition() - nearPed->GetPosition());
int direction = nearPed->GetLocalDirection(diff); int direction = nearPed->GetLocalDirection(diff);
@ -5067,7 +5013,7 @@ CPed::FightStrike(CVector &touchedNodePos)
} }
// Change direction if we used kick. // Change direction if we used kick.
if (m_lastFightMove == FIGHTMOVE_KICK) { if (m_curFightMove == FIGHTMOVE_KICK) {
if (CGeneral::GetRandomNumber() & 1) { if (CGeneral::GetRandomNumber() & 1) {
direction++; direction++;
if (direction > 3) if (direction > 3)
@ -5083,16 +5029,16 @@ CPed::FightStrike(CVector &touchedNodePos)
else else
unk2 = damageMult; unk2 = damageMult;
nearPed->StartFightDefend(direction, tFightMoves[m_lastFightMove].hitLevel, unk2); nearPed->StartFightDefend(direction, tFightMoves[m_curFightMove].hitLevel, unk2);
PlayHitSound(nearPed); PlayHitSound(nearPed);
m_fightState = FIGHTSTATE_JUST_ATTACKED; m_fightState = FIGHTSTATE_JUST_ATTACKED;
RpAnimBlendClumpGetAssociation(GetClump(), tFightMoves[m_lastFightMove].animId)->speed = 0.6f; RpAnimBlendClumpGetAssociation(GetClump(), tFightMoves[m_curFightMove].animId)->speed = 0.6f;
if (!nearPed->DyingOrDead()) { if (!nearPed->DyingOrDead()) {
nearPed->InflictDamage(this, WEAPONTYPE_UNARMED, damageMult * 3.0f, closestPedPiece, direction); nearPed->InflictDamage(this, WEAPONTYPE_UNARMED, damageMult * 3.0f, closestPedPiece, direction);
} }
if (CGame::nastyGame if (CGame::nastyGame
&& tFightMoves[m_lastFightMove].hitLevel > HITLEVEL_MEDIUM && tFightMoves[m_curFightMove].hitLevel > HITLEVEL_MEDIUM
&& nearPed->m_nPedState == PED_DIE && nearPed->m_nPedState == PED_DIE
&& nearPed->GetIsOnScreen()) { && nearPed->GetIsOnScreen()) {
@ -5102,7 +5048,7 @@ CPed::FightStrike(CVector &touchedNodePos)
CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, attackDistance, nil, 0.0f, 0, 0, 0, 0); CParticle::AddParticle(PARTICLE_BLOOD, bloodPos, attackDistance, nil, 0.0f, 0, 0, 0, 0);
} }
} }
if (nearPed->m_nPedState != PED_FALL && nearPed->m_nPedState != PED_DIE && nearPed->m_nPedState != PED_DEAD) { if (!nearPed->OnGround()) {
float curVictimHealth = nearPed->m_fHealth; float curVictimHealth = nearPed->m_fHealth;
if (curVictimHealth > 0.0f if (curVictimHealth > 0.0f
&& (curVictimHealth < 40.0f && oldVictimHealth > 40.0f && !nearPed->IsPlayer() && (curVictimHealth < 40.0f && oldVictimHealth > 40.0f && !nearPed->IsPlayer()
@ -5122,7 +5068,7 @@ CPed::FightStrike(CVector &touchedNodePos)
nearPed->bIsStanding = false; nearPed->bIsStanding = false;
float moveMult; float moveMult;
if (m_lastFightMove == FIGHTMOVE_GROUNDKICK) { if (m_curFightMove == FIGHTMOVE_GROUNDKICK) {
moveMult = Min(damageMult * 0.6f, 4.0f); moveMult = Min(damageMult * 0.6f, 4.0f);
} else { } else {
if (nearPed->m_nPedState != PED_DIE || damageMult >= 20) { if (nearPed->m_nPedState != PED_DIE || damageMult >= 20) {
@ -5434,21 +5380,21 @@ CPed::PlayHitSound(CPed *hitTo)
}; };
// This is why first dimension is between FightMove 1 and 12. // This is why first dimension is between FightMove 1 and 12.
if (m_lastFightMove == FIGHTMOVE_NULL || m_lastFightMove >= FIGHTMOVE_HITFRONT) if (m_curFightMove == FIGHTMOVE_NULL || m_curFightMove >= FIGHTMOVE_HITFRONT)
return; return;
uint16 soundId; uint16 soundId;
// And this is why second dimension is between 13 and 22. // And this is why second dimension is between 13 and 22.
if (hitTo->m_lastFightMove <= FIGHTMOVE_GROUNDKICK || hitTo->m_lastFightMove >= FIGHTMOVE_IDLE2NORM) { if (hitTo->m_curFightMove > FIGHTMOVE_GROUNDKICK && hitTo->m_curFightMove < FIGHTMOVE_IDLE2NORM) {
soundId = hitSoundsByFightMoves[m_curFightMove - FIGHTMOVE_STDPUNCH][hitTo->m_curFightMove - FIGHTMOVE_HITFRONT];
if (hitTo->m_nPedState == PED_DEAD || hitTo->UseGroundColModel()) {
soundId = hitSoundsByFightMoves[m_lastFightMove - FIGHTMOVE_STDPUNCH][FIGHTMOVE_HITONFLOOR - FIGHTMOVE_HITFRONT];
} else {
soundId = hitSoundsByFightMoves[m_lastFightMove - FIGHTMOVE_STDPUNCH][FIGHTMOVE_HITFRONT - FIGHTMOVE_HITFRONT];
}
} else { } else {
soundId = hitSoundsByFightMoves[m_lastFightMove - FIGHTMOVE_STDPUNCH][hitTo->m_lastFightMove - FIGHTMOVE_HITFRONT]; if (hitTo->m_nPedState == PED_DEAD || hitTo->UseGroundColModel()) {
soundId = hitSoundsByFightMoves[m_curFightMove - FIGHTMOVE_STDPUNCH][FIGHTMOVE_HITONFLOOR - FIGHTMOVE_HITFRONT];
} else {
soundId = hitSoundsByFightMoves[m_curFightMove - FIGHTMOVE_STDPUNCH][FIGHTMOVE_HITFRONT - FIGHTMOVE_HITFRONT];
}
} }
if (soundId != NO_SND) if (soundId != NO_SND)
@ -6124,7 +6070,7 @@ CPed::EndFight(uint8 endType)
if (m_nPedState != PED_FIGHT) if (m_nPedState != PED_FIGHT)
return; return;
m_lastFightMove = FIGHTMOVE_NULL; m_curFightMove = FIGHTMOVE_NULL;
RestorePreviousState(); RestorePreviousState();
CAnimBlendAssociation *animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FIGHT_IDLE); CAnimBlendAssociation *animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_FIGHT_IDLE);
if (animAssoc) if (animAssoc)
@ -6353,24 +6299,27 @@ CPed::Fall(void)
void void
CPed::Fight(void) CPed::Fight(void)
{ {
CAnimBlendAssociation *currentAssoc = nil, *animAssoc; CAnimBlendAssociation *currentAssoc, *animAssoc;
bool hasShoppingBags, punchOnly, canKick, canKneeHead, canRoundhouse; bool hasShoppingBags, punchOnly, canKick, canKneeHead, canRoundhouse;
float angleToFace, nextAngle; float angleToFace, nextAngle;
bool goForward = false; bool goForward = false;
int nextFightMove; int nextFightMove;
switch (m_lastFightMove) { switch (m_curFightMove) {
case FIGHTMOVE_NULL: case FIGHTMOVE_NULL:
return; return;
case FIGHTMOVE_IDLE2NORM: case FIGHTMOVE_IDLE2NORM:
m_lastFightMove = FIGHTMOVE_NULL; m_curFightMove = FIGHTMOVE_NULL;
RestorePreviousState(); RestorePreviousState();
// FIX: Uninitialized
currentAssoc = nil;
break; break;
case FIGHTMOVE_IDLE: case FIGHTMOVE_IDLE:
// currentAssoc = nil; currentAssoc = nil;
break; break;
default: default:
currentAssoc = RpAnimBlendClumpGetAssociation(GetClump(), tFightMoves[m_lastFightMove].animId); currentAssoc = RpAnimBlendClumpGetAssociation(GetClump(), tFightMoves[m_curFightMove].animId);
break; break;
} }
@ -6387,12 +6336,12 @@ CPed::Fight(void)
} else if (currentAssoc && m_fightState > FIGHTSTATE_MOVE_FINISHED) { } else if (currentAssoc && m_fightState > FIGHTSTATE_MOVE_FINISHED) {
float animTime = currentAssoc->currentTime; float animTime = currentAssoc->currentTime;
FightMove &curMove = tFightMoves[m_lastFightMove]; FightMove &curMove = tFightMoves[m_curFightMove];
if (curMove.hitLevel != HITLEVEL_NULL && animTime > curMove.startFireTime && animTime <= curMove.endFireTime && m_fightState >= FIGHTSTATE_NO_MOVE) { if (curMove.hitLevel != HITLEVEL_NULL && animTime > curMove.startFireTime && animTime <= curMove.endFireTime && m_fightState >= FIGHTSTATE_NO_MOVE) {
CVector touchingNodePos(0.0f, 0.0f, 0.0f); CVector touchingNodePos(0.0f, 0.0f, 0.0f);
switch (m_lastFightMove) { switch (m_curFightMove) {
case FIGHTMOVE_STDPUNCH: case FIGHTMOVE_STDPUNCH:
case FIGHTMOVE_PUNCHHOOK: case FIGHTMOVE_PUNCHHOOK:
case FIGHTMOVE_BODYBLOW: case FIGHTMOVE_BODYBLOW:
@ -6418,9 +6367,9 @@ CPed::Fight(void)
break; break;
} }
if (m_lastFightMove == FIGHTMOVE_PUNCHJAB) { if (m_curFightMove == FIGHTMOVE_PUNCHJAB) {
touchingNodePos += 0.1f * GetForward(); touchingNodePos += 0.1f * GetForward();
} else if (m_lastFightMove == FIGHTMOVE_PUNCHHOOK) { } else if (m_curFightMove == FIGHTMOVE_PUNCHHOOK) {
touchingNodePos += 0.22f * GetForward(); touchingNodePos += 0.22f * GetForward();
} }
FightStrike(touchingNodePos); FightStrike(touchingNodePos);
@ -6440,7 +6389,7 @@ CPed::Fight(void)
if (curMove.comboFollowOnTime > 0.0f && m_fightButtonPressure != 0 && animTime > curMove.comboFollowOnTime) { if (curMove.comboFollowOnTime > 0.0f && m_fightButtonPressure != 0 && animTime > curMove.comboFollowOnTime) {
// Notice that it increases fight move index, because we're in combo! // Notice that it increases fight move index, because we're in combo!
animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[++m_lastFightMove].animId, 8.0f); animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[++m_curFightMove].animId, 8.0f);
animAssoc->SetFinishCallback(FinishFightMoveCB, this); animAssoc->SetFinishCallback(FinishFightMoveCB, this);
animAssoc->SetCurrentTime(0.1f * animAssoc->hierarchy->totalLength); animAssoc->SetCurrentTime(0.1f * animAssoc->hierarchy->totalLength);
m_fightButtonPressure = 0; m_fightButtonPressure = 0;
@ -6448,7 +6397,7 @@ CPed::Fight(void)
} }
} }
} else { } else {
if (curMove.startFireTime > 0.0f && m_lastFightMove != FIGHTMOVE_SHUFFLE_F && animTime > curMove.startFireTime) { if (curMove.startFireTime > 0.0f && m_curFightMove != FIGHTMOVE_SHUFFLE_F && animTime > curMove.startFireTime) {
if (IsPlayer()) if (IsPlayer())
currentAssoc->speed = 1.3f; currentAssoc->speed = 1.3f;
else else
@ -6504,8 +6453,7 @@ CPed::Fight(void)
if (neededTurn > PI) if (neededTurn > PI)
neededTurn = TWOPI - neededTurn; neededTurn = TWOPI - neededTurn;
PedState nearPedState = nearPed->m_nPedState; if (!nearPed->OnGroundOrGettingUp()) {
if (nearPedState != PED_FALL && nearPedState != PED_GETUP && nearPedState != PED_DIE && nearPedState != PED_DEAD) {
if (nearPedDist < 0.8f && neededTurn < DEGTORAD(75.0f) && canKneeHead) { if (nearPedDist < 0.8f && neededTurn < DEGTORAD(75.0f) && canKneeHead) {
canAffectMultiplePeople = false; canAffectMultiplePeople = false;
@ -6546,7 +6494,7 @@ CPed::Fight(void)
goForward = true; goForward = true;
} }
} else if (nearPedState != PED_DEAD || pedOnGround) { } else if (nearPed->m_nPedState != PED_DEAD || pedOnGround) {
if (!nearPed->IsPedHeadAbovePos(-0.3f)) { if (!nearPed->IsPedHeadAbovePos(-0.3f)) {
canAffectMultiplePeople = false; canAffectMultiplePeople = false;
nextFightMove = FIGHTMOVE_GROUNDKICK; nextFightMove = FIGHTMOVE_GROUNDKICK;
@ -6600,8 +6548,7 @@ CPed::Fight(void)
nextAngle = CGeneral::LimitRadianAngle(angleToFace); nextAngle = CGeneral::LimitRadianAngle(angleToFace);
m_fRotationDest = nextAngle; m_fRotationDest = nextAngle;
m_fRotationCur = m_fRotationDest; m_fRotationCur = m_fRotationDest;
PedState fightingPedState = m_pedInObjective->m_nPedState; if (!m_pedInObjective->OnGroundOrGettingUp()) {
if (fightingPedState != PED_FALL && fightingPedState != PED_GETUP && fightingPedState != PED_DIE && fightingPedState != PED_DEAD) {
if (fightingPedDist >= 0.8f || !canKneeHead) { if (fightingPedDist >= 0.8f || !canKneeHead) {
@ -6650,8 +6597,8 @@ CPed::Fight(void)
} }
if (nextFightMove != FIGHTMOVE_IDLE) { if (nextFightMove != FIGHTMOVE_IDLE) {
m_lastFightMove = nextFightMove; m_curFightMove = nextFightMove;
animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_lastFightMove].animId, 4.0f); animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_curFightMove].animId, 4.0f);
animAssoc->SetFinishCallback(FinishFightMoveCB, this); animAssoc->SetFinishCallback(FinishFightMoveCB, this);
if (m_fightState == FIGHTSTATE_MOVE_FINISHED && animAssoc->currentTime != 0.0f) { if (m_fightState == FIGHTSTATE_MOVE_FINISHED && animAssoc->currentTime != 0.0f) {
@ -6661,21 +6608,21 @@ CPed::Fight(void)
m_fightButtonPressure = 0; m_fightButtonPressure = 0;
} }
m_fightState = FIGHTSTATE_NO_MOVE; m_fightState = FIGHTSTATE_NO_MOVE;
} else if (m_takeAStepAfterAttack && m_lastFightMove != FIGHTMOVE_SHUFFLE_F } else if (m_takeAStepAfterAttack && m_curFightMove != FIGHTMOVE_SHUFFLE_F
#ifndef FIX_BUGS #ifndef FIX_BUGS
&& CheckForPedsOnGroundToAttack(this, nil) == 4) { && CheckForPedsOnGroundToAttack(this, nil) == 4) {
#else #else
&& CheckForPedsOnGroundToAttack(this, nil) == PED_IN_FRONT_OF_ATTACKER) { && CheckForPedsOnGroundToAttack(this, nil) == PED_IN_FRONT_OF_ATTACKER) {
#endif #endif
m_lastFightMove = FIGHTMOVE_SHUFFLE_F; m_curFightMove = FIGHTMOVE_SHUFFLE_F;
animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), tFightMoves[m_lastFightMove].animId); animAssoc = RpAnimBlendClumpGetAssociation(GetClump(), tFightMoves[m_curFightMove].animId);
if (animAssoc) { if (animAssoc) {
animAssoc->SetCurrentTime(0.0f); animAssoc->SetCurrentTime(0.0f);
animAssoc->blendDelta = 4.0f; animAssoc->blendDelta = 4.0f;
animAssoc->SetRun(); animAssoc->SetRun();
} else { } else {
animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_lastFightMove].animId, 32.0f); animAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_curFightMove].animId, 32.0f);
} }
animAssoc->SetFinishCallback(FinishFightMoveCB, this); animAssoc->SetFinishCallback(FinishFightMoveCB, this);
m_fightState = FIGHTSTATE_NO_MOVE; m_fightState = FIGHTSTATE_NO_MOVE;
@ -6685,13 +6632,13 @@ CPed::Fight(void)
} else if (m_takeAStepAfterAttack) { } else if (m_takeAStepAfterAttack) {
EndFight(ENDFIGHT_FAST); EndFight(ENDFIGHT_FAST);
} else if (m_lastFightMove == FIGHTMOVE_IDLE) { } else if (m_curFightMove == FIGHTMOVE_IDLE) {
if (CTimer::GetTimeInMilliseconds() > m_nWaitTimer) { if (CTimer::GetTimeInMilliseconds() > m_nWaitTimer) {
EndFight(ENDFIGHT_NORMAL); EndFight(ENDFIGHT_NORMAL);
} }
} else { } else {
m_lastFightMove = FIGHTMOVE_IDLE; m_curFightMove = FIGHTMOVE_IDLE;
if (IsPlayer()) if (IsPlayer())
m_nWaitTimer = CTimer::GetTimeInMilliseconds() + 500; m_nWaitTimer = CTimer::GetTimeInMilliseconds() + 500;
else else
@ -6781,7 +6728,7 @@ CPed::FinishFightMoveCB(CAnimBlendAssociation *animAssoc, void *arg)
{ {
CPed *ped = (CPed*)arg; CPed *ped = (CPed*)arg;
if (tFightMoves[ped->m_lastFightMove].animId == animAssoc->animId) { if (tFightMoves[ped->m_curFightMove].animId == animAssoc->animId) {
ped->m_fightState = FIGHTSTATE_MOVE_FINISHED; ped->m_fightState = FIGHTSTATE_MOVE_FINISHED;
animAssoc->blendDelta = -1000.0f; animAssoc->blendDelta = -1000.0f;
} }
@ -7527,9 +7474,9 @@ CPed::Flee(void)
if (!m_collidingEntityWhileFleeing) if (!m_collidingEntityWhileFleeing)
return; return;
double damagingThingPriorityMult = (double)(m_collidingThingTimer - CTimer::GetTimeInMilliseconds()) * 2.0 / 2500; double collidingThingPriorityMult = (double)(m_collidingThingTimer - CTimer::GetTimeInMilliseconds()) * 2.0 / 2500;
if (damagingThingPriorityMult <= 1.5) { if (collidingThingPriorityMult <= 1.5) {
double angleToFleeEntity = CGeneral::GetRadianAngleBetweenPoints( double angleToFleeEntity = CGeneral::GetRadianAngleBetweenPoints(
GetPosition().x, GetPosition().x,
@ -7538,35 +7485,34 @@ CPed::Flee(void)
m_collidingEntityWhileFleeing->GetPosition().y); m_collidingEntityWhileFleeing->GetPosition().y);
angleToFleeEntity = CGeneral::LimitRadianAngle(angleToFleeEntity); angleToFleeEntity = CGeneral::LimitRadianAngle(angleToFleeEntity);
// It includes projectiles, but is everything collides with us included? double angleToFleeCollidingThing = CGeneral::GetRadianAngleBetweenPoints(
double angleToFleeDamagingThing = CGeneral::GetRadianAngleBetweenPoints(
m_vecDamageNormal.x, m_vecDamageNormal.x,
m_vecDamageNormal.y, m_vecDamageNormal.y,
0.0f, 0.0f,
0.0f); 0.0f);
angleToFleeDamagingThing = CGeneral::LimitRadianAngle(angleToFleeDamagingThing); angleToFleeCollidingThing = CGeneral::LimitRadianAngle(angleToFleeCollidingThing);
if (angleToFleeEntity - PI > angleToFleeDamagingThing) if (angleToFleeEntity - PI > angleToFleeCollidingThing)
angleToFleeDamagingThing += TWOPI; angleToFleeCollidingThing += TWOPI;
else if (PI + angleToFleeEntity < angleToFleeDamagingThing) else if (PI + angleToFleeEntity < angleToFleeCollidingThing)
angleToFleeDamagingThing -= TWOPI; angleToFleeCollidingThing -= TWOPI;
if (damagingThingPriorityMult <= 1.0f) { if (collidingThingPriorityMult <= 1.0f) {
// Range [0.0, 1.0] // Range [0.0, 1.0]
float angleToFleeBoth = (angleToFleeDamagingThing + angleToFleeEntity) * 0.5f; float angleToFleeBoth = (angleToFleeCollidingThing + angleToFleeEntity) * 0.5f;
if (m_fRotationDest - PI > angleToFleeBoth) if (m_fRotationDest - PI > angleToFleeBoth)
angleToFleeBoth += TWOPI; angleToFleeBoth += TWOPI;
else if (PI + m_fRotationDest < angleToFleeBoth) else if (PI + m_fRotationDest < angleToFleeBoth)
angleToFleeBoth -= TWOPI; angleToFleeBoth -= TWOPI;
m_fRotationDest = (1.0f - damagingThingPriorityMult) * m_fRotationDest + damagingThingPriorityMult * angleToFleeBoth; m_fRotationDest = (1.0f - collidingThingPriorityMult) * m_fRotationDest + collidingThingPriorityMult * angleToFleeBoth;
} else { } else {
// Range (1.0, 1.5] // Range (1.0, 1.5]
double adjustedMult = (damagingThingPriorityMult - 1.0f) * 2.0f; double adjustedMult = (collidingThingPriorityMult - 1.0f) * 2.0f;
m_fRotationDest = angleToFleeEntity * (1.0 - adjustedMult) + adjustedMult * angleToFleeDamagingThing; m_fRotationDest = angleToFleeEntity * (1.0 - adjustedMult) + adjustedMult * angleToFleeCollidingThing;
} }
} else { } else {
m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints( m_fRotationDest = CGeneral::GetRadianAngleBetweenPoints(
@ -8564,8 +8510,7 @@ CPed::KillPedWithCar(CVehicle *car, float impulse)
CPed::InflictDamage(car, WEAPONTYPE_RAMMEDBYCAR, damage, PEDPIECE_TORSO, fallDirection); CPed::InflictDamage(car, WEAPONTYPE_RAMMEDBYCAR, damage, PEDPIECE_TORSO, fallDirection);
CPed::SetFall(1000, (AnimationId)(fallDirection + ANIM_KO_SKID_FRONT), true); CPed::SetFall(1000, (AnimationId)(fallDirection + ANIM_KO_SKID_FRONT), true);
if ((m_nPedState == PED_FALL || m_nPedState == PED_DIE || m_nPedState == PED_DEAD) if (OnGround() && !m_pCollidingEntity &&
&& !m_pCollidingEntity &&
(!IsPlayer() || bHasHitWall || car->GetModelIndex() == MI_TRAIN || m_vecDamageNormal.z < -0.8f)) { (!IsPlayer() || bHasHitWall || car->GetModelIndex() == MI_TRAIN || m_vecDamageNormal.z < -0.8f)) {
m_pCollidingEntity = car; m_pCollidingEntity = car;
@ -14992,7 +14937,7 @@ CPed::PreRender(void)
CVector speed = FindPlayerSpeed(); CVector speed = FindPlayerSpeed();
if (Abs(speed.x) <= 0.05f && Abs(speed.y) <= 0.05f) { if (Abs(speed.x) <= 0.05f && Abs(speed.y) <= 0.05f) {
if (m_nPedState != PED_FALL && !DyingOrDead() && m_nPedState != PED_ATTACK && m_nPedState != PED_FIGHT) { if (!OnGround() && m_nPedState != PED_ATTACK && m_nPedState != PED_FIGHT) {
if (!IsPedHeadAbovePos(0.3f) || RpAnimBlendClumpGetAssociation(GetClump(), ANIM_IDLE_TIRED)) { if (!IsPedHeadAbovePos(0.3f) || RpAnimBlendClumpGetAssociation(GetClump(), ANIM_IDLE_TIRED)) {
doSplashUp = false; doSplashUp = false;
} }
@ -16201,7 +16146,7 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk)
Say(SOUND_PED_DEFEND); Say(SOUND_PED_DEFEND);
switch (hitLevel) { switch (hitLevel) {
case HITLEVEL_GROUND: case HITLEVEL_GROUND:
m_lastFightMove = FIGHTMOVE_HITONFLOOR; m_curFightMove = FIGHTMOVE_HITONFLOOR;
break; break;
case HITLEVEL_LOW: case HITLEVEL_LOW:
#ifndef VC_PED_PORTS #ifndef VC_PED_PORTS
@ -16218,52 +16163,52 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk)
return; return;
} }
#endif #endif
m_lastFightMove = FIGHTMOVE_HITBODY; m_curFightMove = FIGHTMOVE_HITBODY;
break; break;
case HITLEVEL_HIGH: case HITLEVEL_HIGH:
switch (direction) { switch (direction) {
case 1: case 1:
m_lastFightMove = FIGHTMOVE_HITLEFT; m_curFightMove = FIGHTMOVE_HITLEFT;
break; break;
case 2: case 2:
m_lastFightMove = FIGHTMOVE_HITBACK; m_curFightMove = FIGHTMOVE_HITBACK;
break; break;
case 3: case 3:
m_lastFightMove = FIGHTMOVE_HITRIGHT; m_curFightMove = FIGHTMOVE_HITRIGHT;
break; break;
default: default:
if (unk <= 5) if (unk <= 5)
m_lastFightMove = FIGHTMOVE_HITHEAD; m_curFightMove = FIGHTMOVE_HITHEAD;
else else
m_lastFightMove = FIGHTMOVE_HITBIGSTEP; m_curFightMove = FIGHTMOVE_HITBIGSTEP;
break; break;
} }
break; break;
default: default:
switch (direction) { switch (direction) {
case 1: case 1:
m_lastFightMove = FIGHTMOVE_HITLEFT; m_curFightMove = FIGHTMOVE_HITLEFT;
break; break;
case 2: case 2:
m_lastFightMove = FIGHTMOVE_HITBACK; m_curFightMove = FIGHTMOVE_HITBACK;
break; break;
case 3: case 3:
m_lastFightMove = FIGHTMOVE_HITRIGHT; m_curFightMove = FIGHTMOVE_HITRIGHT;
break; break;
default: default:
if (unk <= 5) if (unk <= 5)
m_lastFightMove = FIGHTMOVE_HITCHEST; m_curFightMove = FIGHTMOVE_HITCHEST;
else else
m_lastFightMove = FIGHTMOVE_HITBIGSTEP; m_curFightMove = FIGHTMOVE_HITBIGSTEP;
break; break;
} }
break; break;
} }
if (m_nPedState == PED_GETUP && !IsPedHeadAbovePos(0.0f)) if (m_nPedState == PED_GETUP && !IsPedHeadAbovePos(0.0f))
m_lastFightMove = FIGHTMOVE_HITONFLOOR; m_curFightMove = FIGHTMOVE_HITONFLOOR;
if (m_nPedState == PED_FIGHT) { if (m_nPedState == PED_FIGHT) {
CAnimBlendAssociation *moveAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_lastFightMove].animId, 8.0f); CAnimBlendAssociation *moveAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_curFightMove].animId, 8.0f);
moveAssoc->SetCurrentTime(0.0f); moveAssoc->SetCurrentTime(0.0f);
moveAssoc->SetFinishCallback(FinishFightMoveCB, this); moveAssoc->SetFinishCallback(FinishFightMoveCB, this);
if (IsPlayer()) if (IsPlayer())
@ -16272,7 +16217,7 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk)
m_takeAStepAfterAttack = 0; m_takeAStepAfterAttack = 0;
m_fightButtonPressure = 0; m_fightButtonPressure = 0;
} else if (IsPlayer() && m_currentWeapon != WEAPONTYPE_UNARMED) { } else if (IsPlayer() && m_currentWeapon != WEAPONTYPE_UNARMED) {
CAnimBlendAssociation *moveAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_lastFightMove].animId, 4.0f); CAnimBlendAssociation *moveAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_curFightMove].animId, 4.0f);
moveAssoc->SetCurrentTime(0.0f); moveAssoc->SetCurrentTime(0.0f);
moveAssoc->speed = 1.3f; moveAssoc->speed = 1.3f;
} else { } else {
@ -16302,7 +16247,7 @@ CPed::StartFightDefend(uint8 direction, uint8 hitLevel, uint8 unk)
SetMoveState(PEDMOVE_NONE); SetMoveState(PEDMOVE_NONE);
m_nStoredMoveState = PEDMOVE_NONE; m_nStoredMoveState = PEDMOVE_NONE;
CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_FIGHT_IDLE)->blendAmount = 1.0f; CAnimManager::AddAnimation(GetClump(), ASSOCGRP_STD, ANIM_FIGHT_IDLE)->blendAmount = 1.0f;
CAnimBlendAssociation *moveAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_lastFightMove].animId, 8.0f); CAnimBlendAssociation *moveAssoc = CAnimManager::BlendAnimation(GetClump(), ASSOCGRP_STD, tFightMoves[m_curFightMove].animId, 8.0f);
moveAssoc->SetFinishCallback(FinishFightMoveCB, this); moveAssoc->SetFinishCallback(FinishFightMoveCB, this);
m_fightState = FIGHTSTATE_NO_MOVE; m_fightState = FIGHTSTATE_NO_MOVE;
m_takeAStepAfterAttack = false; m_takeAStepAfterAttack = false;

View File

@ -480,7 +480,7 @@ public:
uint8 m_wepAccuracy; uint8 m_wepAccuracy;
CEntity *m_pPointGunAt; CEntity *m_pPointGunAt;
CVector m_vecHitLastPos; CVector m_vecHitLastPos;
uint32 m_lastFightMove; uint32 m_curFightMove;
uint8 m_fightButtonPressure; uint8 m_fightButtonPressure;
FightState m_fightState; FightState m_fightState;
bool m_takeAStepAfterAttack; bool m_takeAStepAfterAttack;
@ -802,6 +802,7 @@ public:
bool Dying(void) { return m_nPedState == PED_DIE; } bool Dying(void) { return m_nPedState == PED_DIE; }
bool DyingOrDead(void) { return m_nPedState == PED_DIE || m_nPedState == PED_DEAD; } bool DyingOrDead(void) { return m_nPedState == PED_DIE || m_nPedState == PED_DEAD; }
bool OnGround(void) { return m_nPedState == PED_FALL || m_nPedState == PED_DIE || m_nPedState == PED_DEAD; } bool OnGround(void) { return m_nPedState == PED_FALL || m_nPedState == PED_DIE || m_nPedState == PED_DEAD; }
bool OnGroundOrGettingUp(void) { return OnGround() || m_nPedState == PED_GETUP; }
bool Driving(void) { return m_nPedState == PED_DRIVING; } bool Driving(void) { return m_nPedState == PED_DRIVING; }
bool InVehicle(void) { return bInVehicle && m_pMyVehicle; } // True when ped is sitting/standing in vehicle, not in enter/exit state. bool InVehicle(void) { return bInVehicle && m_pMyVehicle; } // True when ped is sitting/standing in vehicle, not in enter/exit state.

View File

@ -64,10 +64,6 @@ static psGlobalType PsGlobal;
#undef MAKEPOINTS #undef MAKEPOINTS
#define MAKEPOINTS(l) (*((POINTS /*FAR*/ *)&(l))) #define MAKEPOINTS(l) (*((POINTS /*FAR*/ *)&(l)))
#define SAFE_RELEASE(x) { if (x) x->Release(); x = NULL; }
#define JIF(x) if (FAILED(hr=(x))) \
{debug(TEXT("FAILED(hr=0x%x) in ") TEXT(#x) TEXT("\n"), hr); return;}
unsigned long _dwMemAvailPhys; unsigned long _dwMemAvailPhys;
RwUInt32 gGameState; RwUInt32 gGameState;