Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit cee63da

Browse files
CrosRoad95botder
CrosRoad95
authored andcommitted
Add event onClientElementHitByWaterCannon (#477)
1 parent d28393f commit cee63da

File tree

5 files changed

+105
-0
lines changed

5 files changed

+105
-0
lines changed

‎Client/mods/deathmatch/logic/CClientGame.cpp‎

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,6 +280,7 @@ CClientGame::CClientGame(bool bLocalPlay)
280280
g_pMultiplayer->SetGameEntityRenderHandler(CClientGame::StaticGameEntityRenderHandler);
281281
g_pMultiplayer->SetFxSystemDestructionHandler(CClientGame::StaticFxSystemDestructionHandler);
282282
g_pMultiplayer->SetDrivebyAnimationHandler(CClientGame::StaticDrivebyAnimationHandler);
283+
g_pMultiplayer->SetWaterCannonHitWorldHandler(CClientGame::StaticWaterCannonHitWorldHandler);
283284
g_pGame->SetPreWeaponFireHandler(CClientGame::PreWeaponFire);
284285
g_pGame->SetPostWeaponFireHandler(CClientGame::PostWeaponFire);
285286
g_pGame->SetTaskSimpleBeHitHandler(CClientGame::StaticTaskSimpleBeHitHandler);
@@ -440,6 +441,7 @@ CClientGame::~CClientGame(void)
440441
g_pMultiplayer->SetGameModelRemoveHandler(NULL);
441442
g_pMultiplayer->SetGameEntityRenderHandler(NULL);
442443
g_pMultiplayer->SetDrivebyAnimationHandler(nullptr);
444+
g_pMultiplayer->SetWaterCannonHitWorldHandler(nullptr);
443445
g_pGame->SetPreWeaponFireHandler(NULL);
444446
g_pGame->SetPostWeaponFireHandler(NULL);
445447
g_pGame->SetTaskSimpleBeHitHandler(NULL);
@@ -2744,6 +2746,7 @@ void CClientGame::AddBuiltInEvents(void)
27442746
m_Events.AddEvent("onClientElementStreamIn", "", NULL, false);
27452747
m_Events.AddEvent("onClientElementStreamOut", "", NULL, false);
27462748
m_Events.AddEvent("onClientElementDestroy", "", NULL, false);
2749+
m_Events.AddEvent("onClientElementHitByWaterCannon", "vehicle, hitX, hitY, hitZ, normalX, normalY, normalZ, model, materialID", nullptr, false);
27472750

27482751
// Player events
27492752
m_Events.AddEvent("onClientPlayerJoin", "", NULL, false);
@@ -3798,6 +3801,11 @@ AnimationId CClientGame::StaticDrivebyAnimationHandler(AnimationId animGroup, As
37983801
return g_pClientGame->DrivebyAnimationHandler(animGroup, animId);
37993802
}
38003803

3804+
void CClientGame::StaticWaterCannonHitWorldHandler(SWaterCannonHitEvent& event)
3805+
{
3806+
g_pClientGame->WaterCannonHitWorldHandler(event);
3807+
}
3808+
38013809
void CClientGame::DrawRadarAreasHandler(void)
38023810
{
38033811
m_pRadarAreaManager->DoPulse();
@@ -6885,3 +6893,28 @@ void CClientGame::RemoveAnimationAssociationFromMap(CAnimBlendAssociationSAInter
68856893
{
68866894
m_mapOfCustomAnimationAssociations.erase(pAnimAssociation);
68876895
}
6896+
6897+
void CClientGame::WaterCannonHitWorldHandler(SWaterCannonHitEvent& event)
6898+
{
6899+
CClientEntity* const pVehicle = event.pGameVehicle ? g_pClientGame->GetGameEntityXRefManager()->FindClientVehicle(event.pGameVehicle) : nullptr;
6900+
6901+
if (!pVehicle)
6902+
return;
6903+
6904+
CClientEntity* pEntity = event.pHitGameEntity ? g_pClientGame->GetGameEntityXRefManager()->FindClientEntity(event.pHitGameEntity) : nullptr;
6905+
6906+
if (!pEntity)
6907+
pEntity = m_pRootEntity;
6908+
6909+
CLuaArguments arguments;
6910+
arguments.PushElement(pVehicle);
6911+
arguments.PushNumber(event.vecPosition.fX);
6912+
arguments.PushNumber(event.vecPosition.fY);
6913+
arguments.PushNumber(event.vecPosition.fZ);
6914+
arguments.PushNumber(event.vecNormal.fX);
6915+
arguments.PushNumber(event.vecNormal.fY);
6916+
arguments.PushNumber(event.vecNormal.fZ);
6917+
arguments.PushNumber(event.iModel);
6918+
arguments.PushNumber(event.ucColSurface);
6919+
pEntity->CallEvent("onClientElementHitByWaterCannon", arguments, false);
6920+
}

‎Client/mods/deathmatch/logic/CClientGame.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -527,6 +527,7 @@ class CClientGame
527527
static void StaticGameEntityRenderHandler(CEntitySAInterface* pEntity);
528528
static void StaticTaskSimpleBeHitHandler(CPedSAInterface* pPedAttacker, ePedPieceTypes hitBodyPart, int hitBodySide, int weaponId);
529529
static void StaticFxSystemDestructionHandler(void* pFxSAInterface);
530+
static void StaticWaterCannonHitWorldHandler(SWaterCannonHitEvent& event);
530531
static AnimationId StaticDrivebyAnimationHandler(AnimationId animGroup, AssocGroupId animId);
531532

532533
bool DamageHandler(CPed* pDamagePed, CEventDamage* pEvent);
@@ -616,6 +617,8 @@ class CClientGame
616617
void InsertAnimationAssociationToMap(CAnimBlendAssociationSAInterface* pAnimAssociation, const std::shared_ptr<CIFPAnimations>& pIFPAnimations);
617618
void RemoveAnimationAssociationFromMap(CAnimBlendAssociationSAInterface* pAnimAssociation);
618619

620+
void WaterCannonHitWorldHandler(SWaterCannonHitEvent& event);
621+
619622
private:
620623
eStatus m_Status;
621624
eServerType m_ServerType;

‎Client/multiplayer_sa/CMultiplayerSA.cpp‎

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -300,6 +300,9 @@ DWORD dwFUNC_CAEVehicleAudioEntity__ProcessAIProp = FUNC_CAEVehicleAudioEntity__
300300
#define HOOKPOS_CTaskSimpleSwim_ProcessSwimmingResistance 0x68A4EF
301301
DWORD RETURN_CTaskSimpleSwim_ProcessSwimmingResistance = 0x68A50E;
302302

303+
#define HOOKPOS_CWaterCannon__Render 0x72932A
304+
static DWORD CONTINUE_CWaterCannon__Render = 0x72932F;
305+
303306
CPed* pContextSwitchedPed = 0;
304307
CVector vecCenterOfWorld;
305308
FLOAT fFalseHeading;
@@ -367,6 +370,7 @@ ObjectDamageHandler* m_pObjectDamageHandler = NULL;
367370
ObjectBreakHandler* m_pObjectBreakHandler = NULL;
368371
FxSystemDestructionHandler* m_pFxSystemDestructionHandler = NULL;
369372
DrivebyAnimationHandler* m_pDrivebyAnimationHandler = NULL;
373+
WaterCannonHitWorldHandler* m_pWaterCannonHitWorldHandler = nullptr;
370374

371375
CEntitySAInterface* dwSavedPlayerPointer = 0;
372376
CEntitySAInterface* activeEntityForStreaming = 0; // the entity that the streaming system considers active
@@ -524,6 +528,8 @@ void HOOK_CAEVehicleAudioEntity__ProcessDummyProp();
524528

525529
void HOOK_CTaskSimpleSwim_ProcessSwimmingResistance();
526530

531+
static void HOOK_CWaterCannon__Render();
532+
527533
CMultiplayerSA::CMultiplayerSA()
528534
{
529535
// Unprotect all of the GTASA code at once and leave it that way
@@ -757,6 +763,8 @@ void CMultiplayerSA::InitHooks()
757763
// Fix GTA:SA swimming speed problem on higher fps
758764
HookInstall(HOOKPOS_CTaskSimpleSwim_ProcessSwimmingResistance, (DWORD)HOOK_CTaskSimpleSwim_ProcessSwimmingResistance, 6);
759765

766+
HookInstall(HOOKPOS_CWaterCannon__Render, (DWORD)HOOK_CWaterCannon__Render, 5);
767+
760768
// Disable GTA setting g_bGotFocus to false when we minimize
761769
MemSet((void*)ADDR_GotFocus, 0x90, pGameInterface->GetGameVersion() == VERSION_EU_10 ? 6 : 10);
762770

@@ -1490,6 +1498,10 @@ void CMultiplayerSA::InitHooks()
14901498
// Allow to switch weapons while glued
14911499
MemSetFast((void*)0x60D861, 0x90, 14);
14921500

1501+
// Allow water cannon to hit objects and players visually
1502+
MemSet((void*)0x72925D, 0x1, 1); // objects
1503+
MemSet((void*)0x729263, 0x1, 1); // players
1504+
14931505
InitHooks_CrashFixHacks();
14941506

14951507
// Init our 1.3 hooks.
@@ -2250,6 +2262,11 @@ void CMultiplayerSA::SetDrivebyAnimationHandler(DrivebyAnimationHandler* pHandle
22502262
m_pDrivebyAnimationHandler = pHandler;
22512263
}
22522264

2265+
void CMultiplayerSA::SetWaterCannonHitWorldHandler(WaterCannonHitWorldHandler* pHandler)
2266+
{
2267+
m_pWaterCannonHitWorldHandler = pHandler;
2268+
}
2269+
22532270
// What we do here is check if the idle handler has been set
22542271
bool CMultiplayerSA::IsConnected(void)
22552272
{
@@ -6890,3 +6907,42 @@ void _declspec(naked) HOOK_CTaskSimpleSwim_ProcessSwimmingResistance()
68906907
jmp RETURN_CTaskSimpleSwim_ProcessSwimmingResistance
68916908
}
68926909
}
6910+
6911+
static void __cdecl WaterCannonHitWorld(CVehicleSAInterface* pGameVehicle, CColPointSAInterface* pColPoint, CEntitySAInterface** ppGameEntity)
6912+
{
6913+
if (m_pWaterCannonHitWorldHandler)
6914+
{
6915+
CEntitySAInterface* const pGameEntity = ppGameEntity ? *ppGameEntity : nullptr;
6916+
const int iModel = pGameEntity ? pGameEntity->m_nModelIndex : -1;
6917+
6918+
SWaterCannonHitEvent event = {
6919+
pGameVehicle,
6920+
pGameEntity,
6921+
pColPoint->Position,
6922+
pColPoint->Normal,
6923+
iModel,
6924+
pColPoint->ucSurfaceTypeB,
6925+
};
6926+
6927+
m_pWaterCannonHitWorldHandler(event);
6928+
}
6929+
}
6930+
6931+
static void _declspec(naked) HOOK_CWaterCannon__Render()
6932+
{
6933+
_asm
6934+
{
6935+
pushad
6936+
mov eax, [ebx] // CVehicleSAInterface* CWaterCannon::m_pVehicle
6937+
lea ebx, [esp + 100h - 54h] // CColPointSAInterface*
6938+
lea ecx, [esp + 100h - 58h] // CEntitySAInterface**
6939+
push ecx // ppGameEntity
6940+
push ebx // pColPoint
6941+
push eax // pGameVehicle
6942+
call WaterCannonHitWorld
6943+
add esp, 12
6944+
popad
6945+
push 3E4CCCCDh
6946+
jmp CONTINUE_CWaterCannon__Render
6947+
}
6948+
}

‎Client/multiplayer_sa/CMultiplayerSA.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@ class CMultiplayerSA : public CMultiplayer
130130
void SetGameEntityRenderHandler(GameEntityRenderHandler* pHandler);
131131
void SetFxSystemDestructionHandler(FxSystemDestructionHandler* pHandler);
132132
void SetDrivebyAnimationHandler(DrivebyAnimationHandler* pHandler);
133+
void SetWaterCannonHitWorldHandler(WaterCannonHitWorldHandler* pHandler);
133134

134135
void AllowMouseMovement(bool bAllow);
135136
void DoSoundHacksOnLostFocus(bool bLostFocus);

‎Client/sdk/multiplayer/CMultiplayer.h‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ struct SClothesCacheStats
3737
uint uiNumRemoved;
3838
};
3939

40+
struct SWaterCannonHitEvent
41+
{
42+
CEntitySAInterface* pGameVehicle;
43+
CEntitySAInterface* pHitGameEntity;
44+
CVector vecPosition;
45+
CVector vecNormal;
46+
int iModel;
47+
unsigned char ucColSurface;
48+
};
49+
4050
class CAnimBlendAssociationSAInterface;
4151
class CAnimBlendStaticAssociationSAInterface;
4252
class CAnimBlendAssocGroupSAInterface;
@@ -97,6 +107,7 @@ typedef void(GameModelRemoveHandler)(ushort usModelId);
97107
typedef void(GameEntityRenderHandler)(CEntitySAInterface* pEntity);
98108
typedef void(FxSystemDestructionHandler)(void* pFxSA);
99109
typedef AnimationId(DrivebyAnimationHandler)(AnimationId animGroup, AssocGroupId animId);
110+
typedef void(WaterCannonHitWorldHandler)(SWaterCannonHitEvent& event);
100111

101112
/**
102113
* This class contains information used for shot syncing, one exists per player.
@@ -214,6 +225,7 @@ class CMultiplayer
214225
virtual void SetGameEntityRenderHandler(GameEntityRenderHandler* pHandler) = 0;
215226
virtual void SetFxSystemDestructionHandler(FxSystemDestructionHandler* pHandler) = 0;
216227
virtual void SetDrivebyAnimationHandler(DrivebyAnimationHandler* pHandler) = 0;
228+
virtual void SetWaterCannonHitWorldHandler(WaterCannonHitWorldHandler* pHandler) = 0;
217229

218230
virtual void AllowMouseMovement(bool bAllow) = 0;
219231
virtual void DoSoundHacksOnLostFocus(bool bLostFocus) = 0;

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /