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->m_nRoadblockVeh->RegisterReference((CEntity**)&pCopPed->m_nRoadblockVeh);
pCopPed->bCrouchWhenShooting = roadBlockType == 2 ? false : true; pCopPed->bCrouchWhenShooting = roadBlockType == 2 ? false : true;
if (pEntityToAttack) { if (pEntityToAttack) {
if (pCopPed->m_pPointGunAt) pCopPed->SetWeaponLockOnTarget(pEntityToAttack);
pCopPed->m_pPointGunAt->CleanUpOldReference(&pCopPed->m_pPointGunAt);
pCopPed->m_pPointGunAt = pEntityToAttack;
if (pEntityToAttack)
pEntityToAttack->RegisterReference(&pCopPed->m_pPointGunAt);
pCopPed->SetAttack(pEntityToAttack); pCopPed->SetAttack(pEntityToAttack);
} }
pCopPed->m_pMyVehicle = pVehicle; pCopPed->m_pMyVehicle = pVehicle;

View File

@ -1011,14 +1011,15 @@ CCamera::CamControl(void)
if((m_bLookingAtPlayer || m_bEnable1rstPersonCamCntrlsScript) && pTargetEntity->IsPed() && if((m_bLookingAtPlayer || m_bEnable1rstPersonCamCntrlsScript) && pTargetEntity->IsPed() &&
(!m_WideScreenOn || m_bEnable1rstPersonCamCntrlsScript) && !Cams[0].Using3rdPersonMouseCam() (!m_WideScreenOn || m_bEnable1rstPersonCamCntrlsScript) && !Cams[0].Using3rdPersonMouseCam()
#ifdef FREE_CAM #ifdef FREE_CAM
&& !CCamera::bFreeCam && (!CCamera::bFreeCam || m_bEnable1rstPersonCamCntrlsScript)
#endif #endif
){ ){
// See if we want to enter first person mode // See if we want to enter first person mode
if(CPad::GetPad(0)->LookAroundLeftRight() || CPad::GetPad(0)->LookAroundUpDown()){ if(CPad::GetPad(0)->LookAroundLeftRight() || CPad::GetPad(0)->LookAroundUpDown()){
m_uiFirstPersonCamLastInputTime = CTimer::GetTimeInMilliseconds(); m_uiFirstPersonCamLastInputTime = CTimer::GetTimeInMilliseconds();
m_bFirstPersonBeingUsed = true; m_bFirstPersonBeingUsed = true;
}else if(m_bFirstPersonBeingUsed){ }
if(m_bFirstPersonBeingUsed){
// Or if we want to go back to 3rd person // Or if we want to go back to 3rd person
if(CPad::GetPad(0)->GetPedWalkLeftRight() || CPad::GetPad(0)->GetPedWalkUpDown() || if(CPad::GetPad(0)->GetPedWalkLeftRight() || CPad::GetPad(0)->GetPedWalkUpDown() ||
CPad::GetPad(0)->GetSquare() || CPad::GetPad(0)->GetTriangle() || CPad::GetPad(0)->GetSquare() || CPad::GetPad(0)->GetTriangle() ||
@ -1701,7 +1702,7 @@ CCamera::CamControl(void)
StartTransitionWhenNotFinishedInter(ReqMode); StartTransitionWhenNotFinishedInter(ReqMode);
pTargetEntity->RegisterReference(&pTargetEntity); pTargetEntity->RegisterReference(&pTargetEntity);
Cams[ActiveCam].CamTargetEntity->RegisterReference(&Cams[ActiveCam].CamTargetEntity); 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_uiTransitionState = 0;
m_vecDoingSpecialInterPolation = false; m_vecDoingSpecialInterPolation = false;
if(m_bEnable1rstPersonCamCntrlsScript && ReqMode == CCam::MODE_1STPERSON) 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_CLASSIC_ROW_HEIGHT 9.0f
#define CONTSETUP_BOUND_HIGHLIGHT_HEIGHT 10 #define CONTSETUP_BOUND_HIGHLIGHT_HEIGHT 10
#define CONTSETUP_BOUND_COLUMN_WIDTH 190.0f #define CONTSETUP_BOUND_COLUMN_WIDTH 190.0f
#define CONTSETUP_LIST_HEADER_HEIGHT 20.0f #define CONTSETUP_LIST_TOP 58.0f
#define CONTSETUP_LIST_TOP 28.0f
#define CONTSETUP_LIST_RIGHT 18.0f #define CONTSETUP_LIST_RIGHT 18.0f
#define CONTSETUP_LIST_BOTTOM 120.0f #define CONTSETUP_LIST_BOTTOM 78.0f
#define CONTSETUP_LIST_LEFT 18.0f #define CONTSETUP_LIST_LEFT 30.0f
#define CONTSETUP_COLUMN_1_X 40.0f #define CONTSETUP_COLUMN_1_X 40.0f
#define CONTSETUP_COLUMN_2_X 210.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_COLUMN_3_X (CONTSETUP_COLUMN_2_X + CONTSETUP_BOUND_COLUMN_WIDTH + 10.0f)
#define CONTSETUP_BACK_RIGHT 35.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 #define CONTSETUP_BACK_HEIGHT 25.0f
enum enum
@ -310,21 +309,6 @@ enum eCheckHover
HOVEROPTION_USESKIN, // also layer in controller setup and skin menu HOVEROPTION_USESKIN, // also layer in controller setup and skin menu
HOVEROPTION_NEXT_RADIO, HOVEROPTION_NEXT_RADIO,
HOVEROPTION_PREV_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_INCREASE_BRIGHTNESS,
HOVEROPTION_DECREASE_BRIGHTNESS, HOVEROPTION_DECREASE_BRIGHTNESS,
HOVEROPTION_INCREASE_DRAWDIST, HOVEROPTION_INCREASE_DRAWDIST,
@ -359,7 +343,7 @@ enum eControlMethod
enum ControllerSetupColumn enum ControllerSetupColumn
{ {
CONTSETUP_PED_COLUMN = 0, CONTSETUP_PED_COLUMN = 0,
CONTSETUP_VEHICLE_COLUMN = 14, CONTSETUP_VEHICLE_COLUMN = 16,
}; };
struct tSkinInfo struct tSkinInfo
@ -485,7 +469,7 @@ public:
int8 m_PrefsShowSubtitles; int8 m_PrefsShowSubtitles;
int8 m_PrefsShowLegends; int8 m_PrefsShowLegends;
int8 m_PrefsUseWideScreen; int8 m_PrefsUseWideScreen;
int8 m_PrefsVsync; // TODO(Miami): Are we sure? int8 m_PrefsVsync;
int8 m_PrefsVsyncDisp; int8 m_PrefsVsyncDisp;
int8 m_PrefsFrameLimiter; int8 m_PrefsFrameLimiter;
int8 m_nPrefsAudio3DProviderIndex; int8 m_nPrefsAudio3DProviderIndex;
@ -526,7 +510,7 @@ public:
uint8 field_74[4]; uint8 field_74[4];
int32 *pControlEdit; int32 *pControlEdit;
bool m_OnlySaveMenu; bool m_OnlySaveMenu;
int32 m_menuTransitionProgress; int32 m_firstStartCounter;
CSprite2d m_aFrontEndSprites[NUM_MENU_SPRITES]; CSprite2d m_aFrontEndSprites[NUM_MENU_SPRITES];
bool m_bSpritesLoaded; bool m_bSpritesLoaded;
int32 m_LeftMostRadioX; int32 m_LeftMostRadioX;
@ -662,7 +646,6 @@ public:
void Initialise(); void Initialise();
void PrintMap(); void PrintMap();
void SetFrontEndRenderStates(); void SetFrontEndRenderStates();
static void BuildStatLine(Const char *text, void *stat, bool itsFloat, void *stat2);
static void CentreMousePointer(); static void CentreMousePointer();
void CheckCodesForControls(int); void CheckCodesForControls(int);
bool CheckHover(int x1, int x2, int y1, int y2); bool CheckHover(int x1, int x2, int y1, int y2);
@ -679,7 +662,6 @@ public:
void DrawBackground(bool transitionCall); void DrawBackground(bool transitionCall);
void DrawPlayerSetupScreen(bool); void DrawPlayerSetupScreen(bool);
int FadeIn(int alpha); int FadeIn(int alpha);
void FilterOutColorMarkersFromString(wchar*);
int GetStartOptionsCntrlConfigScreens(); int GetStartOptionsCntrlConfigScreens();
void InitialiseChangedLanguageSettings(); void InitialiseChangedLanguageSettings();
void LoadAllTextures(); void LoadAllTextures();
@ -707,7 +689,6 @@ public:
void UnloadTextures(); void UnloadTextures();
void WaitForUserCD(); void WaitForUserCD();
int GetNumOptionsCntrlConfigScreens(); int GetNumOptionsCntrlConfigScreens();
int ConstructStatLine(int);
void SwitchToNewScreen(int8); void SwitchToNewScreen(int8);
void AdditionalOptionInput(bool &goBack); void AdditionalOptionInput(bool &goBack);
void ExportStats(void); void ExportStats(void);

View File

@ -5,6 +5,9 @@
#include "World.h" #include "World.h"
#include "Pad.h" #include "Pad.h"
#include "DMAudio.h" #include "DMAudio.h"
#include "main.h"
#include "Font.h"
#include "Frontend.h"
#include <climits> #include <climits>
@ -774,3 +777,254 @@ CStats::PopulateFavoriteRadioStationList()
for (int i = 0; i < NUM_RADIOS; i++) for (int i = 0; i < NUM_RADIOS; i++)
FavoriteRadioStationList[i] = pListenTimeArray[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 AddPropertyAsOwned(int32);
static void PopulateFavoriteRadioStationList(); static void PopulateFavoriteRadioStationList();
static float GetFavoriteRadioStationList(int32); 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_61C = 0;
field_624 = 0; field_624 = 0;
m_pStinger = new CStinger; m_pStinger = new CStinger;
if (m_pPointGunAt) SetWeaponLockOnTarget(nil);
m_pPointGunAt->CleanUpOldReference(&m_pPointGunAt);
m_pPointGunAt = nil;
} }
CCopPed::~CCopPed() CCopPed::~CCopPed()
@ -493,12 +491,7 @@ CCopPed::CopAI(void)
false, true, false, false, true, false, false) false, true, false, false, true, false, false)
|| foundEnt && foundEnt == playerOrHisVeh) { || foundEnt && foundEnt == playerOrHisVeh) {
if (m_pPointGunAt) SetWeaponLockOnTarget(playerOrHisVeh);
m_pPointGunAt->CleanUpOldReference((CEntity**) &m_pPointGunAt);
m_pPointGunAt = playerOrHisVeh;
if (playerOrHisVeh)
playerOrHisVeh->RegisterReference((CEntity**) &m_pPointGunAt);
SetAttack(playerOrHisVeh); SetAttack(playerOrHisVeh);
SetShootTimer(CGeneral::GetRandomNumberInRange(500, 1000)); 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 #ifdef COMPATIBLE_SAVES
#define CopyFromBuf(buf, data) memcpy(&data, buf, sizeof(data)); SkipSaveBuf(buf, sizeof(data)); #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)); #define CopyToBuf(buf, data) memcpy(buf, &data, sizeof(data)); SkipSaveBuf(buf, sizeof(data));

View File

@ -866,6 +866,7 @@ public:
void PositionAttachedPed(); void PositionAttachedPed();
bool CanUseTorsoWhenLooking(); bool CanUseTorsoWhenLooking();
void ScanForDelayedResponseThreats(); void ScanForDelayedResponseThreats();
void SetWeaponLockOnTarget(CEntity*);
// Static methods // Static methods
static CVector GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float offset); static CVector GetLocalPositionToOpenCarDoor(CVehicle *veh, uint32 component, float offset);
@ -1067,6 +1068,13 @@ public:
else else
return (AnimationId)0; 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. // My additions, because there were many, many instances of that.

View File

@ -324,11 +324,7 @@ CPed::SetObjective(eObjective newObj, void *entity)
break; break;
case OBJECTIVE_DESTROY_OBJECT: case OBJECTIVE_DESTROY_OBJECT:
if (m_pPointGunAt) SetWeaponLockOnTarget((CEntity*)entity);
m_pPointGunAt->CleanUpOldReference(&m_pPointGunAt);
m_pPointGunAt = (CPed*)entity;
if (entity)
((CEntity*)entity)->RegisterReference((CEntity**) &m_pPointGunAt);
break; break;
case OBJECTIVE_ENTER_CAR_AS_PASSENGER: case OBJECTIVE_ENTER_CAR_AS_PASSENGER:
case OBJECTIVE_ENTER_CAR_AS_DRIVER: case OBJECTIVE_ENTER_CAR_AS_DRIVER:
@ -698,11 +694,7 @@ CPed::UpdateFromLeader(void)
m_pLookTarget->RegisterReference((CEntity **) &m_pLookTarget); m_pLookTarget->RegisterReference((CEntity **) &m_pLookTarget);
TurnBody(); TurnBody();
if (m_attackTimer < CTimer::GetTimeInMilliseconds() && !GetWeapon()->IsTypeMelee()) { if (m_attackTimer < CTimer::GetTimeInMilliseconds() && !GetWeapon()->IsTypeMelee()) {
if (m_pPointGunAt) SetWeaponLockOnTarget(m_threatEntity);
m_pPointGunAt->CleanUpOldReference(&m_pPointGunAt);
m_pPointGunAt = m_threatEntity;
if (m_threatEntity)
m_threatEntity->RegisterReference((CEntity **) &m_pPointGunAt);
SetAttack(m_threatEntity); SetAttack(m_threatEntity);
} }
} }
@ -1353,12 +1345,7 @@ CPed::ProcessObjective(void)
CWorld::bIncludeDeadPeds = false; CWorld::bIncludeDeadPeds = false;
if (foundEnt == m_carInObjective) { if (foundEnt == m_carInObjective) {
SetAttack(m_carInObjective); SetAttack(m_carInObjective);
if (m_pPointGunAt) SetWeaponLockOnTarget(m_carInObjective);
m_pPointGunAt->CleanUpOldReference((CEntity**)&m_pPointGunAt);
m_pPointGunAt = m_carInObjective;
if (m_pPointGunAt)
m_pPointGunAt->RegisterReference((CEntity **) &m_pPointGunAt);
SetShootTimer(CGeneral::GetRandomNumberInRange(500, 2000)); SetShootTimer(CGeneral::GetRandomNumberInRange(500, 2000));
if (distWithTargetSc > 10.0f && !bKindaStayInSamePlace) { if (distWithTargetSc > 10.0f && !bKindaStayInSamePlace) {
SetAttackTimer(CGeneral::GetRandomNumberInRange(2000, 5000)); 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) { if (m_attackTimer < CTimer::GetTimeInMilliseconds() && distWithTargetSc < wepRange && distWithTargetSc > 3.0f) {
SetAttack(vehOfTarget); SetAttack(vehOfTarget);
if (m_pPointGunAt) SetWeaponLockOnTarget(vehOfTarget);
m_pPointGunAt->CleanUpOldReference(&m_pPointGunAt);
m_pPointGunAt = vehOfTarget;
if (vehOfTarget)
vehOfTarget->RegisterReference((CEntity **) &m_pPointGunAt);
SetShootTimer(CGeneral::GetRandomNumberInRange(500, 2000)); SetShootTimer(CGeneral::GetRandomNumberInRange(500, 2000));
CVector2D dirVehGoing = vehOfTarget->m_vecMoveSpeed; CVector2D dirVehGoing = vehOfTarget->m_vecMoveSpeed;
@ -6620,13 +6601,7 @@ CPed::KillCharOnFootArmed(CVector &ourPos, CVector &targetPos, CVector &distWith
} }
bObstacleShowedUpDuringKillObjective = false; bObstacleShowedUpDuringKillObjective = false;
SetAttack(m_pedInObjective); SetAttack(m_pedInObjective);
if (m_pPointGunAt) SetWeaponLockOnTarget(m_pedInObjective);
m_pPointGunAt->CleanUpOldReference(&m_pPointGunAt);
m_pPointGunAt = m_pedInObjective;
if (m_pedInObjective)
m_pedInObjective->RegisterReference((CEntity**)&m_pPointGunAt);
SetShootTimer(CGeneral::GetRandomNumberInRange(600.0f, 1500.0f)); SetShootTimer(CGeneral::GetRandomNumberInRange(600.0f, 1500.0f));
int time; int time;
@ -6756,34 +6731,34 @@ CPed::KillCharOnFootMelee(CVector &ourPos, CVector &targetPos, CVector &distWith
// Already calculated at the start // Already calculated at the start
// float distWithTargetSc = distWithTarget.Magnitude(); // float distWithTargetSc = distWithTarget.Magnitude();
float wepRange = 0.3f; float maxDistToKeep = 0.3f;
float wepRangeAdjusted = wepInfo->m_fRange / 2.f; float wepRange = wepInfo->m_fRange / 2.f;
if (GetWeapon()->m_eWeaponType == WEAPONTYPE_UNARMED && !IsPlayer() && !(m_pedStats->m_flags & STAT_CAN_KICK)) 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(); m_vecSeekPos = m_pedInObjective->GetPosition();
wepRangeAdjusted = 1.0f; wepRange = 1.0f;
wepRange = 0.5f; maxDistToKeep = 0.5f;
} else { } else {
int8 attackDir = victimPlayer->FindMeleeAttackPoint(this, distWithTarget, endOfAttack); int8 attackDir = victimPlayer->FindMeleeAttackPoint(this, distWithTarget, endOfAttack);
if (attackDir == -1) { if (attackDir == -1) {
m_vecSeekPos = victimPlayer->GetPosition(); m_vecSeekPos = victimPlayer->GetPosition();
wepRange = 4.0f; maxDistToKeep = 4.0f;
} else { } else {
victimPlayer->GetMeleeAttackCoords(m_vecSeekPos, attackDir, wepRangeAdjusted); victimPlayer->GetMeleeAttackCoords(m_vecSeekPos, attackDir, wepRange);
distWithTargetSc = (m_vecSeekPos - GetPosition()).Magnitude(); distWithTargetSc = (m_vecSeekPos - GetPosition()).Magnitude();
canReachVictim = true; canReachVictim = true;
} }
} }
} else { } else {
m_vecSeekPos = m_pedInObjective->GetPosition(); m_vecSeekPos = m_pedInObjective->GetPosition();
wepRange = Max(0.8f, 0.9f * wepRangeAdjusted); maxDistToKeep = Max(0.8f, 0.9f * wepRange);
wepRangeAdjusted = 1.1f * wepRangeAdjusted; wepRange *= 1.1f;
if (victimPlayer && victimPlayer->m_bDrunkVisualsWearOff) if (victimPlayer && victimPlayer->m_bNoPosForMeleeAttack)
victimPlayer = nil; 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) { (m_nPedState != PED_FIGHT || m_curFightMove == FIGHTMOVE_IDLE) && !killPlayerInNoPoliceZone) {
bool goForward = false; bool goForward = false;
@ -6859,10 +6834,10 @@ CPed::KillCharOnFootMelee(CVector &ourPos, CVector &targetPos, CVector &distWith
if (m_nPedState == PED_FIGHT) { if (m_nPedState == PED_FIGHT) {
if (canReachVictim) { if (canReachVictim) {
CVector attackAndVictimDist = m_vecSeekPos - m_pedInObjective->GetPosition(); CVector attackAndVictimDist = m_vecSeekPos - m_pedInObjective->GetPosition();
CVector victimFarness = attackAndVictimDist / wepRangeAdjusted; CVector victimFarness = attackAndVictimDist / wepRange;
CVector distVec = GetPosition() - m_pedInObjective->GetPosition(); CVector distVec = GetPosition() - m_pedInObjective->GetPosition();
float distSqr = distVec.MagnitudeSqr(); float distSqr = distVec.MagnitudeSqr();
if (sq(wepRangeAdjusted) > distSqr && distSqr > 0.05f) { if (sq(wepRange) > distSqr && distSqr > 0.05f) {
distVec.Normalise(); distVec.Normalise();
if (DotProduct2D(victimFarness, distVec) > Cos(DEGTORAD(30.f))) if (DotProduct2D(victimFarness, distVec) > Cos(DEGTORAD(30.f)))
goForward = true; goForward = true;
@ -6888,15 +6863,15 @@ CPed::KillCharOnFootMelee(CVector &ourPos, CVector &targetPos, CVector &distWith
SetSeek(m_vecSeekPos, m_distanceToCountSeekDone); SetSeek(m_vecSeekPos, m_distanceToCountSeekDone);
} else { } else {
if (canReachVictim) if (canReachVictim)
SetSeek(m_vecSeekPos, wepRange); SetSeek(m_vecSeekPos, maxDistToKeep);
else else
SetSeek(m_pedInObjective, wepRange); SetSeek(m_pedInObjective, maxDistToKeep);
} }
return ATTACK_IN_PROGRESS; return ATTACK_IN_PROGRESS;
} }
if (m_attackTimer < CTimer::GetTimeInMilliseconds() 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) { if (bIsDucking) {
CAnimBlendAssociation* duckAnim = RpAnimBlendClumpGetAssociation(GetClump(), ANIM_DUCK_DOWN); 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_bAdrenalineActive;
bool m_bHasLockOnTarget; bool m_bHasLockOnTarget;
bool m_bCanBeDamaged; 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 CVector m_vecSafePos[6]; // safe places from the player, for example behind a tree
CPed *m_pPedAtSafePos[6]; CPed *m_pPedAtSafePos[6];
CPed *m_pMeleeList[6]; // reachable peds at each direction(6) CPed *m_pMeleeList[6]; // reachable peds at each direction(6)
char unused1; int16 m_nAttackDirToCheck;
int16 m_nCheckPlayersIndex;
float m_fWalkAngle; //angle between heading and walking direction float m_fWalkAngle; //angle between heading and walking direction
float m_fFPSMoveHeading; float m_fFPSMoveHeading;
RpAtomic* m_pMinigunTopAtomic; //atomic for the spinning part of the minigun model RpAtomic* m_pMinigunTopAtomic; //atomic for the spinning part of the minigun model
@ -45,6 +45,8 @@ public:
unsigned int m_nPadDownPressedInMilliseconds; unsigned int m_nPadDownPressedInMilliseconds;
unsigned int m_nLastBusFareCollected; unsigned int m_nLastBusFareCollected;
static bool bDontAllowWeaponChange;
CPlayerPed(); CPlayerPed();
~CPlayerPed(); ~CPlayerPed();
void SetMoveAnim() { }; void SetMoveAnim() { };
@ -64,18 +66,18 @@ public:
class CPlayerInfo *GetPlayerInfoForThisPlayerPed(); class CPlayerInfo *GetPlayerInfoForThisPlayerPed();
void SetRealMoveAnim(void); void SetRealMoveAnim(void);
void RestoreSprintEnergy(float); void RestoreSprintEnergy(float);
bool DoWeaponSmoothSpray(void); float DoWeaponSmoothSpray(void);
void DoStuffToGoOnFire(void); void DoStuffToGoOnFire(void);
bool DoesTargetHaveToBeBroken(CVector, CWeapon*); bool DoesTargetHaveToBeBroken(CVector, CWeapon*);
void RunningLand(CPad*); void RunningLand(CPad*);
bool IsThisPedAttackingPlayer(CPed*); bool IsThisPedAnAimingPriority(CPed*);
void PlayerControlSniper(CPad*); void PlayerControlSniper(CPad*);
void PlayerControlM16(CPad*); void PlayerControlM16(CPad*);
void PlayerControlFighter(CPad*); void PlayerControlFighter(CPad*);
void ProcessWeaponSwitch(CPad*); void ProcessWeaponSwitch(CPad*);
void MakeObjectTargettable(int32); void MakeObjectTargettable(int32);
void PlayerControl1stPersonRunAround(CPad *padUsed); 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); void EvaluateTarget(CEntity*, CEntity**, float*, float, float, bool);
bool FindNextWeaponLockOnTarget(CEntity*, bool); bool FindNextWeaponLockOnTarget(CEntity*, bool);
bool FindWeaponLockOnTarget(void); bool FindWeaponLockOnTarget(void);
@ -87,6 +89,12 @@ public:
void RemovePedFromMeleeList(CPed*); void RemovePedFromMeleeList(CPed*);
void GetMeleeAttackCoords(CVector&, int8, float); void GetMeleeAttackCoords(CVector&, int8, float);
int32 FindMeleeAttackPoint(CPed*, CVector&, uint32&); 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 SetupPlayerPed(int32);
static void DeactivatePlayerPed(int32); static void DeactivatePlayerPed(int32);

View File

@ -1437,3 +1437,21 @@ CFont::SetDropColor(CRGBA col)
if (Details.alphaFade < 255.0f) if (Details.alphaFade < 255.0f)
Details.dropColor.a *= 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 SetColor(CRGBA col);
static void SetDropColor(CRGBA col); static void SetDropColor(CRGBA col);
static wchar FindNewCharacter(wchar c); static wchar FindNewCharacter(wchar c);
static void FilterOutTokensFromString(wchar*);
#ifdef MORE_LANGUAGES #ifdef MORE_LANGUAGES
static void ReloadFonts(uint8 set); static void ReloadFonts(uint8 set);

View File

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