1
0
Fork 0
mirror of https://git.rip/DMCA_FUCKER/re3.git synced 2024-12-23 11:29:59 +00:00

more script stuff

This commit is contained in:
Nikolay Korolev 2020-05-16 23:06:33 +03:00
parent e3291b0cb1
commit b587d835e8
11 changed files with 84 additions and 16 deletions

View file

@ -129,12 +129,12 @@ CPickup::GiveUsAPickUpObject(int32 handle)
}
bool
CPickup::CanBePickedUp(CPlayerPed *player)
CPickup::CanBePickedUp(CPlayerPed *player, int playerId)
{
assert(m_pObject != nil);
bool cannotBePickedUp =
(m_pObject->GetModelIndex() == MI_PICKUP_BODYARMOUR && player->m_fArmour > 99.5f)
|| (m_pObject->GetModelIndex() == MI_PICKUP_HEALTH && player->m_fHealth > 99.5f)
(m_pObject->GetModelIndex() == MI_PICKUP_BODYARMOUR && player->m_fArmour > CWorld::Players[playerId].m_nMaxArmour - 0.5f)
|| (m_pObject->GetModelIndex() == MI_PICKUP_HEALTH && player->m_fHealth > CWorld::Players[playerId].m_nMaxHealth - 0.5f)
|| (m_pObject->GetModelIndex() == MI_PICKUP_BRIBE && player->m_pWanted->m_nWantedLevel == 0)
|| (m_pObject->GetModelIndex() == MI_PICKUP_KILLFRENZY && (CTheScripts::IsPlayerOnAMission() || CDarkel::FrenzyOnGoing() || !CGame::nastyGame));
return !cannotBePickedUp;
@ -190,7 +190,7 @@ CPickup::Update(CPlayerPed *player, CVehicle *vehicle, int playerId)
}
// if we didn't then we've got nothing to do
if (isPickupTouched && CanBePickedUp(player)) {
if (isPickupTouched && CanBePickedUp(player, playerId)) {
CPad::GetPad(0)->StartShake(120, 100);
switch (m_eType)
{
@ -430,14 +430,14 @@ CPickups::GivePlayerGoodiesWithPickUpMI(int16 modelIndex, int playerIndex)
DMAudio.PlayFrontEndSound(SOUND_PICKUP_ADRENALINE, 0);
return true;
} else if (modelIndex == MI_PICKUP_BODYARMOUR) {
player->m_fArmour = 100.0f;
player->m_fArmour = CWorld::Players[playerIndex].m_nMaxArmour;
DMAudio.PlayFrontEndSound(SOUND_PICKUP_ARMOUR, 0);
return true;
} else if (modelIndex == MI_PICKUP_INFO) {
DMAudio.PlayFrontEndSound(SOUND_PICKUP_BONUS, 0);
return true;
} else if (modelIndex == MI_PICKUP_HEALTH) {
player->m_fHealth = 100.0f;
player->m_fHealth = CWorld::Players[playerIndex].m_nMaxHealth;
DMAudio.PlayFrontEndSound(SOUND_PICKUP_HEALTH, 0);
return true;
} else if (modelIndex == MI_PICKUP_BONUS) {

View file

@ -46,7 +46,7 @@ public:
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);
inline bool CanBePickedUp(CPlayerPed *player, int playerId);
void RemoveKeepType();
void Remove();
};

View file

@ -4821,7 +4821,7 @@ int8 CRunningScript::ProcessCommands500To599(int32 command)
CollectParameters(&m_nIp, 2);
CPlayerPed* pPed = CWorld::Players[ScriptParams[0]].m_pPed;
assert(pPed);
pPed->m_fHealth = ScriptParams[1];
pPed->m_fHealth = Min(ScriptParams[1], CWorld::Players[ScriptParams[0]].m_nMaxHealth);
return 0;
}
case COMMAND_SET_CHAR_HEALTH:
@ -7173,7 +7173,7 @@ int8 CRunningScript::ProcessCommands800To899(int32 command)
CollectParameters(&m_nIp, 2);
CPlayerPed* pPlayerPed = CWorld::Players[ScriptParams[0]].m_pPed;
assert(pPlayerPed);
pPlayerPed->m_fArmour = clamp(pPlayerPed->m_fArmour + ScriptParams[1], 0.0f, 100.0f);
pPlayerPed->m_fArmour = clamp(pPlayerPed->m_fArmour + ScriptParams[1], 0.0f, CWorld::Players[ScriptParams[0]].m_nMaxArmour);
return 0;
}
case COMMAND_ADD_ARMOUR_TO_CHAR:
@ -9870,6 +9870,10 @@ int8 CRunningScript::ProcessCommands1200To1299(int32 command)
return 0;
}
case COMMAND_ADD_MONEY_SPENT_ON_CLOTHES:
CollectParameters(&m_nIp, 1);
CStats::MoneySpentOnFashion(ScriptParams[0]);
return 0;
case COMMAND_SET_HELI_ORIENTATION:
case COMMAND_CLEAR_HELI_ORIENTATION:
case COMMAND_PLANE_GOTO_COORDS:
@ -10077,10 +10081,41 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
case COMMAND_GET_CLOSEST_WATER_NODE:
case COMMAND_ADD_PORN_LEAFLET_TO_RUBBISH:
case COMMAND_CREATE_CLOTHES_PICKUP:
{
CollectParameters(&m_nIp, 4);
CVector pos = *(CVector*)&ScriptParams[0];
if (pos.z <= MAP_Z_LOW_LIMIT)
pos.z = CWorld::FindGroundZForCoord(pos.x, pos.y) + PICKUP_PLACEMENT_OFFSET;
CPickups::GetActualPickupIndex(CollectNextParameterWithoutIncreasingPC(m_nIp));
ScriptParams[0] = CPickups::GenerateNewOne(pos, MI_PICKUP_CLOTHES, PICKUP_ON_STREET, ScriptParams[3]);
StoreParameters(&m_nIp, 1);
return 0;
}
case COMMAND_CHANGE_BLIP_THRESHOLD:
assert(0);
case COMMAND_MAKE_PLAYER_FIRE_PROOF:
{
CollectParameters(&m_nIp, 2);
CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]];
pPlayerInfo->m_bFireproof = ScriptParams[1];
return 0;
}
case COMMAND_INCREASE_PLAYER_MAX_HEALTH:
{
CollectParameters(&m_nIp, 2);
CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]];
pPlayerInfo->m_nMaxHealth += ScriptParams[1];
pPlayerInfo->m_pPed->m_fHealth = pPlayerInfo->m_nMaxHealth;
return 0;
}
case COMMAND_INCREASE_PLAYER_MAX_ARMOUR:
{
CollectParameters(&m_nIp, 2);
CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]];
pPlayerInfo->m_nMaxArmour += ScriptParams[1];
pPlayerInfo->m_pPed->m_fArmour = pPlayerInfo->m_nMaxArmour;
return 0;
}
case COMMAND_CREATE_RANDOM_CHAR_AS_DRIVER:
case COMMAND_CREATE_RANDOM_CHAR_AS_PASSENGER:
case COMMAND_SET_CHAR_IGNORE_THREATS_BEHIND_OBJECTS:
@ -10090,6 +10125,7 @@ int8 CRunningScript::ProcessCommands1300To1399(int32 command)
assert(0);
case COMMAND_SET_OBJECT_AREA_VISIBLE:
{
CollectParameters(&m_nIp, 2);
CObject* pObject = CPools::GetObjectPool()->GetAt(ScriptParams[0]);
assert(pObject);
pObject->m_area = ScriptParams[1];
@ -10157,7 +10193,11 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
case COMMAND_SET_LOAD_COLLISION_FOR_OBJECT_FLAG:
case COMMAND_ADD_BIG_GUN_FLASH:
case COMMAND_HAS_CHAR_BOUGHT_ICE_CREAM:
assert(0);
case COMMAND_GET_PROGRESS_PERCENTAGE:
*(float*)&ScriptParams[0] = CStats::GetPercentageProgress();
StoreParameters(&m_nIp, 1);
return 0;
case COMMAND_SET_SHORTCUT_PICKUP_POINT:
case COMMAND_SET_SHORTCUT_DROPOFF_POINT_FOR_MISSION:
case COMMAND_GET_RANDOM_ICE_CREAM_CUSTOMER_IN_AREA:

View file

@ -100,7 +100,7 @@ void WeaponCheat()
void HealthCheat()
{
CHud::SetHelpMessage(TheText.Get("CHEAT3"), true);
FindPlayerPed()->m_fHealth = 100.0f;
FindPlayerPed()->m_fHealth = CWorld::Players[0].m_nMaxHealth;
if (FindPlayerVehicle()) {
FindPlayerVehicle()->m_fHealth = 1000.0f;
if (FindPlayerVehicle()->m_vehType == VEHICLE_TYPE_CAR)
@ -224,7 +224,7 @@ void MoneyCheat()
void ArmourCheat()
{
CHud::SetHelpMessage(TheText.Get("CHEAT4"), true);
FindPlayerPed()->m_fArmour = 100.0f;
FindPlayerPed()->m_fArmour = CWorld::Players[0].m_nMaxArmour;
}
void WantedLevelUpCheat()

View file

@ -140,6 +140,7 @@ CPlayerInfo::Clear(void)
m_nUpsideDownCounter = 0;
m_bInfiniteSprint = false;
m_bFastReload = false;
m_nMaxHealth = m_nMaxArmour = 100;
m_bGetOutOfJailFree = false;
m_bGetOutOfHospitalFree = false;
m_nPreviousTimeRewardedForExplosion = 0;

View file

@ -52,6 +52,9 @@ public:
int32 field_272;
bool m_bInfiniteSprint;
bool m_bFastReload;
bool m_bFireproof;
uint8 m_nMaxHealth;
uint8 m_nMaxArmour;
bool m_bGetOutOfJailFree;
bool m_bGetOutOfHospitalFree;
char m_aSkinName[32];

View file

@ -61,6 +61,7 @@ int32 CStats::HighestScores[CStats::TOTAL_HIGHEST_SCORES];
int32 CStats::Sprayings;
float CStats::AutoPaintingBudget;
int32 CStats::NoMoreHurricanes;
float CStats::FashionBudget;
void CStats::Init()
{
@ -208,6 +209,19 @@ void CStats::SetTotalNumberMissions(int32 total)
TotalNumberMissions = total;
}
float CStats::GetPercentageProgress()
{
float p;
if (TotalProgressInGame == 0.0f)
p = 0.0f;
else if (CGame::nastyGame)
p = 100.0f * ProgressMade / TotalProgressInGame;
else
p = 100.0f * ProgressMade / (TotalProgressInGame - 1);
return Min(100.0f, p);
}
wchar *CStats::FindCriminalRatingString()
{
int rating = FindCriminalRatingNumber();
@ -249,6 +263,11 @@ int32 CStats::FindCriminalRatingNumber()
return rating;
}
void CStats::MoneySpentOnFashion(int32 money)
{
FashionBudget += money;
}
void CStats::SaveStats(uint8 *buf, uint32 *size)
{
CheckPointReachedSuccessfully();

View file

@ -65,6 +65,7 @@ public:
static int32 Sprayings;
static float AutoPaintingBudget;
static int32 NoMoreHurricanes;
static float FashionBudget;
public:
static void Init(void);
@ -88,6 +89,9 @@ public:
static void CheckPointReachedSuccessfully() { TotalLegitimateKills += KillsSinceLastCheckpoint; KillsSinceLastCheckpoint = 0; };
static void CheckPointReachedUnsuccessfully() { KillsSinceLastCheckpoint = 0; };
static int32 FindCriminalRatingNumber();
static float GetPercentageProgress();
static void SaveStats(uint8 *buf, uint32 *size);
static void LoadStats(uint8 *buf, uint32 size);
static void MoneySpentOnFashion(int32);
};

View file

@ -160,7 +160,8 @@
X("subplatform_sub", MI_SUBPLATFORM_SUB2, 0x5F5BC0) \
X("files", MI_FILES, 0x5F5BC4) \
X("property_locked", MI_PICKUP_PROPERTY, 0x0) \
X("property_fsale", MI_PICKUP_PROPERTY_FORSALE, 0x0)
X("property_fsale", MI_PICKUP_PROPERTY_FORSALE, 0x0) \
X("clothesp", MI_PICKUP_CLOTHES, 0x0)
#define X(name, var, addr) extern int16 var;
MODELINDICES

View file

@ -325,7 +325,7 @@ CCivilianPed::ProcessControl(void)
CWorld::Players[CWorld::PlayerInFocus].m_nSexFrequency = Max(250, playerSexFrequency - 10);
}
m_pMyVehicle->pDriver->m_fHealth = Min(125.0f, 1.0f + m_pMyVehicle->pDriver->m_fHealth);
m_pMyVehicle->pDriver->m_fHealth = Min(CWorld::Players[0].m_nMaxHealth + 25.0f, 1.0f + m_pMyVehicle->pDriver->m_fHealth);
if (CWorld::Players[CWorld::PlayerInFocus].m_nSexFrequency == 250)
CWorld::Players[CWorld::PlayerInFocus].m_nNextSexFrequencyUpdateTime = CTimer::GetTimeInMilliseconds() + 3000;
} else {
@ -336,7 +336,7 @@ CCivilianPed::ProcessControl(void)
} else {
bWanderPathAfterExitingCar = true;
CWorld::Players[CWorld::PlayerInFocus].m_pHooker = nil;
m_pMyVehicle->pDriver->m_fHealth = 125.0f;
m_pMyVehicle->pDriver->m_fHealth = CWorld::Players[0].m_nMaxHealth + 25.0f;
SetObjective(OBJECTIVE_LEAVE_VEHICLE, m_pMyVehicle);
}
} else {

View file

@ -1080,14 +1080,14 @@ CVehicle::SetDriver(CPed *driver)
if(bFreebies && driver == FindPlayerPed()){
if(GetModelIndex() == MI_AMBULAN)
FindPlayerPed()->m_fHealth = Min(FindPlayerPed()->m_fHealth + 20.0f, 100.0f);
FindPlayerPed()->m_fHealth = Min(FindPlayerPed()->m_fHealth + 20.0f, CWorld::Players[0].m_nMaxHealth);
else if(GetModelIndex() == MI_TAXI)
CWorld::Players[CWorld::PlayerInFocus].m_nMoney += 25;
else if (GetModelIndex() == MI_POLICE) {
CStreaming::RequestModel(WEAPONTYPE_SHOTGUN, STREAMFLAGS_DONT_REMOVE);
driver->GiveWeapon(WEAPONTYPE_SHOTGUN, 5);
} else if (GetModelIndex() == MI_ENFORCER)
driver->m_fArmour = Max(driver->m_fArmour, 100.0f);
driver->m_fArmour = Max(driver->m_fArmour, CWorld::Players[0].m_nMaxArmour);
else if(GetModelIndex() == MI_CABBIE || GetModelIndex() == MI_ZEBRA) // TODO(MIAMI): check zebra
CWorld::Players[CWorld::PlayerInFocus].m_nMoney += 25;
bFreebies = false;