Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
22a476c
Merge pull request #2 from multitheftauto/master
CrosRoad95 May 30, 2018
d9229bc
Merge pull request #3 from multitheftauto/master
CrosRoad95 Jun 1, 2018
6e3ea50
Merge pull request #4 from multitheftauto/master
CrosRoad95 Jun 23, 2018
ec62964
Merge pull request #5 from multitheftauto/master
CrosRoad95 Jun 29, 2018
ad8eb2f
test 1
CrosRoad95 Jun 30, 2018
6591fc1
Merge pull request #7 from multitheftauto/master
CrosRoad95 Jul 1, 2018
fb084fc
Merge pull request #9 from multitheftauto/master
CrosRoad95 Jul 2, 2018
3055613
Merge pull request #10 from multitheftauto/master
CrosRoad95 Jul 4, 2018
f5dd372
Merge pull request #10 from multitheftauto/master
CrosRoad95 Jul 4, 2018
86baf91
removed pathfinding from master
CrosRoad95 Jul 4, 2018
9258936
Merge remote-tracking branch 'origin/master'
CrosRoad95 Jul 12, 2018
96df11d
Merge remote-tracking branch 'upstream/master'
CrosRoad95 Aug 31, 2018
25e275f
Water cannon event
CrosRoad95 Sep 16, 2018
6f734a0
updated
CrosRoad95 Sep 16, 2018
8b971b3
fixed a bit
CrosRoad95 Sep 17, 2018
ed9d53e
fix conflicts
CrosRoad95 Sep 17, 2018
d626e0d
Merge branch 'master' into watercanon
Sep 18, 2018
6fd451b
Merge remote-tracking branch 'origin/master'
CrosRoad95 Sep 21, 2018
f71c7b0
Merge pull request #11 from multitheftauto/master
CrosRoad95 Sep 22, 2018
ef48974
Merge remote-tracking branch 'origin/master'
CrosRoad95 Sep 22, 2018
e68fd5d
Merge branch 'master' into watercanon
CrosRoad95 Sep 22, 2018
8e25837
Merge branch 'master' into watercanon
CrosRoad95 Sep 22, 2018
c2f909b
test for conflict fix
CrosRoad95 Sep 22, 2018
c293ae9
fix conflict
CrosRoad95 Sep 22, 2018
1f4a314
fix offset
CrosRoad95 Sep 22, 2018
e6bb1b0
renamed event
CrosRoad95 Sep 22, 2018
cbcc684
updated names
CrosRoad95 Sep 25, 2018
1a3c65a
Merge branch 'master' into watercanon
botder Sep 27, 2018
feb9d30
Refactor onClientWaterCannonHit to *ElementHitByWaterCannon
botder Sep 28, 2018
02f9d83
Remove game_sa include in multiplayer project
botder Sep 30, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,7 @@ CClientGame::CClientGame(bool bLocalPlay)
g_pMultiplayer->SetGameEntityRenderHandler(CClientGame::StaticGameEntityRenderHandler);
g_pMultiplayer->SetFxSystemDestructionHandler(CClientGame::StaticFxSystemDestructionHandler);
g_pMultiplayer->SetDrivebyAnimationHandler(CClientGame::StaticDrivebyAnimationHandler);
g_pMultiplayer->SetWaterCannonHitWorldHandler(CClientGame::StaticWaterCannonHitWorldHandler);
g_pGame->SetPreWeaponFireHandler(CClientGame::PreWeaponFire);
g_pGame->SetPostWeaponFireHandler(CClientGame::PostWeaponFire);
g_pGame->SetTaskSimpleBeHitHandler(CClientGame::StaticTaskSimpleBeHitHandler);
Expand Down Expand Up @@ -440,6 +441,7 @@ CClientGame::~CClientGame(void)
g_pMultiplayer->SetGameModelRemoveHandler(NULL);
g_pMultiplayer->SetGameEntityRenderHandler(NULL);
g_pMultiplayer->SetDrivebyAnimationHandler(nullptr);
g_pMultiplayer->SetWaterCannonHitWorldHandler(nullptr);
g_pGame->SetPreWeaponFireHandler(NULL);
g_pGame->SetPostWeaponFireHandler(NULL);
g_pGame->SetTaskSimpleBeHitHandler(NULL);
Expand Down Expand Up @@ -2744,6 +2746,7 @@ void CClientGame::AddBuiltInEvents(void)
m_Events.AddEvent("onClientElementStreamIn", "", NULL, false);
m_Events.AddEvent("onClientElementStreamOut", "", NULL, false);
m_Events.AddEvent("onClientElementDestroy", "", NULL, false);
m_Events.AddEvent("onClientElementHitByWaterCannon", "vehicle, hitX, hitY, hitZ, normalX, normalY, normalZ, model, materialID", nullptr, false);

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

void CClientGame::StaticWaterCannonHitWorldHandler(SWaterCannonHitEvent& event)
{
g_pClientGame->WaterCannonHitWorldHandler(event);
}

void CClientGame::DrawRadarAreasHandler(void)
{
m_pRadarAreaManager->DoPulse();
Expand Down Expand Up @@ -6885,3 +6893,28 @@ void CClientGame::RemoveAnimationAssociationFromMap(CAnimBlendAssociationSAInter
{
m_mapOfCustomAnimationAssociations.erase(pAnimAssociation);
}

void CClientGame::WaterCannonHitWorldHandler(SWaterCannonHitEvent& event)
{
CClientEntity* const pVehicle = event.pGameVehicle ? g_pClientGame->GetGameEntityXRefManager()->FindClientVehicle(event.pGameVehicle) : nullptr;

if (!pVehicle)
return;

CClientEntity* pEntity = event.pHitGameEntity ? g_pClientGame->GetGameEntityXRefManager()->FindClientEntity(event.pHitGameEntity) : nullptr;

if (!pEntity)
pEntity = m_pRootEntity;

CLuaArguments arguments;
arguments.PushElement(pVehicle);
arguments.PushNumber(event.vecPosition.fX);
arguments.PushNumber(event.vecPosition.fY);
arguments.PushNumber(event.vecPosition.fZ);
arguments.PushNumber(event.vecNormal.fX);
arguments.PushNumber(event.vecNormal.fY);
arguments.PushNumber(event.vecNormal.fZ);
arguments.PushNumber(event.iModel);
arguments.PushNumber(event.ucColSurface);
pEntity->CallEvent("onClientElementHitByWaterCannon", arguments, false);
}
3 changes: 3 additions & 0 deletions Client/mods/deathmatch/logic/CClientGame.h
Original file line number Diff line number Diff line change
Expand Up @@ -527,6 +527,7 @@ class CClientGame
static void StaticGameEntityRenderHandler(CEntitySAInterface* pEntity);
static void StaticTaskSimpleBeHitHandler(CPedSAInterface* pPedAttacker, ePedPieceTypes hitBodyPart, int hitBodySide, int weaponId);
static void StaticFxSystemDestructionHandler(void* pFxSAInterface);
static void StaticWaterCannonHitWorldHandler(SWaterCannonHitEvent& event);
static AnimationId StaticDrivebyAnimationHandler(AnimationId animGroup, AssocGroupId animId);

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

void WaterCannonHitWorldHandler(SWaterCannonHitEvent& event);

private:
eStatus m_Status;
eServerType m_ServerType;
Expand Down
56 changes: 56 additions & 0 deletions Client/multiplayer_sa/CMultiplayerSA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,9 @@ DWORD dwFUNC_CAEVehicleAudioEntity__ProcessAIProp = FUNC_CAEVehicleAudioEntity__
#define HOOKPOS_CTaskSimpleSwim_ProcessSwimmingResistance 0x68A4EF
DWORD RETURN_CTaskSimpleSwim_ProcessSwimmingResistance = 0x68A50E;

#define HOOKPOS_CWaterCannon__Render 0x72932A
static DWORD CONTINUE_CWaterCannon__Render = 0x72932F;

CPed* pContextSwitchedPed = 0;
CVector vecCenterOfWorld;
FLOAT fFalseHeading;
Expand Down Expand Up @@ -367,6 +370,7 @@ ObjectDamageHandler* m_pObjectDamageHandler = NULL;
ObjectBreakHandler* m_pObjectBreakHandler = NULL;
FxSystemDestructionHandler* m_pFxSystemDestructionHandler = NULL;
DrivebyAnimationHandler* m_pDrivebyAnimationHandler = NULL;
WaterCannonHitWorldHandler* m_pWaterCannonHitWorldHandler = nullptr;

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

void HOOK_CTaskSimpleSwim_ProcessSwimmingResistance();

static void HOOK_CWaterCannon__Render();

CMultiplayerSA::CMultiplayerSA()
{
// Unprotect all of the GTASA code at once and leave it that way
Expand Down Expand Up @@ -757,6 +763,8 @@ void CMultiplayerSA::InitHooks()
// Fix GTA:SA swimming speed problem on higher fps
HookInstall(HOOKPOS_CTaskSimpleSwim_ProcessSwimmingResistance, (DWORD)HOOK_CTaskSimpleSwim_ProcessSwimmingResistance, 6);

HookInstall(HOOKPOS_CWaterCannon__Render, (DWORD)HOOK_CWaterCannon__Render, 5);

// Disable GTA setting g_bGotFocus to false when we minimize
MemSet((void*)ADDR_GotFocus, 0x90, pGameInterface->GetGameVersion() == VERSION_EU_10 ? 6 : 10);

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

// Allow water cannon to hit objects and players visually
MemSet((void*)0x72925D, 0x1, 1); // objects
MemSet((void*)0x729263, 0x1, 1); // players

InitHooks_CrashFixHacks();

// Init our 1.3 hooks.
Expand Down Expand Up @@ -2250,6 +2262,11 @@ void CMultiplayerSA::SetDrivebyAnimationHandler(DrivebyAnimationHandler* pHandle
m_pDrivebyAnimationHandler = pHandler;
}

void CMultiplayerSA::SetWaterCannonHitWorldHandler(WaterCannonHitWorldHandler* pHandler)
{
m_pWaterCannonHitWorldHandler = pHandler;
}

// What we do here is check if the idle handler has been set
bool CMultiplayerSA::IsConnected(void)
{
Expand Down Expand Up @@ -6890,3 +6907,42 @@ void _declspec(naked) HOOK_CTaskSimpleSwim_ProcessSwimmingResistance()
jmp RETURN_CTaskSimpleSwim_ProcessSwimmingResistance
}
}

static void __cdecl WaterCannonHitWorld(CVehicleSAInterface* pGameVehicle, CColPointSAInterface* pColPoint, CEntitySAInterface** ppGameEntity)
{
if (m_pWaterCannonHitWorldHandler)
{
CEntitySAInterface* const pGameEntity = ppGameEntity ? *ppGameEntity : nullptr;
const int iModel = pGameEntity ? pGameEntity->m_nModelIndex : -1;

SWaterCannonHitEvent event = {
pGameVehicle,
pGameEntity,
pColPoint->Position,
pColPoint->Normal,
iModel,
pColPoint->ucSurfaceTypeB,
};

m_pWaterCannonHitWorldHandler(event);
}
}

static void _declspec(naked) HOOK_CWaterCannon__Render()
{
_asm
{
pushad
mov eax, [ebx] // CVehicleSAInterface* CWaterCannon::m_pVehicle
lea ebx, [esp + 100h - 54h] // CColPointSAInterface*
lea ecx, [esp + 100h - 58h] // CEntitySAInterface**
push ecx // ppGameEntity
push ebx // pColPoint
push eax // pGameVehicle
call WaterCannonHitWorld
add esp, 12
popad
push 3E4CCCCDh
jmp CONTINUE_CWaterCannon__Render
}
}
1 change: 1 addition & 0 deletions Client/multiplayer_sa/CMultiplayerSA.h
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ class CMultiplayerSA : public CMultiplayer
void SetGameEntityRenderHandler(GameEntityRenderHandler* pHandler);
void SetFxSystemDestructionHandler(FxSystemDestructionHandler* pHandler);
void SetDrivebyAnimationHandler(DrivebyAnimationHandler* pHandler);
void SetWaterCannonHitWorldHandler(WaterCannonHitWorldHandler* pHandler);

void AllowMouseMovement(bool bAllow);
void DoSoundHacksOnLostFocus(bool bLostFocus);
Expand Down
12 changes: 12 additions & 0 deletions Client/sdk/multiplayer/CMultiplayer.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,16 @@ struct SClothesCacheStats
uint uiNumRemoved;
};

struct SWaterCannonHitEvent
{
CEntitySAInterface* pGameVehicle;
CEntitySAInterface* pHitGameEntity;
CVector vecPosition;
CVector vecNormal;
int iModel;
unsigned char ucColSurface;
};

class CAnimBlendAssociationSAInterface;
class CAnimBlendStaticAssociationSAInterface;
class CAnimBlendAssocGroupSAInterface;
Expand Down Expand Up @@ -97,6 +107,7 @@ typedef void(GameModelRemoveHandler)(ushort usModelId);
typedef void(GameEntityRenderHandler)(CEntitySAInterface* pEntity);
typedef void(FxSystemDestructionHandler)(void* pFxSA);
typedef AnimationId(DrivebyAnimationHandler)(AnimationId animGroup, AssocGroupId animId);
typedef void(WaterCannonHitWorldHandler)(SWaterCannonHitEvent& event);

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

virtual void AllowMouseMovement(bool bAllow) = 0;
virtual void DoSoundHacksOnLostFocus(bool bLostFocus) = 0;
Expand Down