mirror of
https://git.rip/DMCA_FUCKER/re3.git
synced 2024-12-22 23:30:01 +00:00
Reorganize CPed functions into their original cpp files
This commit is contained in:
parent
a0a8bb8d92
commit
9e45feb4fa
|
@ -1432,3 +1432,85 @@ CPacManPickups::ResetPowerPillsCarriedByPlayer()
|
|||
FindPlayerVehicle()->m_fForceMultiplier = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CPed::CreateDeadPedMoney(void)
|
||||
{
|
||||
if (!CGame::nastyGame)
|
||||
return;
|
||||
|
||||
int mi = GetModelIndex();
|
||||
|
||||
if ((mi >= MI_COP && mi <= MI_FIREMAN) || CharCreatedBy == MISSION_CHAR || bInVehicle)
|
||||
return;
|
||||
|
||||
int money = CGeneral::GetRandomNumber() % 60;
|
||||
if (money < 10)
|
||||
return;
|
||||
|
||||
if (money == 43)
|
||||
money = 700;
|
||||
|
||||
int pickupCount = money / 40 + 1;
|
||||
int moneyPerPickup = money / pickupCount;
|
||||
|
||||
for(int i = 0; i < pickupCount; i++) {
|
||||
// (CGeneral::GetRandomNumber() % 256) * PI / 128 gives a float up to something TWOPI-ish.
|
||||
float pickupX = 1.5f * Sin((CGeneral::GetRandomNumber() % 256) * PI / 128) + GetPosition().x;
|
||||
float pickupY = 1.5f * Cos((CGeneral::GetRandomNumber() % 256) * PI / 128) + GetPosition().y;
|
||||
bool found = false;
|
||||
float groundZ = CWorld::FindGroundZFor3DCoord(pickupX, pickupY, GetPosition().z, &found) + 0.5f;
|
||||
if (found) {
|
||||
CPickups::GenerateNewOne(CVector(pickupX, pickupY, groundZ), MI_MONEY, PICKUP_MONEY, moneyPerPickup + (CGeneral::GetRandomNumber() & 7));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CPed::CreateDeadPedWeaponPickups(void)
|
||||
{
|
||||
bool found = false;
|
||||
float angleToPed;
|
||||
CVector pickupPos;
|
||||
|
||||
if (bInVehicle)
|
||||
return;
|
||||
|
||||
for(int i = 0; i < WEAPONTYPE_TOTAL_INVENTORY_WEAPONS; i++) {
|
||||
|
||||
eWeaponType weapon = GetWeapon(i).m_eWeaponType;
|
||||
int weaponAmmo = GetWeapon(i).m_nAmmoTotal;
|
||||
if (weapon == WEAPONTYPE_UNARMED || weapon == WEAPONTYPE_DETONATOR || weaponAmmo == 0)
|
||||
continue;
|
||||
|
||||
angleToPed = i * 1.75f;
|
||||
pickupPos = GetPosition();
|
||||
pickupPos.x += 1.5f * Sin(angleToPed);
|
||||
pickupPos.y += 1.5f * Cos(angleToPed);
|
||||
pickupPos.z = CWorld::FindGroundZFor3DCoord(pickupPos.x, pickupPos.y, pickupPos.z, &found) + 0.5f;
|
||||
|
||||
CVector pedPos = GetPosition();
|
||||
pedPos.z += 0.3f;
|
||||
|
||||
CVector pedToPickup = pickupPos - pedPos;
|
||||
float distance = pedToPickup.Magnitude();
|
||||
|
||||
// outer edge of pickup
|
||||
distance = (distance + 0.3f) / distance;
|
||||
CVector pickupPos2 = pedPos;
|
||||
pickupPos2 += distance * pedToPickup;
|
||||
|
||||
// pickup must be on ground and line to its edge must be clear
|
||||
if (!found || CWorld::GetIsLineOfSightClear(pickupPos2, pedPos, true, false, false, false, false, false, false)) {
|
||||
// otherwise try another position (but disregard second check apparently)
|
||||
angleToPed += 3.14f;
|
||||
pickupPos = GetPosition();
|
||||
pickupPos.x += 1.5f * Sin(angleToPed);
|
||||
pickupPos.y += 1.5f * Cos(angleToPed);
|
||||
pickupPos.z = CWorld::FindGroundZFor3DCoord(pickupPos.x, pickupPos.y, pickupPos.z, &found) + 0.5f;
|
||||
}
|
||||
if (found)
|
||||
CPickups::GenerateNewOne_WeaponType(pickupPos, weapon, PICKUP_ONCE_TIMEOUT, Min(weaponAmmo, AmmoForWeapon_OnStreet[weapon]));
|
||||
}
|
||||
ClearWeapons();
|
||||
}
|
|
@ -11,7 +11,6 @@
|
|||
#include "HandlingMgr.h"
|
||||
#include "CarCtrl.h"
|
||||
#include "PedType.h"
|
||||
#include "PedStats.h"
|
||||
#include "AnimManager.h"
|
||||
#include "Game.h"
|
||||
#include "RwHelper.h"
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "ClumpModelInfo.h"
|
||||
#include "PedType.h"
|
||||
#include "PedStats.h"
|
||||
|
||||
enum PedNode {
|
||||
PED_TORSO,
|
||||
|
|
|
@ -424,3 +424,45 @@ CCivilianPed::ProcessControl(void)
|
|||
if (m_moved.Magnitude() > 0.0f)
|
||||
Avoid();
|
||||
}
|
||||
|
||||
// It's "CPhoneInfo::ProcessNearestFreePhone" in PC IDB but that's not true, someone made it up.
|
||||
bool
|
||||
CPed::RunToReportCrime(eCrimeType crimeToReport)
|
||||
{
|
||||
#ifdef PEDS_REPORT_CRIMES_ON_PHONE
|
||||
if (bRunningToPhone) {
|
||||
if (!isPhoneAvailable(m_phoneId)) {
|
||||
m_phoneId = -1;
|
||||
bIsRunning = false;
|
||||
ClearSeek(); // clears bRunningToPhone
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
#else
|
||||
// They changed true into false to make this function unusable. So running to phone actually starts but first frame after that cancels it.
|
||||
if (m_nPedState == PED_SEEK_POS)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
CVector pos = GetPosition();
|
||||
int phoneId = gPhoneInfo.FindNearestFreePhone(&pos);
|
||||
|
||||
if (phoneId == -1)
|
||||
return false;
|
||||
|
||||
CPhone *phone = &gPhoneInfo.m_aPhones[phoneId];
|
||||
#ifndef PEDS_REPORT_CRIMES_ON_PHONE
|
||||
if (phone->m_nState != PHONE_STATE_FREE)
|
||||
return false;
|
||||
#endif
|
||||
|
||||
bRunningToPhone = true;
|
||||
SetSeek(phone->m_pEntity->GetMatrix() * -phone->m_pEntity->GetForward(), 1.0f); // original: phone.m_vecPos, 0.3f
|
||||
SetMoveState(PEDMOVE_RUN);
|
||||
bIsRunning = true; // not there in original
|
||||
m_phoneId = phoneId;
|
||||
m_crimeToReportOnPhone = crimeToReport;
|
||||
return true;
|
||||
}
|
19230
src/peds/Ped.cpp
19230
src/peds/Ped.cpp
File diff suppressed because it is too large
Load diff
|
@ -5,7 +5,7 @@
|
|||
#include "Crime.h"
|
||||
#include "EventList.h"
|
||||
#include "PedIK.h"
|
||||
#include "PedStats.h"
|
||||
#include "PedType.h"
|
||||
#include "Physical.h"
|
||||
#include "Weapon.h"
|
||||
#include "WeaponInfo.h"
|
||||
|
@ -13,6 +13,7 @@
|
|||
#define FEET_OFFSET 1.04f
|
||||
#define CHECK_NEARBY_THINGS_MAX_DIST 15.0f
|
||||
#define ENTER_CAR_MAX_DIST 30.0f
|
||||
#define CAN_SEE_ENTITY_ANGLE_THRESHOLD DEGTORAD(60.0f)
|
||||
|
||||
struct CPathNode;
|
||||
class CAccident;
|
||||
|
@ -568,7 +569,7 @@ public:
|
|||
void CalculateNewOrientation(void);
|
||||
float WorkOutHeadingForMovingFirstPerson(float);
|
||||
void CalculateNewVelocity(void);
|
||||
bool CanSeeEntity(CEntity*, float);
|
||||
bool CanSeeEntity(CEntity*, float threshold = CAN_SEE_ENTITY_ANGLE_THRESHOLD);
|
||||
void RestorePreviousObjective(void);
|
||||
void SetIdle(void);
|
||||
#ifdef _MSC_VER
|
||||
|
@ -747,7 +748,7 @@ public:
|
|||
static void PedSetQuickDraggedOutCarPositionCB(CAnimBlendAssociation *assoc, void *arg);
|
||||
static void PedSetDraggedOutCarPositionCB(CAnimBlendAssociation *assoc, void *arg);
|
||||
|
||||
bool IsPlayer(void);
|
||||
bool IsPlayer(void) const;
|
||||
bool UseGroundColModel(void);
|
||||
bool CanSetPedState(void);
|
||||
bool IsPedInControl(void);
|
||||
|
@ -765,7 +766,7 @@ public:
|
|||
void SetStoredObjective(void);
|
||||
void SetLeader(CEntity* leader);
|
||||
void SetPedStats(ePedStats);
|
||||
bool IsGangMember(void);
|
||||
bool IsGangMember(void) const;
|
||||
void Die(void);
|
||||
void EnterTrain(void);
|
||||
void ExitTrain(void);
|
||||
|
@ -788,7 +789,7 @@ public:
|
|||
CObject *SpawnFlyingComponent(int, int8);
|
||||
void SetCarJack_AllClear(CVehicle*, uint32, uint32);
|
||||
#ifdef VC_PED_PORTS
|
||||
bool CanPedJumpThis(CEntity*, CVector*);
|
||||
bool CanPedJumpThis(CEntity *unused, CVector *damageNormal = nil);
|
||||
#else
|
||||
bool CanPedJumpThis(CEntity*);
|
||||
#endif
|
||||
|
@ -809,9 +810,40 @@ public:
|
|||
bool InVehicle(void) { return bInVehicle && m_pMyVehicle; } // True when ped is sitting/standing in vehicle, not in enter/exit state.
|
||||
bool EnteringCar(void) { return m_nPedState == PED_ENTER_CAR || m_nPedState == PED_CARJACK; }
|
||||
|
||||
void ReplaceWeaponWhenExitingVehicle(void);
|
||||
void RemoveWeaponWhenEnteringVehicle(void);
|
||||
bool IsNotInWreckedVehicle();
|
||||
// It was inlined in III but not in VC.
|
||||
inline void
|
||||
ReplaceWeaponWhenExitingVehicle(void)
|
||||
{
|
||||
eWeaponType weaponType = GetWeapon()->m_eWeaponType;
|
||||
|
||||
// If it's Uzi, we may have stored weapon. Uzi is the only gun we can use in car.
|
||||
if (IsPlayer() && weaponType == WEAPONTYPE_UZI) {
|
||||
if (/*IsPlayer() && */ m_storedWeapon != WEAPONTYPE_UNIDENTIFIED) {
|
||||
SetCurrentWeapon(m_storedWeapon);
|
||||
m_storedWeapon = WEAPONTYPE_UNIDENTIFIED;
|
||||
}
|
||||
} else {
|
||||
AddWeaponModel(CWeaponInfo::GetWeaponInfo(weaponType)->m_nModelId);
|
||||
}
|
||||
}
|
||||
|
||||
// It was inlined in III but not in VC.
|
||||
inline void
|
||||
RemoveWeaponWhenEnteringVehicle(void)
|
||||
{
|
||||
if (IsPlayer() && HasWeapon(WEAPONTYPE_UZI) && GetWeapon(WEAPONTYPE_UZI).m_nAmmoTotal > 0) {
|
||||
if (m_storedWeapon == WEAPONTYPE_UNIDENTIFIED)
|
||||
m_storedWeapon = GetWeapon()->m_eWeaponType;
|
||||
SetCurrentWeapon(WEAPONTYPE_UZI);
|
||||
} else {
|
||||
CWeaponInfo *ourWeapon = CWeaponInfo::GetWeaponInfo(GetWeapon()->m_eWeaponType);
|
||||
RemoveWeaponModel(ourWeapon->m_nModelId);
|
||||
}
|
||||
}
|
||||
bool IsNotInWreckedVehicle()
|
||||
{
|
||||
return m_pMyVehicle != nil && ((CEntity*)m_pMyVehicle)->GetStatus() != STATUS_WRECKED;
|
||||
}
|
||||
// My additions, because there were many, many instances of that.
|
||||
inline void SetFindPathAndFlee(CEntity *fleeFrom, int time, bool walk = false)
|
||||
{
|
||||
|
|
5413
src/peds/PedAI.cpp
Normal file
5413
src/peds/PedAI.cpp
Normal file
File diff suppressed because it is too large
Load diff
3250
src/peds/PedFight.cpp
Normal file
3250
src/peds/PedFight.cpp
Normal file
File diff suppressed because it is too large
Load diff
|
@ -1,118 +0,0 @@
|
|||
#include "common.h"
|
||||
|
||||
#include "General.h"
|
||||
#include "FileMgr.h"
|
||||
#include "PedStats.h"
|
||||
|
||||
CPedStats *CPedStats::ms_apPedStats[NUM_PEDSTATS];
|
||||
|
||||
void
|
||||
CPedStats::Initialise(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
debug("Initialising CPedStats...\n");
|
||||
for(i = 0; i < NUM_PEDSTATS; i++){
|
||||
ms_apPedStats[i] = new CPedStats;
|
||||
ms_apPedStats[i]->m_type = PEDSTAT_PLAYER;
|
||||
ms_apPedStats[i]->m_name[8] = 'R'; // WHAT?
|
||||
ms_apPedStats[i]->m_fleeDistance = 20.0f;
|
||||
ms_apPedStats[i]->m_headingChangeRate = 15.0f;
|
||||
ms_apPedStats[i]->m_fear = 50;
|
||||
ms_apPedStats[i]->m_temper = 50;
|
||||
ms_apPedStats[i]->m_lawfulness = 50;
|
||||
ms_apPedStats[i]->m_sexiness = 50;
|
||||
ms_apPedStats[i]->m_attackStrength = 1.0f;
|
||||
ms_apPedStats[i]->m_defendWeakness = 1.0f;
|
||||
ms_apPedStats[i]->m_flags = 0;
|
||||
}
|
||||
debug("Loading pedstats data...\n");
|
||||
CPedStats::LoadPedStats();
|
||||
debug("CPedStats ready\n");
|
||||
}
|
||||
|
||||
void
|
||||
CPedStats::Shutdown(void)
|
||||
{
|
||||
int i;
|
||||
debug("Shutting down CPedStats...\n");
|
||||
for(i = 0; i < NUM_PEDSTATS; i++)
|
||||
delete ms_apPedStats[i];
|
||||
debug("CPedStats shut down\n");
|
||||
}
|
||||
|
||||
void
|
||||
CPedStats::LoadPedStats(void)
|
||||
{
|
||||
char *buf;
|
||||
char line[256];
|
||||
char name[32];
|
||||
size_t bp, buflen;
|
||||
int lp, linelen;
|
||||
int type;
|
||||
float fleeDist, headingChangeRate, attackStrength, defendWeakness;
|
||||
int fear, temper, lawfullness, sexiness, flags;
|
||||
|
||||
|
||||
type = 0;
|
||||
buf = new char[16 * 1024];
|
||||
|
||||
CFileMgr::SetDir("DATA");
|
||||
buflen = CFileMgr::LoadFile("PEDSTATS.DAT", (uint8*)buf, 16 * 1024, "r");
|
||||
CFileMgr::SetDir("");
|
||||
|
||||
for(bp = 0; bp < buflen; ){
|
||||
// read file line by line
|
||||
for(linelen = 0; buf[bp] != '\n' && bp < buflen; bp++){
|
||||
if(buf[bp] == '\r' || buf[bp] == ',' || buf[bp] == '\t')
|
||||
line[linelen++] = ' ';
|
||||
else
|
||||
line[linelen++] = buf[bp];
|
||||
}
|
||||
bp++;
|
||||
line[linelen] = '\0';
|
||||
|
||||
// skip white space
|
||||
for(lp = 0; line[lp] <= ' '; lp++);
|
||||
|
||||
if(lp >= linelen || // FIX: game uses == here, but this is safer if we have empty lines
|
||||
line[lp] == '#')
|
||||
continue;
|
||||
|
||||
sscanf(&line[lp], "%s %f %f %d %d %d %d %f %f %d",
|
||||
name,
|
||||
&fleeDist,
|
||||
&headingChangeRate,
|
||||
&fear,
|
||||
&temper,
|
||||
&lawfullness,
|
||||
&sexiness,
|
||||
&attackStrength,
|
||||
&defendWeakness,
|
||||
&flags);
|
||||
ms_apPedStats[type]->m_type = (ePedStats)type;
|
||||
strncpy(ms_apPedStats[type]->m_name, name, 24); // FIX: game uses strcpy
|
||||
ms_apPedStats[type]->m_fleeDistance = fleeDist;
|
||||
ms_apPedStats[type]->m_headingChangeRate = headingChangeRate;
|
||||
ms_apPedStats[type]->m_fear = fear;
|
||||
ms_apPedStats[type]->m_temper = temper;
|
||||
ms_apPedStats[type]->m_lawfulness = lawfullness;
|
||||
ms_apPedStats[type]->m_sexiness = sexiness;
|
||||
ms_apPedStats[type]->m_attackStrength = attackStrength;
|
||||
ms_apPedStats[type]->m_defendWeakness = defendWeakness;
|
||||
ms_apPedStats[type]->m_flags = flags;
|
||||
type++;
|
||||
}
|
||||
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
ePedStats
|
||||
CPedStats::GetPedStatType(char *name)
|
||||
{
|
||||
for(uint16 type = 0; type < NUM_PEDSTATS; type++)
|
||||
if(!CGeneral::faststrcmp(ms_apPedStats[type]->m_name, name))
|
||||
return (ePedStats) type;
|
||||
|
||||
return NUM_PEDSTATS;
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
#pragma once
|
||||
|
||||
enum ePedStats
|
||||
{
|
||||
PEDSTAT_PLAYER,
|
||||
PEDSTAT_COP,
|
||||
PEDSTAT_MEDIC,
|
||||
PEDSTAT_FIREMAN,
|
||||
PEDSTAT_GANG1,
|
||||
PEDSTAT_GANG2,
|
||||
PEDSTAT_GANG3,
|
||||
PEDSTAT_GANG4,
|
||||
PEDSTAT_GANG5,
|
||||
PEDSTAT_GANG6,
|
||||
PEDSTAT_GANG7,
|
||||
PEDSTAT_STREET_GUY,
|
||||
PEDSTAT_SUIT_GUY,
|
||||
PEDSTAT_SENSIBLE_GUY,
|
||||
PEDSTAT_GEEK_GUY,
|
||||
PEDSTAT_OLD_GUY,
|
||||
PEDSTAT_TOUGH_GUY,
|
||||
PEDSTAT_STREET_GIRL,
|
||||
PEDSTAT_SUIT_GIRL,
|
||||
PEDSTAT_SENSIBLE_GIRL,
|
||||
PEDSTAT_GEEK_GIRL,
|
||||
PEDSTAT_OLD_GIRL,
|
||||
PEDSTAT_TOUGH_GIRL,
|
||||
PEDSTAT_TRAMP_MALE,
|
||||
PEDSTAT_TRAMP_FEMALE,
|
||||
PEDSTAT_TOURIST,
|
||||
PEDSTAT_PROSTITUTE,
|
||||
PEDSTAT_CRIMINAL,
|
||||
PEDSTAT_BUSKER,
|
||||
PEDSTAT_TAXIDRIVER,
|
||||
PEDSTAT_PSYCHO,
|
||||
PEDSTAT_STEWARD,
|
||||
PEDSTAT_SPORTSFAN,
|
||||
PEDSTAT_SHOPPER,
|
||||
PEDSTAT_OLDSHOPPER,
|
||||
|
||||
NUM_PEDSTATS
|
||||
};
|
||||
|
||||
// flags
|
||||
enum
|
||||
{
|
||||
STAT_PUNCH_ONLY = 1,
|
||||
STAT_CAN_KNEE_HEAD = 2,
|
||||
STAT_CAN_KICK = 4,
|
||||
STAT_CAN_ROUNDHOUSE = 8,
|
||||
STAT_NO_DIVE = 0x10,
|
||||
STAT_ONE_HIT_KNOCKDOWN = 0x20,
|
||||
STAT_SHOPPING_BAGS = 0x40,
|
||||
STAT_GUN_PANIC = 0x80
|
||||
};
|
||||
|
||||
class CPedStats
|
||||
{
|
||||
public:
|
||||
ePedStats m_type;
|
||||
char m_name[24];
|
||||
float m_fleeDistance;
|
||||
float m_headingChangeRate;
|
||||
int8 m_fear;
|
||||
int8 m_temper;
|
||||
int8 m_lawfulness;
|
||||
int8 m_sexiness;
|
||||
float m_attackStrength;
|
||||
float m_defendWeakness;
|
||||
int16 m_flags;
|
||||
|
||||
static CPedStats *ms_apPedStats[NUM_PEDSTATS];
|
||||
|
||||
static void Initialise(void);
|
||||
static void Shutdown(void);
|
||||
static void LoadPedStats(void);
|
||||
static ePedStats GetPedStatType(char *name);
|
||||
};
|
||||
|
||||
VALIDATE_SIZE(CPedStats, 0x34);
|
|
@ -1,9 +1,11 @@
|
|||
#include "common.h"
|
||||
|
||||
#include "General.h"
|
||||
#include "FileMgr.h"
|
||||
#include "PedType.h"
|
||||
|
||||
CPedType *CPedType::ms_apPedType[NUM_PEDTYPES];
|
||||
CPedStats *CPedStats::ms_apPedStats[NUM_PEDSTATS];
|
||||
|
||||
void
|
||||
CPedType::Initialise(void)
|
||||
|
@ -202,3 +204,114 @@ INITSAVEBUF
|
|||
*ms_apPedType[i] = ReadSaveBuf<CPedType>(buf);
|
||||
VALIDATESAVEBUF(size)
|
||||
}
|
||||
|
||||
void
|
||||
CPedStats::Initialise(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
debug("Initialising CPedStats...\n");
|
||||
for(i = 0; i < NUM_PEDSTATS; i++){
|
||||
ms_apPedStats[i] = new CPedStats;
|
||||
ms_apPedStats[i]->m_type = PEDSTAT_PLAYER;
|
||||
ms_apPedStats[i]->m_name[8] = 'R'; // WHAT?
|
||||
ms_apPedStats[i]->m_fleeDistance = 20.0f;
|
||||
ms_apPedStats[i]->m_headingChangeRate = 15.0f;
|
||||
ms_apPedStats[i]->m_fear = 50;
|
||||
ms_apPedStats[i]->m_temper = 50;
|
||||
ms_apPedStats[i]->m_lawfulness = 50;
|
||||
ms_apPedStats[i]->m_sexiness = 50;
|
||||
ms_apPedStats[i]->m_attackStrength = 1.0f;
|
||||
ms_apPedStats[i]->m_defendWeakness = 1.0f;
|
||||
ms_apPedStats[i]->m_flags = 0;
|
||||
}
|
||||
debug("Loading pedstats data...\n");
|
||||
CPedStats::LoadPedStats();
|
||||
debug("CPedStats ready\n");
|
||||
}
|
||||
|
||||
void
|
||||
CPedStats::Shutdown(void)
|
||||
{
|
||||
int i;
|
||||
debug("Shutting down CPedStats...\n");
|
||||
for(i = 0; i < NUM_PEDSTATS; i++)
|
||||
delete ms_apPedStats[i];
|
||||
debug("CPedStats shut down\n");
|
||||
}
|
||||
|
||||
void
|
||||
CPedStats::LoadPedStats(void)
|
||||
{
|
||||
char *buf;
|
||||
char line[256];
|
||||
char name[32];
|
||||
size_t bp, buflen;
|
||||
int lp, linelen;
|
||||
int type;
|
||||
float fleeDist, headingChangeRate, attackStrength, defendWeakness;
|
||||
int fear, temper, lawfullness, sexiness, flags;
|
||||
|
||||
|
||||
type = 0;
|
||||
buf = new char[16 * 1024];
|
||||
|
||||
CFileMgr::SetDir("DATA");
|
||||
buflen = CFileMgr::LoadFile("PEDSTATS.DAT", (uint8*)buf, 16 * 1024, "r");
|
||||
CFileMgr::SetDir("");
|
||||
|
||||
for(bp = 0; bp < buflen; ){
|
||||
// read file line by line
|
||||
for(linelen = 0; buf[bp] != '\n' && bp < buflen; bp++){
|
||||
if(buf[bp] == '\r' || buf[bp] == ',' || buf[bp] == '\t')
|
||||
line[linelen++] = ' ';
|
||||
else
|
||||
line[linelen++] = buf[bp];
|
||||
}
|
||||
bp++;
|
||||
line[linelen] = '\0';
|
||||
|
||||
// skip white space
|
||||
for(lp = 0; line[lp] <= ' '; lp++);
|
||||
|
||||
if(lp >= linelen || // FIX: game uses == here, but this is safer if we have empty lines
|
||||
line[lp] == '#')
|
||||
continue;
|
||||
|
||||
sscanf(&line[lp], "%s %f %f %d %d %d %d %f %f %d",
|
||||
name,
|
||||
&fleeDist,
|
||||
&headingChangeRate,
|
||||
&fear,
|
||||
&temper,
|
||||
&lawfullness,
|
||||
&sexiness,
|
||||
&attackStrength,
|
||||
&defendWeakness,
|
||||
&flags);
|
||||
ms_apPedStats[type]->m_type = (ePedStats)type;
|
||||
strncpy(ms_apPedStats[type]->m_name, name, 24); // FIX: game uses strcpy
|
||||
ms_apPedStats[type]->m_fleeDistance = fleeDist;
|
||||
ms_apPedStats[type]->m_headingChangeRate = headingChangeRate;
|
||||
ms_apPedStats[type]->m_fear = fear;
|
||||
ms_apPedStats[type]->m_temper = temper;
|
||||
ms_apPedStats[type]->m_lawfulness = lawfullness;
|
||||
ms_apPedStats[type]->m_sexiness = sexiness;
|
||||
ms_apPedStats[type]->m_attackStrength = attackStrength;
|
||||
ms_apPedStats[type]->m_defendWeakness = defendWeakness;
|
||||
ms_apPedStats[type]->m_flags = flags;
|
||||
type++;
|
||||
}
|
||||
|
||||
delete[] buf;
|
||||
}
|
||||
|
||||
ePedStats
|
||||
CPedStats::GetPedStatType(char *name)
|
||||
{
|
||||
for(uint16 type = 0; type < NUM_PEDSTATS; type++)
|
||||
if(!CGeneral::faststrcmp(ms_apPedStats[type]->m_name, name))
|
||||
return (ePedStats) type;
|
||||
|
||||
return NUM_PEDSTATS;
|
||||
}
|
||||
|
|
|
@ -92,3 +92,82 @@ public:
|
|||
};
|
||||
|
||||
VALIDATE_SIZE(CPedType, 0x20);
|
||||
|
||||
enum ePedStats
|
||||
{
|
||||
PEDSTAT_PLAYER,
|
||||
PEDSTAT_COP,
|
||||
PEDSTAT_MEDIC,
|
||||
PEDSTAT_FIREMAN,
|
||||
PEDSTAT_GANG1,
|
||||
PEDSTAT_GANG2,
|
||||
PEDSTAT_GANG3,
|
||||
PEDSTAT_GANG4,
|
||||
PEDSTAT_GANG5,
|
||||
PEDSTAT_GANG6,
|
||||
PEDSTAT_GANG7,
|
||||
PEDSTAT_STREET_GUY,
|
||||
PEDSTAT_SUIT_GUY,
|
||||
PEDSTAT_SENSIBLE_GUY,
|
||||
PEDSTAT_GEEK_GUY,
|
||||
PEDSTAT_OLD_GUY,
|
||||
PEDSTAT_TOUGH_GUY,
|
||||
PEDSTAT_STREET_GIRL,
|
||||
PEDSTAT_SUIT_GIRL,
|
||||
PEDSTAT_SENSIBLE_GIRL,
|
||||
PEDSTAT_GEEK_GIRL,
|
||||
PEDSTAT_OLD_GIRL,
|
||||
PEDSTAT_TOUGH_GIRL,
|
||||
PEDSTAT_TRAMP_MALE,
|
||||
PEDSTAT_TRAMP_FEMALE,
|
||||
PEDSTAT_TOURIST,
|
||||
PEDSTAT_PROSTITUTE,
|
||||
PEDSTAT_CRIMINAL,
|
||||
PEDSTAT_BUSKER,
|
||||
PEDSTAT_TAXIDRIVER,
|
||||
PEDSTAT_PSYCHO,
|
||||
PEDSTAT_STEWARD,
|
||||
PEDSTAT_SPORTSFAN,
|
||||
PEDSTAT_SHOPPER,
|
||||
PEDSTAT_OLDSHOPPER,
|
||||
|
||||
NUM_PEDSTATS
|
||||
};
|
||||
|
||||
// flags
|
||||
enum
|
||||
{
|
||||
STAT_PUNCH_ONLY = 1,
|
||||
STAT_CAN_KNEE_HEAD = 2,
|
||||
STAT_CAN_KICK = 4,
|
||||
STAT_CAN_ROUNDHOUSE = 8,
|
||||
STAT_NO_DIVE = 0x10,
|
||||
STAT_ONE_HIT_KNOCKDOWN = 0x20,
|
||||
STAT_SHOPPING_BAGS = 0x40,
|
||||
STAT_GUN_PANIC = 0x80
|
||||
};
|
||||
|
||||
class CPedStats
|
||||
{
|
||||
public:
|
||||
ePedStats m_type;
|
||||
char m_name[24];
|
||||
float m_fleeDistance;
|
||||
float m_headingChangeRate;
|
||||
int8 m_fear;
|
||||
int8 m_temper;
|
||||
int8 m_lawfulness;
|
||||
int8 m_sexiness;
|
||||
float m_attackStrength;
|
||||
float m_defendWeakness;
|
||||
int16 m_flags;
|
||||
|
||||
static CPedStats *ms_apPedStats[NUM_PEDSTATS];
|
||||
|
||||
static void Initialise(void);
|
||||
static void Shutdown(void);
|
||||
static void LoadPedStats(void);
|
||||
static ePedStats GetPedStatType(char *name);
|
||||
};
|
||||
|
||||
VALIDATE_SIZE(CPedStats, 0x34);
|
|
@ -848,6 +848,37 @@ CRenderer::RequestObjectsInFrustum(void)
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
CPed::SetupLighting(void)
|
||||
{
|
||||
ActivateDirectional();
|
||||
SetAmbientColoursForPedsCarsAndObjects();
|
||||
|
||||
#ifndef MASTER
|
||||
// Originally this was being called through iteration of Sectors, but putting it here is better.
|
||||
if (GetDebugDisplay() != 0 && !IsPlayer())
|
||||
DebugRenderOnePedText();
|
||||
#endif
|
||||
|
||||
if (bRenderScorched) {
|
||||
WorldReplaceNormalLightsWithScorched(Scene.world, 0.1f);
|
||||
} else {
|
||||
// Note that this lightMult is only affected by LIGHT_DARKEN. If there's no LIGHT_DARKEN, it will be 1.0.
|
||||
float lightMult = CPointLights::GenerateLightsAffectingObject(&GetPosition());
|
||||
if (!bHasBlip && lightMult != 1.0f) {
|
||||
SetAmbientAndDirectionalColours(lightMult);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
CPed::RemoveLighting(bool reset)
|
||||
{
|
||||
CRenderer::RemoveVehiclePedLights(this, reset);
|
||||
}
|
||||
|
||||
float
|
||||
CalcNewDelta(RwV2d *a, RwV2d *b)
|
||||
{
|
||||
|
|
|
@ -4182,6 +4182,93 @@ CAutomobile::HasCarStoppedBecauseOfLight(void)
|
|||
return false;
|
||||
}
|
||||
|
||||
void
|
||||
CPed::DeadPedMakesTyresBloody(void)
|
||||
{
|
||||
int minX = CWorld::GetSectorIndexX(GetPosition().x - 2.0f);
|
||||
if (minX < 0) minX = 0;
|
||||
int minY = CWorld::GetSectorIndexY(GetPosition().y - 2.0f);
|
||||
if (minY < 0) minY = 0;
|
||||
int maxX = CWorld::GetSectorIndexX(GetPosition().x + 2.0f);
|
||||
if (maxX > NUMSECTORS_X-1) maxX = NUMSECTORS_X-1;
|
||||
int maxY = CWorld::GetSectorIndexY(GetPosition().y + 2.0f);
|
||||
if (maxY > NUMSECTORS_Y-1) maxY = NUMSECTORS_Y-1;
|
||||
|
||||
CWorld::AdvanceCurrentScanCode();
|
||||
|
||||
for (int curY = minY; curY <= maxY; curY++) {
|
||||
for (int curX = minX; curX <= maxX; curX++) {
|
||||
CSector *sector = CWorld::GetSector(curX, curY);
|
||||
MakeTyresMuddySectorList(sector->m_lists[ENTITYLIST_VEHICLES]);
|
||||
MakeTyresMuddySectorList(sector->m_lists[ENTITYLIST_VEHICLES_OVERLAP]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CPed::MakeTyresMuddySectorList(CPtrList &list)
|
||||
{
|
||||
for (CPtrNode *node = list.first; node; node = node->next) {
|
||||
CVehicle *veh = (CVehicle*)node->item;
|
||||
if (veh->IsCar() && veh->m_scanCode != CWorld::GetCurrentScanCode()) {
|
||||
veh->m_scanCode = CWorld::GetCurrentScanCode();
|
||||
|
||||
if (Abs(GetPosition().x - veh->GetPosition().x) < 10.0f) {
|
||||
|
||||
if (Abs(GetPosition().y - veh->GetPosition().y) < 10.0f
|
||||
&& veh->m_vecMoveSpeed.MagnitudeSqr2D() > 0.05f) {
|
||||
|
||||
for(int wheel = 0; wheel < 4; wheel++) {
|
||||
|
||||
if (!((CAutomobile*)veh)->m_aWheelSkidmarkBloody[wheel]
|
||||
&& ((CAutomobile*)veh)->m_aSuspensionSpringRatio[wheel] < 1.0f) {
|
||||
|
||||
CColModel *vehCol = veh->GetModelInfo()->GetColModel();
|
||||
CVector approxWheelOffset;
|
||||
switch (wheel) {
|
||||
case 0:
|
||||
approxWheelOffset = CVector(-vehCol->boundingBox.max.x, vehCol->boundingBox.max.y, 0.0f);
|
||||
break;
|
||||
case 1:
|
||||
approxWheelOffset = CVector(-vehCol->boundingBox.max.x, vehCol->boundingBox.min.y, 0.0f);
|
||||
break;
|
||||
case 2:
|
||||
approxWheelOffset = CVector(vehCol->boundingBox.max.x, vehCol->boundingBox.max.y, 0.0f);
|
||||
break;
|
||||
case 3:
|
||||
approxWheelOffset = CVector(vehCol->boundingBox.max.x, vehCol->boundingBox.min.y, 0.0f);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// I hope so
|
||||
CVector wheelPos = veh->GetMatrix() * approxWheelOffset;
|
||||
if (Abs(wheelPos.z - GetPosition().z) < 2.0f) {
|
||||
|
||||
if ((wheelPos - GetPosition()).MagnitudeSqr2D() < 1.0f) {
|
||||
if (CGame::nastyGame) {
|
||||
((CAutomobile*)veh)->m_aWheelSkidmarkBloody[wheel] = true;
|
||||
DMAudio.PlayOneShot(veh->m_audioEntityId, SOUND_SPLATTER, 0.0f);
|
||||
}
|
||||
veh->ApplyMoveForce(CVector(0.0f, 0.0f, 50.0f));
|
||||
|
||||
CVector vehAndWheelDist = wheelPos - veh->GetPosition();
|
||||
veh->ApplyTurnForce(CVector(0.0f, 0.0f, 50.0f), vehAndWheelDist);
|
||||
|
||||
if (veh == FindPlayerVehicle()) {
|
||||
CPad::GetPad(0)->StartShake(300, 70);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
CAutomobile::SetBusDoorTimer(uint32 timer, uint8 type)
|
||||
{
|
||||
|
|
|
@ -2287,6 +2287,16 @@ CWeapon::HasWeaponAmmoToBeUsed(void)
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
CPed::IsPedDoingDriveByShooting(void)
|
||||
{
|
||||
if (FindPlayerPed() == this && GetWeapon()->m_eWeaponType == WEAPONTYPE_UZI) {
|
||||
if (TheCamera.Cams[TheCamera.ActiveCam].LookingLeft || TheCamera.Cams[TheCamera.ActiveCam].LookingRight)
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool
|
||||
CWeapon::ProcessLineOfSight(CVector const &point1, CVector const &point2, CColPoint &point, CEntity *&entity, eWeaponType type, CEntity *shooter, bool checkBuildings, bool checkVehicles, bool checkPeds, bool checkObjects, bool checkDummies, bool ignoreSeeThrough, bool ignoreSomeObjects)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue