Skip to content
This repository has been archived by the owner on Dec 8, 2022. It is now read-only.

Commit

Permalink
Fixed #4776: Killing peds with sniper rifle cases scope view to get b…
Browse files Browse the repository at this point in the history
…ack to follow player.

(corrected stealth-task args)
  • Loading branch information
zzzjax@hotmail.com committed Aug 11, 2009
1 parent f000f3a commit c20041c
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 5 deletions.
2 changes: 1 addition & 1 deletion MTA10/game_sa/CTasksSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ CTaskComplexDie* CTasksSA::CreateTaskComplexDie ( const eWeaponType eMeansOfDeat
}


CTaskSimpleStealthKill* CTasksSA::CreateTaskSimpleStealthKill ( bool bKiller, class CPed * pPed, const AnimationId animGroup )
CTaskSimpleStealthKill* CTasksSA::CreateTaskSimpleStealthKill ( bool bKiller, class CPed * pPed, const AssocGroupId animGroup )
{
DEBUG_TRACE("CTaskSimpleStealthKill* CTasksSA::CreateTaskSimpleStealthKill ( bool bKiller, class CPed * pPed, const AnimationId anim )");

Expand Down
2 changes: 1 addition & 1 deletion MTA10/game_sa/CTasksSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ class CTasksSA : public CTasks
CTaskSimpleRunNamedAnim* CreateTaskSimpleRunNamedAnim ( const char* pAnimName, const char* pAnimGroupName, const int flags, const float fBlendDelta, const int iTime = -1, const bool bDontInterrupt = false, const bool bRunInSequence = false, const bool bOffsetPed = false, const bool bHoldLastFrame = false );

CTaskComplexDie* CreateTaskComplexDie ( const eWeaponType eMeansOfDeath=WEAPONTYPE_UNARMED, const AssocGroupId animGroup=0/*ANIM_STD_PED*/, const AnimationId anim=0/*ANIM_STD_KO_FRONT*/, const float fBlendDelta=4.0f, const float fAnimSpeed=0.0f, const bool bBeingKilledByStealth=false, const bool bFallingToDeath=false, const int iFallToDeathDir=0, const bool bFallToDeathOverRailing=false );
CTaskSimpleStealthKill* CreateTaskSimpleStealthKill ( bool bAttacker, class CPed * pPed, const AnimationId anim );
CTaskSimpleStealthKill* CreateTaskSimpleStealthKill ( bool bAttacker, class CPed * pPed, const AssocGroupId animGroup );

CTaskComplexSunbathe* CreateTaskComplexSunbathe ( class CObject* pTowel, const bool bStartStanding );

Expand Down
4 changes: 2 additions & 2 deletions MTA10/mods/shared_logic/CClientPed.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1574,7 +1574,7 @@ void CClientPed::Kill ( eWeaponType weaponType, unsigned char ucBodypart, bool b

if ( bStealth )
{
pTask = g_pGame->GetTasks ()->CreateTaskSimpleStealthKill ( false, m_pPlayerPed, 87 );
pTask = g_pGame->GetTasks ()->CreateTaskSimpleStealthKill ( false, m_pPlayerPed, ANIM_GROUP_STEALTH_KN );
if ( pTask )
{
pTask->SetAsPedTask ( m_pPlayerPed, TASK_PRIORITY_PRIMARY );
Expand Down Expand Up @@ -1609,7 +1609,7 @@ void CClientPed::StealthKill ( CClientPed * pPed )
CPlayerPed * pPlayerPed = pPed->GetGamePlayer ();
if ( pPlayerPed )
{
CTask * pTask = g_pGame->GetTasks ()->CreateTaskSimpleStealthKill ( true, pPlayerPed, 87 );
CTask * pTask = g_pGame->GetTasks ()->CreateTaskSimpleStealthKill ( true, pPlayerPed, ANIM_GROUP_STEALTH_KN );
if ( pTask )
{
pTask->SetAsPedTask ( m_pPlayerPed, TASK_PRIORITY_PRIMARY );
Expand Down
45 changes: 45 additions & 0 deletions MTA10/multiplayer_sa/CMultiplayerSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,9 @@ DWORD RETURN_CAnimManager_BlendAnimation = 0x4D4617;
#define HOOKPOS_CPed_GetWeaponSkill 0x5e3b60
DWORD RETURN_CPed_GetWeaponSkill = 0x5E3B68;

#define HOOKPOS_CTaskSimplePlayerOnFoot_MakeAbortable 0x68596F
DWORD RETURN_CTaskSimplePlayerOnFoot_MakeAbortable = 0x685980;

CPed* pContextSwitchedPed = 0;
CVector vecCenterOfWorld;
FLOAT fFalseHeading;
Expand Down Expand Up @@ -265,6 +268,7 @@ void HOOK_CEventHandler_ComputeKnockOffBikeResponse ();
void HOOK_CAnimManager_AddAnimation ();
void HOOK_CAnimManager_BlendAnimation ();
void HOOK_CPed_GetWeaponSkill ();
void HOOK_CTaskSimplePlayerOnFoot_MakeAbortable ();

void vehicle_lights_init ();

Expand Down Expand Up @@ -376,6 +380,7 @@ void CMultiplayerSA::InitHooks()
HookInstall(HOOKPOS_CAnimManager_AddAnimation, (DWORD)HOOK_CAnimManager_AddAnimation, 10 );
HookInstall(HOOKPOS_CAnimManager_BlendAnimation, (DWORD)HOOK_CAnimManager_BlendAnimation, 7 );
HookInstall(HOOKPOS_CPed_GetWeaponSkill, (DWORD)HOOK_CPed_GetWeaponSkill, 8 );
HookInstall(HOOKPOS_CTaskSimplePlayerOnFoot_MakeAbortable, (DWORD)HOOK_CTaskSimplePlayerOnFoot_MakeAbortable, 11 );

HookInstallCall ( CALL_CBike_ProcessRiderAnims, (DWORD)HOOK_CBike_ProcessRiderAnims );
HookInstallCall ( CALL_Render3DStuff, (DWORD)HOOK_Render3DStuff );
Expand Down Expand Up @@ -4076,4 +4081,44 @@ void _declspec(naked) HOOK_CPed_GetWeaponSkill ()
jmp RETURN_CPed_GetWeaponSkill
}
}
}

CPedSAInterface * pOnFootPed;
DWORD FUNC_CCamera_ClearPlayerWeaponMode = 0x50AB10;
DWORD FUNC_CWeaponEffects_ClearCrossHair = 0x742C60;
void _declspec(naked) HOOK_CTaskSimplePlayerOnFoot_MakeAbortable ()
{
/* Replaces:
call CCamera_ClearPlayerWeaponMode
mov eax, [esi+598h]
push eax
call CWeaponEffects_ClearCrossHair
*/
_asm
{
mov pOnFootPed, esi
pushad
}
if ( IsLocalPlayer ( pOnFootPed ) )
{
_asm
{
popad
call FUNC_CCamera_ClearPlayerWeaponMode
mov eax, [esi+598h]
push eax
call FUNC_CWeaponEffects_ClearCrossHair
jmp RETURN_CTaskSimplePlayerOnFoot_MakeAbortable
}
}
else
{
_asm
{
popad
mov eax, [esi+598h]
push eax
jmp RETURN_CTaskSimplePlayerOnFoot_MakeAbortable
}
}
}
2 changes: 1 addition & 1 deletion MTA10/sdk/game/CTasks.h
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ class CTasks
virtual CTaskSimpleRunNamedAnim * CreateTaskSimpleRunNamedAnim ( const char* pAnimName, const char* pAnimGroupName, const int flags, const float fBlendDelta, const int iTime = -1, const bool bDontInterrupt = false, const bool bRunInSequence = false, const bool bOffsetPed = false, const bool bHoldLastFrame = false )=0;

virtual CTaskComplexDie * CreateTaskComplexDie ( const eWeaponType eMeansOfDeath=WEAPONTYPE_UNARMED, const AssocGroupId animGroup=0/*ANIM_STD_PED*/, const AnimationId anim=0/*ANIM_STD_KO_FRONT*/, const float fBlendDelta=4.0f, const float fAnimSpeed=0.0f, const bool bBeingKilledByStealth=false, const bool bFallingToDeath=false, const int iFallToDeathDir=0, const bool bFallToDeathOverRailing=false )=0;
virtual CTaskSimpleStealthKill * CreateTaskSimpleStealthKill ( bool bAttacker, class CPed * pPed, const AnimationId anim )=0;
virtual CTaskSimpleStealthKill * CreateTaskSimpleStealthKill ( bool bAttacker, class CPed * pPed, const AssocGroupId animGroup )=0;

virtual CTaskComplexSunbathe * CreateTaskComplexSunbathe ( class CObject* pTowel, const bool bStartStanding )=0;

Expand Down

0 comments on commit c20041c

Please sign in to comment.