Merge branch 'master' of git://github.com/GTAmodding/re3 into erorcun

This commit is contained in:
eray orçunus 2019-10-04 01:18:47 +03:00
commit 6b4f6e05e2
11 changed files with 1301 additions and 102 deletions

File diff suppressed because it is too large Load Diff

View File

@ -1,62 +1,109 @@
#pragma once
#include "Weapon.h"
enum ePickupType : uint8
{
PICKUP_NONE = 0,
PICKUP_IN_SHOP = 1,
PICKUP_ON_STREET = 2,
PICKUP_ONCE = 3,
PICKUP_ONCE_TIMEOUT = 4,
PICKUP_COLLECTABLE1 = 5,
PICKUP_IN_SHOP_OUT_OF_STOCK = 6,
PICKUP_MONEY = 7,
PICKUP_MINE_INACTIVE = 8,
PICKUP_MINE_ARMED = 9,
PICKUP_NAUTICAL_MINE_INACTIVE = 10,
PICKUP_NAUTICAL_MINE_ARMED = 11,
PICKUP_FLOATINGPACKAGE = 12,
PICKUP_FLOATINGPACKAGE_FLOATING = 13,
PICKUP_ON_STREET_SLOW = 14,
};
class CEntity;
class CObject;
class CPickup
{
#pragma once
#include "Weapon.h"
enum ePickupType : uint8
{
PICKUP_NONE = 0,
PICKUP_IN_SHOP,
PICKUP_ON_STREET,
PICKUP_ONCE,
PICKUP_ONCE_TIMEOUT,
PICKUP_COLLECTABLE1,
PICKUP_IN_SHOP_OUT_OF_STOCK,
PICKUP_MONEY,
PICKUP_MINE_INACTIVE,
PICKUP_MINE_ARMED,
PICKUP_NAUTICAL_MINE_INACTIVE,
PICKUP_NAUTICAL_MINE_ARMED,
PICKUP_FLOATINGPACKAGE,
PICKUP_FLOATINGPACKAGE_FLOATING,
PICKUP_ON_STREET_SLOW,
PICKUP_NUMOFTYPES
};
class CEntity;
class CObject;
class CVehicle;
class CPlayerPed;
class CPickup
{
public:
ePickupType m_eType;
bool m_bRemoved;
uint16 m_wQuantity;
CObject *m_pObject;
uint32 m_nTimer;
int16 m_eModelIndex;
int16 m_wIndex;
CVector m_vecPos;
};
static_assert(sizeof(CPickup) == 0x1C, "CPickup: error");
class CPickups
{
public:
static void RenderPickUpText(void);
static void DoCollectableEffects(CEntity *ent);
static void DoMoneyEffects(CEntity *ent);
static void DoMineEffects(CEntity *ent);
static void DoPickUpEffects(CEntity *ent);
static void RemoveAllFloatingPickups();
static int32 GenerateNewOne(CVector, uint32, uint8, uint32);
static int32 GenerateNewOne_WeaponType(CVector, eWeaponType, uint8, uint32);
static CPickup (&aPickUps)[NUMPICKUPS];
};
extern uint16 AmmoForWeapon[20];
extern uint16 AmmoForWeapon_OnStreet[20];
class CPacManPickups
{
public:
static void Render(void);
};
bool m_bRemoved;
uint16 m_nQuantity;
CObject *m_pObject;
uint32 m_nTimer;
int16 m_eModelIndex;
uint16 m_nIndex;
CVector m_vecPos;
CObject *GiveUsAPickUpObject(int32 handle);
bool Update(CPlayerPed *player, CVehicle *vehicle, int playerId);
private:
bool IsMine() { return m_eType >= PICKUP_MINE_INACTIVE && m_eType <= PICKUP_FLOATINGPACKAGE_FLOATING; }
inline bool CanBePickedUp(CPlayerPed *player);
void RemoveKeepType();
void Remove();
};
static_assert(sizeof(CPickup) == 0x1C, "CPickup: error");
struct tPickupMessage
{
CVector2D m_pos;
eWeaponType m_weaponType;
CVector2D m_dist;
CRGBA m_color;
uint8 m_bOutOfStock : 1;
uint8 m_quantity;
};
class CPickups
{
static int32 aPickUpsCollected[NUMCOLLECTEDPICKUPS];
static int16 CollectedPickUpIndex;
static int16 NumMessages;
static tPickupMessage aMessages[NUMPICKUPMESSAGES];
public:
static void Init();
static void Update();
static void RenderPickUpText();
static void DoCollectableEffects(CEntity *ent);
static void DoMoneyEffects(CEntity *ent);
static void DoMineEffects(CEntity *ent);
static void DoPickUpEffects(CEntity *ent);
static int32 GenerateNewOne(CVector pos, uint32 modelIndex, uint8 type, uint32 quantity);
static int32 GenerateNewOne_WeaponType(CVector pos, eWeaponType weaponType, uint8 type, uint32 quantity);
static void RemovePickUp(int32 pickupIndex);
static void RemoveAllFloatingPickups();
static void AddToCollectedPickupsArray(int32 index);
static bool IsPickUpPickedUp(int32 pickupId);
static int32 ModelForWeapon(eWeaponType weaponType);
static enum eWeaponType WeaponForModel(int32 model);
static int32 FindColourIndexForWeaponMI(int32 model);
static int32 GetActualPickupIndex(int32 index);
static int32 GetNewUniquePickupIndex(int32 slot);
static void PassTime(uint32 time);
static bool GivePlayerGoodiesWithPickUpMI(int16 modelIndex, int playerIndex);
static void Load(uint8 *buffer, uint32 size);
static void Save(uint8 *buffer, uint32 *size);
static CPickup(&aPickUps)[NUMPICKUPS];
// unused
static bool &bPickUpcamActivated;
static CVehicle *&pPlayerVehicle;
static CVector &StaticCamCoors;
static uint32 &StaticCamStartTime;
};
extern uint16 AmmoForWeapon[20];
extern uint16 AmmoForWeapon_OnStreet[20];
extern uint16 CostOfWeapon[20];
class CPacManPickups
{
public:
static void Render(void);
};

View File

@ -13,6 +13,7 @@ CDummyPool *&CPools::ms_pDummyPool = *(CDummyPool**)0x8F2C18;
CAudioScriptObjectPool *&CPools::ms_pAudioScriptObjectPool = *(CAudioScriptObjectPool**)0x8F1B6C;
WRAPPER void CPools::Initialise(void) { EAXJMP(0x4A1770); }
WRAPPER void CPools::MakeSureSlotInObjectPoolIsEmpty(int32 handle) { EAXJMP(0x4A2DB0); }
#if 0
void

View File

@ -49,4 +49,5 @@ public:
static CVehicle *GetVehicle(int32 handle);
static int32 GetObjectRef(CObject *object);
static CObject *GetObject(int32 handle);
static void MakeSureSlotInObjectPoolIsEmpty(int32 handle);
};

View File

@ -67,10 +67,15 @@ enum Config {
NUMANTENNAS = 8,
NUMCORONAS = 56,
NUMPOINTLIGHTS = 32,
NUMMONEYMESSAGES = 16,
NUMPICKUPMESSAGES = 16,
NUMONSCREENTIMERENTRIES = 1,
NUMRADARBLIPS = 32,
NUMPICKUPS = 336,
NUMGENERALPICKUPS = 320,
NUMSCRIPTEDPICKUPS = 16,
NUMPICKUPS = NUMGENERALPICKUPS + NUMSCRIPTEDPICKUPS,
NUMCOLLECTEDPICKUPS = 20,
NUMEVENTS = 64,
NUM_CARGENS = 160,
@ -140,3 +145,4 @@ enum Config {
#define ANIMATE_PED_COL_MODEL
//#define REMOVE_TREADABLE_PATHFIND
#define VC_PED_PORTS
//#define MONEY_MESSAGES

View File

@ -204,6 +204,22 @@ public:
m_matrix.at.y = 0.0f;
m_matrix.at.z = 1.0f;
}
void SetRotateZOnlyScaled(float angle, float scale) {
float c = Cos(angle);
float s = Sin(angle);
m_matrix.right.x = c * scale;
m_matrix.right.y = s * scale;
m_matrix.right.z = 0.0f;
m_matrix.up.x = -s * scale;
m_matrix.up.y = c * scale;
m_matrix.up.z = 0.0f;
m_matrix.at.x = 0.0f;
m_matrix.at.y = 0.0f;
m_matrix.at.z = scale;
}
void SetRotateZ(float angle){
SetRotateZOnly(angle);
m_matrix.pos.x = 0.0f;

View File

@ -14,7 +14,9 @@ int16 &CObject::nNoTempObjects = *(int16*)0x95CCA2;
int16 &CObject::nBodyCastHealth = *(int16*)0x5F7D4C; // 1000
void *CObject::operator new(size_t sz) { return CPools::GetObjectPool()->New(); }
void *CObject::operator new(size_t sz, int handle) { return CPools::GetObjectPool()->New(handle);};
void CObject::operator delete(void *p, size_t sz) { CPools::GetObjectPool()->Delete((CObject*)p); }
void CObject::operator delete(void *p, int handle) { CPools::GetObjectPool()->Delete((CObject*)p); }
CObject::CObject(void)
{
@ -32,7 +34,7 @@ CObject::CObject(void)
field_172 = 0;
bIsPickup = false;
m_obj_flag2 = false;
m_obj_flag4 = false;
bOutOfStock = false;
m_obj_flag8 = false;
m_obj_flag10 = false;
bHasBeenDamaged = false;

View File

@ -34,13 +34,13 @@ public:
int8 ObjectCreatedBy;
int8 bIsPickup : 1;
int8 m_obj_flag2 : 1;
int8 m_obj_flag4 : 1;
int8 bOutOfStock : 1;
int8 m_obj_flag8 : 1;
int8 m_obj_flag10 : 1;
int8 bHasBeenDamaged : 1;
int8 bUseVehicleColours : 1;
int8 m_obj_flag80 : 1;
int8 field_172;
int8 field_172; // car for a bonus pickup?
int8 field_173;
float m_fCollisionDamageMultiplier;
uint8 m_nCollisionDamageEffect;
@ -63,7 +63,9 @@ public:
static int16 &nBodyCastHealth;
static void *operator new(size_t);
static void *operator new(size_t, int);
static void operator delete(void*, size_t);
static void operator delete(void*, int);
CObject(void);
CObject(int32, bool);

View File

@ -336,23 +336,6 @@ void CHud::Draw()
AsciiToUnicode(sTemp, sPrint);
CFont::SetBackgroundOff();
CFont::SetScale(SCREEN_SCALE_X(0.4f), SCREEN_SCALE_Y(0.6f));
CFont::SetJustifyOff();
CFont::SetCentreOn();
CFont::SetCentreSize(SCREEN_SCALE_X(640.0f));
CFont::SetPropOn();
CFont::SetFontStyle(FONT_BANK);
if (!CDarkel::FrenzyOnGoing()) {
if (WeaponType) {
if (WeaponType != WEAPONTYPE_BASEBALLBAT) {
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(66.0f), SCREEN_SCALE_Y(73.0f), sPrint);
}
}
}
/*
DrawWeaponIcon
*/
@ -368,6 +351,19 @@ void CHud::Draw()
1.0f,
1.0f);
CFont::SetBackgroundOff();
CFont::SetScale(SCREEN_SCALE_X(0.4f), SCREEN_SCALE_Y(0.6f));
CFont::SetJustifyOff();
CFont::SetCentreOn();
CFont::SetCentreSize(SCREEN_SCALE_X(640.0f));
CFont::SetPropOn();
CFont::SetFontStyle(FONT_BANK);
if (!CDarkel::FrenzyOnGoing() && WeaponType != WEAPONTYPE_UNARMED && WeaponType != WEAPONTYPE_BASEBALLBAT) {
CFont::SetColor(CRGBA(0, 0, 0, 255));
CFont::PrintString(SCREEN_SCALE_FROM_RIGHT(66.0f), SCREEN_SCALE_Y(73.0f), sPrint);
}
/*
DrawHealth
*/

View File

@ -0,0 +1,86 @@
#include "common.h"
#include "patcher.h"
#include "MoneyMessages.h"
#include "Timer.h"
#include "Sprite.h"
#include "Font.h"
#include "Text.h"
#define MONEY_MESSAGE_LIFETIME_MS 2000
CMoneyMessage CMoneyMessages::aMoneyMessages[NUMMONEYMESSAGES];
void
CMoneyMessage::Render()
{
const float MAX_SCALE = 4.0f;
uint32 nLifeTime = CTimer::GetTimeInMilliseconds() - m_nTimeRegistered;
if (nLifeTime >= MONEY_MESSAGE_LIFETIME_MS) m_nTimeRegistered = 0;
else {
float fLifeTime = (float)nLifeTime / MONEY_MESSAGE_LIFETIME_MS;
RwV3d vecOut;
float fDistX, fDistY;
if (CSprite::CalcScreenCoors(m_vecPosition + CVector(0.0f, 0.0f, fLifeTime), &vecOut, &fDistX, &fDistY, true)) {
fDistX *= (0.7 * fLifeTime + 2.0) * m_fSize;
fDistY *= (0.7 * fLifeTime + 2.0) * m_fSize;
CFont::SetPropOn();
CFont::SetBackgroundOff();
float fScaleY = fDistY / 100.0f;
if (fScaleY > MAX_SCALE) fScaleY = MAX_SCALE;
float fScaleX = fDistX / 100.0f;
if (fScaleX > MAX_SCALE) fScaleX = MAX_SCALE;
CFont::SetScale(fScaleX, fScaleY); // maybe use SCREEN_SCALE_X and SCREEN_SCALE_Y here?
CFont::SetCentreOn();
CFont::SetCentreSize(SCREEN_WIDTH);
CFont::SetJustifyOff();
CFont::SetColor(CRGBA(m_Colour.r, m_Colour.g, m_Colour.b, (255.0f - 255.0f * fLifeTime) * m_fOpacity));
CFont::SetBackGroundOnlyTextOff();
CFont::SetFontStyle(FONT_BANK);
CFont::PrintString(vecOut.x, vecOut.y, m_aText);
}
}
}
void
CMoneyMessages::Init()
{
for (int32 i = 0; i < NUMMONEYMESSAGES; i++)
aMoneyMessages[i].m_nTimeRegistered = 0;
}
void
CMoneyMessages::Render()
{
for (int32 i = 0; i < NUMMONEYMESSAGES; i++) {
if (aMoneyMessages[i].m_nTimeRegistered != 0)
aMoneyMessages[i].Render();
}
}
void
CMoneyMessages::RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8 bGreen, uint8 bBlue, float fSize, float fOpacity)
{
uint32 nIndex = 0;
while (aMoneyMessages[nIndex].m_nTimeRegistered != 0) {
if (++nIndex >= NUMMONEYMESSAGES) return;
}
// Add data of this money message to the array
AsciiToUnicode(pText, aMoneyMessages[nIndex].m_aText);
aMoneyMessages[nIndex].m_nTimeRegistered = CTimer::GetTimeInMilliseconds();
aMoneyMessages[nIndex].m_vecPosition = vecPos;
aMoneyMessages[nIndex].m_Colour.red = bRed;
aMoneyMessages[nIndex].m_Colour.green = bGreen;
aMoneyMessages[nIndex].m_Colour.blue = bBlue;
aMoneyMessages[nIndex].m_fSize = fSize;
aMoneyMessages[nIndex].m_fOpacity = fOpacity;
}
STARTPATCHES
InjectHook(0x51AF70, CMoneyMessages::Init, PATCH_JUMP);
InjectHook(0x51B030, CMoneyMessages::Render, PATCH_JUMP);
ENDPATCHES

View File

@ -0,0 +1,24 @@
#pragma once
class CMoneyMessage
{
friend class CMoneyMessages;
uint32 m_nTimeRegistered;
CVector m_vecPosition;
wchar m_aText[16];
CRGBA m_Colour;
float m_fSize;
float m_fOpacity;
public:
void Render();
};
class CMoneyMessages
{
static CMoneyMessage aMoneyMessages[NUMMONEYMESSAGES];
public:
static void Init();
static void Render();
static void RegisterOne(CVector vecPos, const char *pText, uint8 bRed, uint8 bGreen, uint8 bBlue, float fSize, float fOpacity);
};