2 new opcodes

This commit is contained in:
eray orçunus 2020-08-16 17:10:59 +03:00
parent 9956b27767
commit 980dd1b5a1
7 changed files with 41 additions and 17 deletions

View File

@ -1824,7 +1824,7 @@ void CMissionCleanup::Process()
CWorld::Players[0].MakePlayerSafe(false); CWorld::Players[0].MakePlayerSafe(false);
CWorld::Players[0].m_pPed->m_nFadeDrunkenness = 1; CWorld::Players[0].m_pPed->m_nFadeDrunkenness = 1;
CWorld::Players[0].m_pPed->m_nDrunkCountdown = 0; CWorld::Players[0].m_pPed->m_nDrunkCountdown = 0;
// CPad::GetPad(0)->SetDrunkInputDelay(0); // TODO(Miami) CPad::GetPad(0)->SetDrunkInputDelay(0);
CWorld::Players[0].m_bDriveByAllowed = true; CWorld::Players[0].m_bDriveByAllowed = true;
// DMAudio::ShutUpPlayerTalking(0); // TODO(Miami) // DMAudio::ShutUpPlayerTalking(0); // TODO(Miami)
CVehicle::bDisableRemoteDetonation = false; CVehicle::bDisableRemoteDetonation = false;
@ -10645,7 +10645,8 @@ int8 CRunningScript::ProcessCommands1000To1099(int32 command)
case COMMAND_SET_DRUNK_INPUT_DELAY: case COMMAND_SET_DRUNK_INPUT_DELAY:
{ {
CollectParameters(&m_nIp, 2); CollectParameters(&m_nIp, 2);
debug("SET_DRUNK_INPUT_DELAY not implemented\n"); assert(ScriptParams[1] < CPad::DRUNK_STEERING_BUFFER_SIZE);
CPad::GetPad(ScriptParams[0])->SetDrunkInputDelay(ScriptParams[1]);
return 0; return 0;
} }
case COMMAND_SET_CHAR_MONEY: case COMMAND_SET_CHAR_MONEY:
@ -13606,9 +13607,11 @@ int8 CRunningScript::ProcessCommands1400To1499(int32 command)
case COMMAND_GET_BUS_FARES_COLLECTED_BY_PLAYER: case COMMAND_GET_BUS_FARES_COLLECTED_BY_PLAYER:
{ {
CollectParameters(&m_nIp, 1); CollectParameters(&m_nIp, 1);
debug("GET_BUS_FARES_COLLECTED_BY_PLAYER not implemented\n"); // TODO(MIAMI) CPlayerInfo* pPlayerInfo = &CWorld::Players[ScriptParams[0]];
ScriptParams[0] = 0; ScriptParams[0] = pPlayerInfo->m_pPed->m_nLastBusFareCollected;
pPlayerInfo->m_pPed->m_nLastBusFareCollected = 0;
StoreParameters(&m_nIp, 1); StoreParameters(&m_nIp, 1);
return 0;
} }
case COMMAND_SET_CHAR_OBJ_BUY_ICE_CREAM: case COMMAND_SET_CHAR_OBJ_BUY_ICE_CREAM:
{ {

View File

@ -631,6 +631,11 @@ void CPad::Clear(bool bResetPlayerControls)
ShakeFreq = 0; ShakeFreq = 0;
ShakeDur = 0; ShakeDur = 0;
for (int32 i = 0; i < DRUNK_STEERING_BUFFER_SIZE; i++)
SteeringLeftRightBuffer[i] = 0;
DrunkDrivingBufferUsed = 0;
if ( bResetPlayerControls ) if ( bResetPlayerControls )
DisablePlayerControls = PLAYERCONTROL_ENABLED; DisablePlayerControls = PLAYERCONTROL_ENABLED;
@ -1806,6 +1811,9 @@ void CPad::Update(int16 pad)
bHornHistory[iCurrHornHistory] = GetHorn(); bHornHistory[iCurrHornHistory] = GetHorn();
for (int32 i = DRUNK_STEERING_BUFFER_SIZE - 2; i >= 0; i--) {
SteeringLeftRightBuffer[i + 1] = SteeringLeftRightBuffer[i];
}
if ( !bDisplayNoControllerMessage ) if ( !bDisplayNoControllerMessage )
CGame::bDemoMode = false; CGame::bDemoMode = false;
@ -1899,6 +1907,7 @@ int16 CPad::GetSteeringLeftRight(void)
if ( ArePlayerControlsDisabled() ) if ( ArePlayerControlsDisabled() )
return 0; return 0;
int16 value;
switch (CURMODE) switch (CURMODE)
{ {
case 0: case 0:
@ -1908,9 +1917,12 @@ int16 CPad::GetSteeringLeftRight(void)
int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2; int16 dpad = (NewState.DPadRight - NewState.DPadLeft) / 2;
if ( Abs(axis) > Abs(dpad) ) if ( Abs(axis) > Abs(dpad) )
return axis; value = axis;
else else
return dpad; value = dpad;
SteeringLeftRightBuffer[0] = value;
value = SteeringLeftRightBuffer[DrunkDrivingBufferUsed];
break; break;
} }
@ -1918,13 +1930,18 @@ int16 CPad::GetSteeringLeftRight(void)
case 1: case 1:
case 3: case 3:
{ {
return NewState.LeftStickX; SteeringLeftRightBuffer[0] = NewState.LeftStickX;
value = SteeringLeftRightBuffer[DrunkDrivingBufferUsed];
break;
}
default:
{
value = 0;
break; break;
} }
} }
return 0; return value;
} }
int16 CPad::GetSteeringUpDown(void) int16 CPad::GetSteeringUpDown(void)

View File

@ -141,9 +141,12 @@ public:
enum enum
{ {
HORNHISTORY_SIZE = 5, HORNHISTORY_SIZE = 5,
DRUNK_STEERING_BUFFER_SIZE = 10,
}; };
CControllerState NewState; CControllerState NewState;
CControllerState OldState; CControllerState OldState;
int16 SteeringLeftRightBuffer[DRUNK_STEERING_BUFFER_SIZE];
int32 DrunkDrivingBufferUsed;
CControllerState PCTempKeyState; CControllerState PCTempKeyState;
CControllerState PCTempJoyState; CControllerState PCTempJoyState;
CControllerState PCTempMouseState; CControllerState PCTempMouseState;
@ -263,6 +266,7 @@ public:
static char *EditString(char *pStr, int32 nSize); static char *EditString(char *pStr, int32 nSize);
static int32 *EditCodesForControls(int32 *pRsKeys, int32 nSize); static int32 *EditCodesForControls(int32 *pRsKeys, int32 nSize);
uint32 InputHowLongAgo(void); uint32 InputHowLongAgo(void);
void SetDrunkInputDelay(int32 delay) { DrunkDrivingBufferUsed = delay; }
#ifdef XINPUT #ifdef XINPUT
void AffectFromXinput(uint32 pad); void AffectFromXinput(uint32 pad);

View File

@ -439,7 +439,7 @@ CPed::CPed(uint32 pedType) : m_pedIK(this)
bCrouchWhenScared = false; bCrouchWhenScared = false;
bKnockedOffBike = false; bKnockedOffBike = false;
b158_8 = false; b158_8 = false;
b158_10 = false; bCollectBusFare = false;
bBoughtIceCream = false; bBoughtIceCream = false;
b158_40 = false; b158_40 = false;
@ -12986,10 +12986,10 @@ CPed::PedSetInCarCB(CAnimBlendAssociation *animAssoc, void *arg)
ped->b157_40 = false; ped->b157_40 = false;
ped->bRemoveFromWorld = true; ped->bRemoveFromWorld = true;
} }
if (ped->b158_10) { if (ped->bCollectBusFare) {
ped->b158_10 = false; ped->bCollectBusFare = false;
if (FindPlayerPed()) if (FindPlayerPed())
FindPlayerPed()->m_nPadUpPressedInMilliseconds += 5; FindPlayerPed()->m_nLastBusFareCollected += 5;
} }
if (!ped->IsNotInWreckedVehicle() || ped->DyingOrDead()) if (!ped->IsNotInWreckedVehicle() || ped->DyingOrDead())
@ -15176,7 +15176,7 @@ CPed::ProcessObjective(void)
b157_40 = true; b157_40 = true;
CPlayerPed *player = FindPlayerPed(); CPlayerPed *player = FindPlayerPed();
if (pBus->IsPassenger(player) || pBus->IsDriver(player)) { if (pBus->IsPassenger(player) || pBus->IsDriver(player)) {
b158_10 = true; bCollectBusFare = true;
} }
} }
} }

View File

@ -485,7 +485,7 @@ public:
uint32 bCrouchWhenScared : 1; uint32 bCrouchWhenScared : 1;
uint32 bKnockedOffBike : 1; uint32 bKnockedOffBike : 1;
uint32 b158_8 : 1; uint32 b158_8 : 1;
uint32 b158_10 : 1; uint32 bCollectBusFare : 1;
uint32 bBoughtIceCream : 1; uint32 bBoughtIceCream : 1;
uint32 b158_40 : 1; uint32 b158_40 : 1;
//uint32 b158_80 //uint32 b158_80

View File

@ -83,7 +83,7 @@ CPlayerPed::CPlayerPed(void) : CPed(PEDTYPE_PLAYER1)
m_pMeleeList[i] = nil; m_pMeleeList[i] = nil;
} }
m_nCheckPlayersIndex = 0; m_nCheckPlayersIndex = 0;
m_nPadUpPressedInMilliseconds = 0; m_nLastBusFareCollected = 0;
idleAnimBlockIndex = CAnimManager::GetAnimationBlockIndex("playidles"); idleAnimBlockIndex = CAnimManager::GetAnimationBlockIndex("playidles");
} }

View File

@ -43,7 +43,7 @@ public:
float m_fGunSpinSpeed; // for minigun float m_fGunSpinSpeed; // for minigun
float m_fGunSpinAngle; float m_fGunSpinAngle;
unsigned int m_nPadDownPressedInMilliseconds; unsigned int m_nPadDownPressedInMilliseconds;
unsigned int m_nPadUpPressedInMilliseconds; unsigned int m_nLastBusFareCollected;
CPlayerPed(); CPlayerPed();
~CPlayerPed(); ~CPlayerPed();