PlayerPed and "Redefine controls" menu done, fixes

This commit is contained in:
erorcun 2020-11-29 19:19:50 +03:00
parent 8cb3c07151
commit bd8b907d13
15 changed files with 1048 additions and 711 deletions

View File

@ -97,11 +97,7 @@ CRoadBlocks::GenerateRoadBlockCopsForCar(CVehicle* pVehicle, int32 roadBlockType
pCopPed->m_nRoadblockVeh->RegisterReference((CEntity**)&pCopPed->m_nRoadblockVeh);
pCopPed->bCrouchWhenShooting = roadBlockType == 2 ? false : true;
if (pEntityToAttack) {
if (pCopPed->m_pPointGunAt)
pCopPed->m_pPointGunAt->CleanUpOldReference(&pCopPed->m_pPointGunAt);
pCopPed->m_pPointGunAt = pEntityToAttack;
if (pEntityToAttack)
pEntityToAttack->RegisterReference(&pCopPed->m_pPointGunAt);
pCopPed->SetWeaponLockOnTarget(pEntityToAttack);
pCopPed->SetAttack(pEntityToAttack);
}
pCopPed->m_pMyVehicle = pVehicle;

View File

@ -1011,14 +1011,15 @@ CCamera::CamControl(void)
if((m_bLookingAtPlayer || m_bEnable1rstPersonCamCntrlsScript) && pTargetEntity->IsPed() &&
(!m_WideScreenOn || m_bEnable1rstPersonCamCntrlsScript) && !Cams[0].Using3rdPersonMouseCam()
#ifdef FREE_CAM
&& !CCamera::bFreeCam
&& (!CCamera::bFreeCam || m_bEnable1rstPersonCamCntrlsScript)
#endif
){
// See if we want to enter first person mode
if(CPad::GetPad(0)->LookAroundLeftRight() || CPad::GetPad(0)->LookAroundUpDown()){
m_uiFirstPersonCamLastInputTime = CTimer::GetTimeInMilliseconds();
m_bFirstPersonBeingUsed = true;
}else if(m_bFirstPersonBeingUsed){
}
if(m_bFirstPersonBeingUsed){
// Or if we want to go back to 3rd person
if(CPad::GetPad(0)->GetPedWalkLeftRight() || CPad::GetPad(0)->GetPedWalkUpDown() ||
CPad::GetPad(0)->GetSquare() || CPad::GetPad(0)->GetTriangle() ||
@ -1701,7 +1702,7 @@ CCamera::CamControl(void)
StartTransitionWhenNotFinishedInter(ReqMode);
pTargetEntity->RegisterReference(&pTargetEntity);
Cams[ActiveCam].CamTargetEntity->RegisterReference(&Cams[ActiveCam].CamTargetEntity);
}else if(m_bStartInterScript && m_iTypeOfSwitch == JUMP_CUT){
}else if(m_bStartInterScript && m_iTypeOfSwitch == JUMP_CUT || jumpCutTo1stPrs){
m_uiTransitionState = 0;
m_vecDoingSpecialInterPolation = false;
if(m_bEnable1rstPersonCamCntrlsScript && ReqMode == CCam::MODE_1STPERSON)

File diff suppressed because it is too large Load Diff

View File

@ -85,16 +85,15 @@
#define CONTSETUP_CLASSIC_ROW_HEIGHT 9.0f
#define CONTSETUP_BOUND_HIGHLIGHT_HEIGHT 10
#define CONTSETUP_BOUND_COLUMN_WIDTH 190.0f
#define CONTSETUP_LIST_HEADER_HEIGHT 20.0f
#define CONTSETUP_LIST_TOP 28.0f
#define CONTSETUP_LIST_TOP 58.0f
#define CONTSETUP_LIST_RIGHT 18.0f
#define CONTSETUP_LIST_BOTTOM 120.0f
#define CONTSETUP_LIST_LEFT 18.0f
#define CONTSETUP_LIST_BOTTOM 78.0f
#define CONTSETUP_LIST_LEFT 30.0f
#define CONTSETUP_COLUMN_1_X 40.0f
#define CONTSETUP_COLUMN_2_X 210.0f
#define CONTSETUP_COLUMN_3_X (CONTSETUP_COLUMN_2_X + CONTSETUP_BOUND_COLUMN_WIDTH + 10.0f)
#define CONTSETUP_BACK_RIGHT 35.0f
#define CONTSETUP_BACK_BOTTOM 122.0f
#define CONTSETUP_BACK_BOTTOM 82.0f
#define CONTSETUP_BACK_HEIGHT 25.0f
enum
@ -310,21 +309,6 @@ enum eCheckHover
HOVEROPTION_USESKIN, // also layer in controller setup and skin menu
HOVEROPTION_NEXT_RADIO,
HOVEROPTION_PREV_RADIO,
// Below is TODO(Miami)
// those are unused in VC
HOVEROPTION_RADIO_0 = HOVEROPTION_NEXT_RADIO,
HOVEROPTION_RADIO_1,
HOVEROPTION_RADIO_2,
HOVEROPTION_RADIO_3,
HOVEROPTION_RADIO_4,
HOVEROPTION_RADIO_5,
HOVEROPTION_RADIO_6,
HOVEROPTION_RADIO_7,
HOVEROPTION_RADIO_8,
HOVEROPTION_RADIO_9,
HOVEROPTION_INCREASE_BRIGHTNESS,
HOVEROPTION_DECREASE_BRIGHTNESS,
HOVEROPTION_INCREASE_DRAWDIST,
@ -359,7 +343,7 @@ enum eControlMethod
enum ControllerSetupColumn
{
CONTSETUP_PED_COLUMN = 0,
CONTSETUP_VEHICLE_COLUMN = 14,
CONTSETUP_VEHICLE_COLUMN = 16,
};
struct tSkinInfo
@ -485,7 +469,7 @@ public:
int8 m_PrefsShowSubtitles;
int8 m_PrefsShowLegends;
int8 m_PrefsUseWideScreen;
int8 m_PrefsVsync; // TODO(Miami): Are we sure?
int8 m_PrefsVsync;
int8 m_PrefsVsyncDisp;
int8 m_PrefsFrameLimiter;
int8 m_nPrefsAudio3DProviderIndex;
@ -526,7 +510,7 @@ public:
uint8 field_74[4];
int32 *pControlEdit;
bool m_OnlySaveMenu;
int32 m_menuTransitionProgress;
int32 m_firstStartCounter;
CSprite2d m_aFrontEndSprites[NUM_MENU_SPRITES];
bool m_bSpritesLoaded;
int32 m_LeftMostRadioX;
@ -662,7 +646,6 @@ public:
void Initialise();
void PrintMap();
void SetFrontEndRenderStates();
static void BuildStatLine(Const char *text, void *stat, bool itsFloat, void *stat2);
static void CentreMousePointer();
void CheckCodesForControls(int);
bool CheckHover(int x1, int x2, int y1, int y2);
@ -679,7 +662,6 @@ public:
void DrawBackground(bool transitionCall);
void DrawPlayerSetupScreen(bool);
int FadeIn(int alpha);
void FilterOutColorMarkersFromString(wchar*);
int GetStartOptionsCntrlConfigScreens();
void InitialiseChangedLanguageSettings();
void LoadAllTextures();
@ -707,7 +689,6 @@ public:
void UnloadTextures();
void WaitForUserCD();
int GetNumOptionsCntrlConfigScreens();
int ConstructStatLine(int);
void SwitchToNewScreen(int8);
void AdditionalOptionInput(bool &goBack);
void ExportStats(void);

View File

@ -5,6 +5,9 @@
#include "World.h"
#include "Pad.h"
#include "DMAudio.h"
#include "main.h"
#include "Font.h"
#include "Frontend.h"
#include <climits>
@ -774,3 +777,254 @@ CStats::PopulateFavoriteRadioStationList()
for (int i = 0; i < NUM_RADIOS; i++)
FavoriteRadioStationList[i] = pListenTimeArray[i];
}
void
CStats::BuildStatLine(Const char *text, void *stat, int displayType, void *stat2, int isTime)
{
#define STAT_D *(int*)stat
#define STAT_F *(float*)stat
#define STAT2_D *(int*)stat2
#define STAT2_F *(float*)stat2
if (!text)
return;
gString2[0] = '\0';
if (isTime == 1) {
if (*((int*)stat2) >= 10)
sprintf(gString2, " %d:%d", STAT_D, STAT2_D);
else
sprintf(gString2, " %d:0%d", STAT_D, STAT2_D);
} else if (stat2) {
#ifdef MORE_LANGUAGES
if (CFont::IsJapanese()) {
switch (displayType) {
case 0:
case 4:
sprintf(gString2, " %d/%d", STAT_D, STAT2_D);
break;
case 1:
sprintf(gString2, " %.2f/%.2f", STAT_F, STAT2_F);
break;
case 2:
sprintf(gString2, " %d%%/%d%%", STAT_D, STAT2_D);
break;
case 3:
sprintf(gString2, " $%.2f/$%.2f", STAT_F, STAT2_F);
break;
default:
break;
}
} else
#endif
{
switch (displayType) {
case 0:
sprintf(gString2, " %d %s %d", STAT_D, UnicodeToAscii(TheText.Get("FEST_OO")), STAT2_D);
break;
case 1:
sprintf(gString2, " %.2f %s %.2f", STAT_F, UnicodeToAscii(TheText.Get("FEST_OO")), STAT2_F);
break;
case 2:
sprintf(gString2, " %d%% %s %d%%", STAT_D, UnicodeToAscii(TheText.Get("FEST_OO")), STAT2_D);
break;
case 3:
sprintf(gString2, " $%.2f %s $%.2f", STAT_F, UnicodeToAscii(TheText.Get("FEST_OO")), STAT2_F);
break;
case 4:
sprintf(gString2, " %d_ %s %d_", STAT_D, UnicodeToAscii(TheText.Get("FEST_OO")), STAT2_D);
break;
default:
break;
}
}
} else if (stat) {
switch (displayType) {
case 0:
sprintf(gString2, "%d", STAT_D);
break;
case 1:
sprintf(gString2, "%.2f", STAT_F);
break;
case 2:
sprintf(gString2, "%d%%", STAT_D);
break;
case 3:
sprintf(gString2, "$%.2f", STAT_F);
break;
case 4:
#ifdef MORE_LANGUAGES
if (CFont::IsJapanese())
sprintf(gString2, "%d", STAT_D);
else
#endif
sprintf(gString2, "%d_", STAT_D);
break;
default:
break;
}
}
UnicodeStrcpy(gUString, TheText.Get(text));
CFont::FilterOutTokensFromString(gUString);
AsciiToUnicode(gString2, gUString2);
#undef STAT_D
#undef STAT_F
#undef STAT2_D
#undef STAT2_F
}
// TODO(Miami)
// rowIdx 99999 returns total numbers of rows. otherwise it returns 0.
int
CStats::ConstructStatLine(int rowIdx)
{
#define STAT_LINE(str, left, isFloat, right) \
do { \
if(counter == rowIdx){ \
BuildStatLine(str, left, isFloat ? 1 : 0, right, 0); \
return 0; \
} counter++; \
} while(0)
int counter = 0, nTemp;
STAT_LINE("PL_STAT", nil, false, nil);
int percentCompleted = GetPercentageProgress();
STAT_LINE("PER_COM", &percentCompleted, false, nil);
STAT_LINE("NMISON", &MissionsGiven, false, nil);
STAT_LINE("FEST_MP", &MissionsPassed, false, &TotalNumberMissions);
if (CGame::nastyGame) {
STAT_LINE("FEST_RP", &NumberKillFrenziesPassed, false, &TotalNumberKillFrenzies);
}
CPlayerInfo &player = CWorld::Players[CWorld::PlayerInFocus];
float packagesPercent = 0.0f;
if (player.m_nTotalPackages != 0)
packagesPercent = player.m_nCollectedPackages * 100.0f / player.m_nTotalPackages;
int nPackagesPercent = packagesPercent;
STAT_LINE("PERPIC", &nPackagesPercent, false, &(nTemp = 100));
STAT_LINE("NOUNIF", &NumberOfUniqueJumpsFound, false, &TotalNumberOfUniqueJumps);
STAT_LINE("DAYSPS", &DaysPassed, false, nil);
if (CGame::nastyGame) {
STAT_LINE("PE_WAST", &PeopleKilledByPlayer, false, nil);
STAT_LINE("PE_WSOT", &PeopleKilledByOthers, false, nil);
}
STAT_LINE("CAR_EXP", &CarsExploded, false, nil);
STAT_LINE("TM_BUST", &TimesArrested, false, nil);
STAT_LINE("TM_DED", &TimesDied, false, nil);
STAT_LINE("GNG_WST", &(nTemp = PedsKilledOfThisType[PEDTYPE_GANG9] + PedsKilledOfThisType[PEDTYPE_GANG8]
+ PedsKilledOfThisType[PEDTYPE_GANG7] + PedsKilledOfThisType[PEDTYPE_GANG6]
+ PedsKilledOfThisType[PEDTYPE_GANG5] + PedsKilledOfThisType[PEDTYPE_GANG4]
+ PedsKilledOfThisType[PEDTYPE_GANG3] + PedsKilledOfThisType[PEDTYPE_GANG2]
+ PedsKilledOfThisType[PEDTYPE_GANG1]), false, nil);
STAT_LINE("DED_CRI", &(nTemp = PedsKilledOfThisType[PEDTYPE_CRIMINAL]), false, nil);
STAT_LINE("HEL_DST", &HelisDestroyed, false, nil);
STAT_LINE("KGS_EXP", &KgsOfExplosivesUsed, false, nil);
if (HighestScores[0] > 0) {
STAT_LINE("FEST_BB", nil, false, nil);
STAT_LINE("FEST_H0", &HighestScores[0], false, nil);
}
if (HighestScores[4] + HighestScores[3] + HighestScores[2] + HighestScores[1] > 0) {
STAT_LINE("FEST_GC", nil, false, nil);
}
if (HighestScores[1] > 0) {
STAT_LINE("FEST_H1", &HighestScores[1], false, nil);
}
if (HighestScores[2] > 0) {
STAT_LINE("FEST_H2", &HighestScores[2], false, nil);
}
if (HighestScores[3] > 0) {
STAT_LINE("FEST_H3", &HighestScores[3], false, nil);
}
if (HighestScores[4] > 0) {
STAT_LINE("FEST_H4", &HighestScores[4], false, nil);
}
switch (FrontEndMenuManager.m_PrefsLanguage) {
case CMenuManager::LANGUAGE_AMERICAN:
#ifndef USE_MEASUREMENTS_IN_METERS
float fTemp;
STAT_LINE("FEST_DF", &(fTemp = DistanceTravelledOnFoot * MILES_IN_METER), true, nil);
STAT_LINE("FEST_DC", &(fTemp = DistanceTravelledByCar * MILES_IN_METER), true, nil);
STAT_LINE("DISTBIK", &(fTemp = DistanceTravelledByBike * MILES_IN_METER), true, nil);
STAT_LINE("DISTBOA", &(fTemp = DistanceTravelledByBoat * MILES_IN_METER), true, nil);
STAT_LINE("DISTGOL", &(fTemp = DistanceTravelledByGolfCart * MILES_IN_METER), true, nil);
STAT_LINE("DISTHEL", &(fTemp = DistanceTravelledByHelicoptor * MILES_IN_METER), true, nil);
STAT_LINE("MXCARD", &(fTemp = MaximumJumpDistance * FEET_IN_METER), true, nil);
STAT_LINE("MXCARJ", &(fTemp = MaximumJumpHeight * FEET_IN_METER), true, nil);
break;
#endif
case CMenuManager::LANGUAGE_FRENCH:
case CMenuManager::LANGUAGE_GERMAN:
case CMenuManager::LANGUAGE_ITALIAN:
case CMenuManager::LANGUAGE_SPANISH:
#ifdef MORE_LANGUAGES
case CMenuManager::LANGUAGE_POLISH:
case CMenuManager::LANGUAGE_RUSSIAN:
case CMenuManager::LANGUAGE_JAPANESE:
#endif
STAT_LINE("FESTDFM", &DistanceTravelledOnFoot, true, nil);
STAT_LINE("FESTDCM", &DistanceTravelledByCar, true, nil);
STAT_LINE("DISTBIM", &DistanceTravelledByBike, true, nil);
STAT_LINE("DISTBOM", &DistanceTravelledByBoat, true, nil);
STAT_LINE("DISTGOM", &DistanceTravelledByGolfCart, true, nil);
STAT_LINE("DISTHEM", &DistanceTravelledByHelicoptor, true, nil);
STAT_LINE("MXCARDM", &MaximumJumpDistance, true, nil);
STAT_LINE("MXCARJM", &MaximumJumpHeight, true, nil);
break;
default:
break;
}
STAT_LINE("MXFLIP", &MaximumJumpFlips, false, nil);
STAT_LINE("MXJUMP", &MaximumJumpSpins, false, nil);
STAT_LINE("BSTSTU", nil, false, nil);
if (counter == rowIdx) {
gUString[0] = '\0';
switch (BestStuntJump) {
case 1:
UnicodeStrcpy(gUString2, TheText.Get("INSTUN"));
return 0;
case 2:
UnicodeStrcpy(gUString2, TheText.Get("PRINST"));
return 0;
case 3:
UnicodeStrcpy(gUString2, TheText.Get("DBINST"));
return 0;
case 4:
UnicodeStrcpy(gUString2, TheText.Get("DBPINS"));
return 0;
case 5:
UnicodeStrcpy(gUString2, TheText.Get("TRINST"));
return 0;
case 6:
UnicodeStrcpy(gUString2, TheText.Get("PRTRST"));
return 0;
case 7:
UnicodeStrcpy(gUString2, TheText.Get("QUINST"));
return 0;
case 8:
UnicodeStrcpy(gUString2, TheText.Get("PQUINS"));
return 0;
default:
UnicodeStrcpy(gUString2, TheText.Get("NOSTUC"));
return 0;
}
}
counter++;
STAT_LINE("PASDRO", &PassengersDroppedOffWithTaxi, false, nil);
STAT_LINE("MONTAX", &MoneyMadeWithTaxi, false, nil);
STAT_LINE("FEST_LS", &LivesSavedWithAmbulance, false, nil);
STAT_LINE("FEST_HA", &HighestLevelAmbulanceMission, false, nil);
STAT_LINE("FEST_CC", &CriminalsCaught, false, nil);
STAT_LINE("FEST_FE", &FiresExtinguished, false, nil);
STAT_LINE("DAYPLC", &(nTemp = CTimer::GetTimeInMilliseconds() + 100), false, nil);
return counter;
#undef STAT_LINE
}

View File

@ -147,4 +147,6 @@ public:
static void AddPropertyAsOwned(int32);
static void PopulateFavoriteRadioStationList();
static float GetFavoriteRadioStationList(int32);
static void BuildStatLine(Const char *, void *, int, void *, int);
static int ConstructStatLine(int);
};

View File

@ -96,9 +96,7 @@ CCopPed::CCopPed(eCopType copType, int32 modifier) : CPed(PEDTYPE_COP)
field_61C = 0;
field_624 = 0;
m_pStinger = new CStinger;
if (m_pPointGunAt)
m_pPointGunAt->CleanUpOldReference(&m_pPointGunAt);
m_pPointGunAt = nil;
SetWeaponLockOnTarget(nil);
}
CCopPed::~CCopPed()
@ -493,12 +491,7 @@ CCopPed::CopAI(void)
false, true, false, false, true, false, false)
|| foundEnt && foundEnt == playerOrHisVeh) {
if (m_pPointGunAt)
m_pPointGunAt->CleanUpOldReference((CEntity**) &m_pPointGunAt);
m_pPointGunAt = playerOrHisVeh;
if (playerOrHisVeh)
playerOrHisVeh->RegisterReference((CEntity**) &m_pPointGunAt);
SetWeaponLockOnTarget(playerOrHisVeh);
SetAttack(playerOrHisVeh);
SetShootTimer(CGeneral::GetRandomNumberInRange(500, 1000));
}

View File

@ -9770,6 +9770,17 @@ CPed::Say(uint16 audio, int32 time)
}
}
void
CPed::SetWeaponLockOnTarget(CEntity *target)
{
if (m_pPointGunAt)
m_pPointGunAt->CleanUpOldReference(&m_pPointGunAt);
m_pPointGunAt = (CPed*)target;
if (target)
((CEntity*)target)->RegisterReference(&m_pPointGunAt);
}
#ifdef COMPATIBLE_SAVES
#define CopyFromBuf(buf, data) memcpy(&data, buf, sizeof(data)); SkipSaveBuf(buf, sizeof(data));
#define CopyToBuf(buf, data) memcpy(buf, &data, sizeof(data)); SkipSaveBuf(buf, sizeof(data));

View File

@ -866,6 +866,7 @@ public:
void PositionAttachedPed();
bool CanUseTorsoWhenLooking();
void ScanForDelayedResponseThreats();
void SetWeaponLockOnTarget(CEntity*);
// Static methods
static CVector GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float offset);
@ -1067,6 +1068,13 @@ public:
else
return (AnimationId)0;
}
static AnimationId GetMeleeStartAnim(CWeaponInfo* weapon) {
if (!!weapon->m_bPartialAttack)
return ANIM_MELEE_ATTACK_START;
else
return (AnimationId)0;
}
// --
// My additions, because there were many, many instances of that.

View File

@ -324,11 +324,7 @@ CPed::SetObjective(eObjective newObj, void *entity)
break;
case OBJECTIVE_DESTROY_OBJECT:
if (m_pPointGunAt)
m_pPointGunAt->CleanUpOldReference(&m_pPointGunAt);
m_pPointGunAt = (CPed*)entity;
if (entity)
((CEntity*)entity)->RegisterReference((CEntity**) &m_pPointGunAt);
SetWeaponLockOnTarget((CEntity*)entity);
break;
case OBJECTIVE_ENTER_CAR_AS_PASSENGER:
case OBJECTIVE_ENTER_CAR_AS_DRIVER:
@ -698,11 +694,7 @@ CPed::UpdateFromLeader(void)
m_pLookTarget->RegisterReference((CEntity **) &m_pLookTarget);
TurnBody();
if (m_attackTimer < CTimer::GetTimeInMilliseconds() && !GetWeapon()->IsTypeMelee()) {
if (m_pPointGunAt)
m_pPointGunAt->CleanUpOldReference(&m_pPointGunAt);
m_pPointGunAt = m_threatEntity;
if (m_threatEntity)
m_threatEntity->RegisterReference((CEntity **) &m_pPointGunAt);
SetWeaponLockOnTarget(m_threatEntity);
SetAttack(m_threatEntity);
}
}
@ -1353,12 +1345,7 @@ CPed::ProcessObjective(void)
CWorld::bIncludeDeadPeds = false;
if (foundEnt == m_carInObjective) {
SetAttack(m_carInObjective);
if (m_pPointGunAt)
m_pPointGunAt->CleanUpOldReference((CEntity**)&m_pPointGunAt);
m_pPointGunAt = m_carInObjective;
if (m_pPointGunAt)
m_pPointGunAt->RegisterReference((CEntity **) &m_pPointGunAt);
SetWeaponLockOnTarget(m_carInObjective);
SetShootTimer(CGeneral::GetRandomNumberInRange(500, 2000));
if (distWithTargetSc > 10.0f && !bKindaStayInSamePlace) {
SetAttackTimer(CGeneral::GetRandomNumberInRange(2000, 5000));
@ -6477,13 +6464,7 @@ CPed::KillCharOnFootArmed(CVector &ourPos, CVector &targetPos, CVector &distWith
if (m_attackTimer < CTimer::GetTimeInMilliseconds() && distWithTargetSc < wepRange && distWithTargetSc > 3.0f) {
SetAttack(vehOfTarget);
if (m_pPointGunAt)
m_pPointGunAt->CleanUpOldReference(&m_pPointGunAt);
m_pPointGunAt = vehOfTarget;
if (vehOfTarget)
vehOfTarget->RegisterReference((CEntity **) &m_pPointGunAt);
SetWeaponLockOnTarget(vehOfTarget);
SetShootTimer(CGeneral::GetRandomNumberInRange(500, 2000));
CVector2D dirVehGoing = vehOfTarget->m_vecMoveSpeed;
@ -6620,13 +6601,7 @@ CPed::KillCharOnFootArmed(CVector &ourPos, CVector &targetPos, CVector &distWith
}
bObstacleShowedUpDuringKillObjective = false;
SetAttack(m_pedInObjective);
if (m_pPointGunAt)
m_pPointGunAt->CleanUpOldReference(&m_pPointGunAt);
m_pPointGunAt = m_pedInObjective;
if (m_pedInObjective)
m_pedInObjective->RegisterReference((CEntity**)&m_pPointGunAt);
SetWeaponLockOnTarget(m_pedInObjective);
SetShootTimer(CGeneral::GetRandomNumberInRange(600.0f, 1500.0f));
int time;
@ -6756,34 +6731,34 @@ CPed::KillCharOnFootMelee(CVector &ourPos, CVector &targetPos, CVector &distWith
// Already calculated at the start
// float distWithTargetSc = distWithTarget.Magnitude();
float wepRange = 0.3f;
float wepRangeAdjusted = wepInfo->m_fRange / 2.f;
float maxDistToKeep = 0.3f;
float wepRange = wepInfo->m_fRange / 2.f;
if (GetWeapon()->m_eWeaponType == WEAPONTYPE_UNARMED && !IsPlayer() && !(m_pedStats->m_flags & STAT_CAN_KICK))
wepRangeAdjusted -= 0.3f;
wepRange -= 0.3f;
if (distWithTargetSc <= 5.f && victimPlayer && !victimPlayer->m_bDrunkVisualsWearOff) {
if (distWithTargetSc <= 5.f && victimPlayer && !victimPlayer->m_bNoPosForMeleeAttack) {
if (m_pedInObjective->EnteringCar() && wepRangeAdjusted > 2.f) {
if (m_pedInObjective->EnteringCar() && wepRange > 2.f) {
m_vecSeekPos = m_pedInObjective->GetPosition();
wepRangeAdjusted = 1.0f;
wepRange = 0.5f;
wepRange = 1.0f;
maxDistToKeep = 0.5f;
} else {
int8 attackDir = victimPlayer->FindMeleeAttackPoint(this, distWithTarget, endOfAttack);
if (attackDir == -1) {
m_vecSeekPos = victimPlayer->GetPosition();
wepRange = 4.0f;
maxDistToKeep = 4.0f;
} else {
victimPlayer->GetMeleeAttackCoords(m_vecSeekPos, attackDir, wepRangeAdjusted);
victimPlayer->GetMeleeAttackCoords(m_vecSeekPos, attackDir, wepRange);
distWithTargetSc = (m_vecSeekPos - GetPosition()).Magnitude();
canReachVictim = true;
}
}
} else {
m_vecSeekPos = m_pedInObjective->GetPosition();
wepRange = Max(0.8f, 0.9f * wepRangeAdjusted);
wepRangeAdjusted = 1.1f * wepRangeAdjusted;
if (victimPlayer && victimPlayer->m_bDrunkVisualsWearOff)
maxDistToKeep = Max(0.8f, 0.9f * wepRange);
wepRange *= 1.1f;
if (victimPlayer && victimPlayer->m_bNoPosForMeleeAttack)
victimPlayer = nil;
}
@ -6851,7 +6826,7 @@ CPed::KillCharOnFootMelee(CVector &ourPos, CVector &targetPos, CVector &distWith
}
}
if (distWithTargetSc > wepRange && !bKindaStayInSamePlace && m_nPedState != PED_ATTACK &&
if (distWithTargetSc > maxDistToKeep && !bKindaStayInSamePlace && m_nPedState != PED_ATTACK &&
(m_nPedState != PED_FIGHT || m_curFightMove == FIGHTMOVE_IDLE) && !killPlayerInNoPoliceZone) {
bool goForward = false;
@ -6859,10 +6834,10 @@ CPed::KillCharOnFootMelee(CVector &ourPos, CVector &targetPos, CVector &distWith
if (m_nPedState == PED_FIGHT) {
if (canReachVictim) {
CVector attackAndVictimDist = m_vecSeekPos - m_pedInObjective->GetPosition();
CVector victimFarness = attackAndVictimDist / wepRangeAdjusted;
CVector victimFarness = attackAndVictimDist / wepRange;
CVector distVec = GetPosition() - m_pedInObjective->GetPosition();
float distSqr = distVec.MagnitudeSqr();
if (sq(wepRangeAdjusted) > distSqr && distSqr > 0.05f) {
if (sq(wepRange) > distSqr && distSqr > 0.05f) {
distVec.Normalise();
if (DotProduct2D(victimFarness, distVec) > Cos(DEGTORAD(30.f)))
goForward = true;
@ -6888,15 +6863,15 @@ CPed::KillCharOnFootMelee(CVector &ourPos, CVector &targetPos, CVector &distWith
SetSeek(m_vecSeekPos, m_distanceToCountSeekDone);
} else {
if (canReachVictim)
SetSeek(m_vecSeekPos, wepRange);
SetSeek(m_vecSeekPos, maxDistToKeep);
else
SetSeek(m_pedInObjective, wepRange);
SetSeek(m_pedInObjective, maxDistToKeep);
}
return ATTACK_IN_PROGRESS;
}
if (m_attackTimer < CTimer::GetTimeInMilliseconds()
&& distWithTargetSc < wepRangeAdjusted && m_pedInObjective->m_nPedState != PED_GETUP && m_pedInObjective->m_nPedState != PED_DRAG_FROM_CAR) {
&& distWithTargetSc < wepRange && m_pedInObjective->m_nPedState != PED_GETUP && m_pedInObjective->m_nPedState != PED_DRAG_FROM_CAR) {
if (bIsDucking) {
CAnimBlendAssociation* duckAnim = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_DUCK_DOWN);

File diff suppressed because it is too large Load Diff

View File

@ -31,12 +31,12 @@ public:
bool m_bAdrenalineActive;
bool m_bHasLockOnTarget;
bool m_bCanBeDamaged;
bool m_bDrunkVisualsWearOff; // TODO(Miami): That may be something else
bool m_bNoPosForMeleeAttack;
bool unk1;
CVector m_vecSafePos[6]; // safe places from the player, for example behind a tree
CPed *m_pPedAtSafePos[6];
CPed *m_pMeleeList[6]; // reachable peds at each direction(6)
char unused1;
int16 m_nCheckPlayersIndex;
int16 m_nAttackDirToCheck;
float m_fWalkAngle; //angle between heading and walking direction
float m_fFPSMoveHeading;
RpAtomic* m_pMinigunTopAtomic; //atomic for the spinning part of the minigun model
@ -45,6 +45,8 @@ public:
unsigned int m_nPadDownPressedInMilliseconds;
unsigned int m_nLastBusFareCollected;
static bool bDontAllowWeaponChange;
CPlayerPed();
~CPlayerPed();
void SetMoveAnim() { };
@ -64,18 +66,18 @@ public:
class CPlayerInfo *GetPlayerInfoForThisPlayerPed();
void SetRealMoveAnim(void);
void RestoreSprintEnergy(float);
bool DoWeaponSmoothSpray(void);
float DoWeaponSmoothSpray(void);
void DoStuffToGoOnFire(void);
bool DoesTargetHaveToBeBroken(CVector, CWeapon*);
void RunningLand(CPad*);
bool IsThisPedAttackingPlayer(CPed*);
bool IsThisPedAnAimingPriority(CPed*);
void PlayerControlSniper(CPad*);
void PlayerControlM16(CPad*);
void PlayerControlFighter(CPad*);
void ProcessWeaponSwitch(CPad*);
void MakeObjectTargettable(int32);
void PlayerControl1stPersonRunAround(CPad *padUsed);
void EvaluateNeighbouringTarget(CEntity*, CEntity**, float*, float, float, bool);
void EvaluateNeighbouringTarget(CEntity*, CEntity**, float*, float, float, bool, bool);
void EvaluateTarget(CEntity*, CEntity**, float*, float, float, bool);
bool FindNextWeaponLockOnTarget(CEntity*, bool);
bool FindWeaponLockOnTarget(void);
@ -87,6 +89,12 @@ public:
void RemovePedFromMeleeList(CPed*);
void GetMeleeAttackCoords(CVector&, int8, float);
int32 FindMeleeAttackPoint(CPed*, CVector&, uint32&);
bool CanIKReachThisTarget(CVector, CWeapon*, bool);
void RotatePlayerToTrackTarget(void);
bool MovementDisabledBecauseOfTargeting(void);
void FindNewAttackPoints(void);
void SetNearbyPedsToInteractWithPlayer(void);
void UpdateMeleeAttackers(void);
static void SetupPlayerPed(int32);
static void DeactivatePlayerPed(int32);

View File

@ -1437,3 +1437,21 @@ CFont::SetDropColor(CRGBA col)
if (Details.alphaFade < 255.0f)
Details.dropColor.a *= Details.alphaFade / 255.0f;
}
void
CFont::FilterOutTokensFromString(wchar *str)
{
int newIdx = 0;
wchar copy[256], *c;
UnicodeStrcpy(copy, str);
for (c = copy; *c != '\0'; c++) {
if (*c == '~') {
c++;
while (*c != '~') c++;
} else {
str[newIdx++] = *c;
}
}
str[newIdx] = '\0';
}

View File

@ -200,6 +200,7 @@ public:
static void SetColor(CRGBA col);
static void SetDropColor(CRGBA col);
static wchar FindNewCharacter(wchar c);
static void FilterOutTokensFromString(wchar*);
#ifdef MORE_LANGUAGES
static void ReloadFonts(uint8 set);

View File

@ -8,7 +8,6 @@
#include "WeaponType.h"
RwTexture *gpCrossHairTex;
RwRaster *gpCrossHairRaster;
CWeaponEffects gCrossHair;
@ -40,7 +39,6 @@ CWeaponEffects::Init(void)
CTxdStore::SetCurrentTxd(slot);
gpCrossHairTex = RwTextureRead("target256", "target256m");
gpCrossHairRaster = RwTextureGetRaster(gpCrossHairTex);
CTxdStore::PopCurrentTxd();
}
@ -99,7 +97,7 @@ CWeaponEffects::Render(void)
#else
RwRenderStateSet(rwRENDERSTATEDESTBLEND, (void *)rwBLENDINVDESTALPHA);
#endif
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void *)gpCrossHairRaster);
RwRenderStateSet(rwRENDERSTATETEXTURERASTER, (void *)RwTextureGetRaster(gpCrossHairTex));
RwV3d pos;
float w, h;