Skip to content

Commit

Permalink
modloader - pedheads support
Browse files Browse the repository at this point in the history
  • Loading branch information
ermaccer committed Feb 5, 2022
1 parent 39a7037 commit 0a018f2
Show file tree
Hide file tree
Showing 16 changed files with 196 additions and 19 deletions.
6 changes: 3 additions & 3 deletions source/code/manhunt/Camera.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#include "Camera.h"

float& CCam::ms_freeCameraRotationSpeed = *(float*)0x715AB8;
float& CCam::ms_freeCameraSpeed = *(float*)0x715ABC;
CCam& TheCamera = *(CCam*)0x7A0FAC;
float& CCamera::ms_freeCameraRotationSpeed = *(float*)0x715AB8;
float& CCamera::ms_freeCameraSpeed = *(float*)0x715ABC;
CCamera& TheCamera = *(CCamera*)0x7A0FAC;
4 changes: 2 additions & 2 deletions source/code/manhunt/Camera.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#pragma once
#include "Vector.h"

struct CCam {
struct CCamera {
float field_0;
char field_4;
char field_5;
Expand Down Expand Up @@ -1154,5 +1154,5 @@ struct CCam {
static float& ms_freeCameraRotationSpeed;
};

extern CCam& TheCamera;
extern CCamera& TheCamera;

2 changes: 1 addition & 1 deletion source/code/manhunt/Entity.h
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ class CEntity {
char field_76;
char field_77;
int field_78;
CTypeData *m_TypeData;
CTypeData *m_pTypeData;
int field_80;
int field_84;
int field_88;
Expand Down
14 changes: 14 additions & 0 deletions source/code/manhunt/MusicManager.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "MusicManager.h"
#include "core.h"

cMusicManager* MusicManager = *(cMusicManager**)0x7A9EBC;

void cMusicManager::StopStreaming()
{
CallMethod<0x5A14A0, cMusicManager*>(this);
}

void cMusicManager::PreloadExecutionStream(eCollectableType type)
{
CallMethod<0x5A5370, cMusicManager*>(this, type);
}
11 changes: 11 additions & 0 deletions source/code/manhunt/MusicManager.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#pragma once
#include "Collectable.h"

class cMusicManager {
public:
void StopStreaming();
void PreloadExecutionStream(eCollectableType type);
};


extern cMusicManager* MusicManager;
30 changes: 30 additions & 0 deletions source/code/manhunt/Ped.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,33 @@ void CPed::SelectInventoryItem(eHolsterSlot slot, int unk)
{
CallMethod<0x4ABE70, CPed*, eHolsterSlot, int>(this,slot, unk);
}

void CPed::UseCollectable(eCollectableType item, bool createIfDoesntExist)
{
CallMethod<0x4ABB50, CPed*, eCollectableType, bool>(this, item, createIfDoesntExist);
}

bool CPed::HoldingMeleeWeapon()
{
return CallMethodAndReturn<bool, 0x4ABCF0, CPed*>(this);
}

bool CPed::HoldingShooterWeapon()
{
return CallMethodAndReturn<bool, 0x4ABD50, CPed*>(this);
}

bool CPed::HoldingTwoHandedShooterWeapon()
{
return CallMethodAndReturn<bool, 0x4ABDA0, CPed*>(this);
}

bool CPed::HoldingThrowingWeapon()
{
return CallMethodAndReturn<bool, 0x4ABDE0, CPed*>(this);
}

bool CPed::HoldingClumsyWeapon()
{
return CallMethodAndReturn<bool, 0x4ABE30, CPed*>(this);
}
8 changes: 8 additions & 0 deletions source/code/manhunt/Ped.h
Original file line number Diff line number Diff line change
Expand Up @@ -1086,6 +1086,14 @@ class CPed : public CCharacter {
void SeverHead(CVector* pos);
void SetHeading(float heading, bool unk);
void SelectInventoryItem(eHolsterSlot slot, int unk);

void UseCollectable(eCollectableType item, bool createIfDoesntExist);

bool HoldingMeleeWeapon();
bool HoldingShooterWeapon();
bool HoldingTwoHandedShooterWeapon();
bool HoldingThrowingWeapon();
bool HoldingClumsyWeapon();
};


Expand Down
6 changes: 6 additions & 0 deletions source/code/plugin/classes/eCustomPed.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "eCustomPed.h"

void CPedEx::UseCollectableEx(eCollectableType item, bool createIfDoesntExist)
{
UseCollectable(CT_NIGHTSTICK, createIfDoesntExist);
}
7 changes: 7 additions & 0 deletions source/code/plugin/classes/eCustomPed.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#pragma once
#include "..\..\manhunt\Ped.h"

class CPedEx : public CPed {
public:
void UseCollectableEx(eCollectableType item, bool createIfDoesntExist);
};
4 changes: 2 additions & 2 deletions source/code/plugin/classes/eCustomProjectile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ void CCustomProjectile::Spawn(RwMatrix * mat)
CWeaponCollectable* wep = (CWeaponCollectable*)this;
wep->Spawn(mat);

if (strcmp(m_TypeData->m_szModel, "Grenade_(CT)") == 0)
if (strcmp(m_pTypeData->m_szModel, "Grenade_(CT)") == 0)
{
CVector pos = *GetLocation();
FXSystem_Play("Drum_Explode", &pos, 0);
Expand All @@ -22,7 +22,7 @@ void CCustomProjectileShot::NewDestroy(bool create_weapon)
{
CWeaponCollectable* wep = *(CWeaponCollectable**)((int)this + 36);

if (strcmp(wep->m_TypeData->m_szModel, "Grenade_(CT)") == 0)
if (strcmp(wep->m_pTypeData->m_szModel, "Grenade_(CT)") == 0)
{
// use health as timer
CEntity* entity = *(CEntity**)((int)this + 32);
Expand Down
5 changes: 3 additions & 2 deletions source/code/plugin/console/eConsole.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -363,9 +363,10 @@ void ConsoleCommands::list(char * args)

if (strcmp(type, "data") == 0)
{
CPed * chr = (CPed*)entity;
CFrontend::PrintDebugInfo(1, "~cyan~DATA[%s]", entityName);
CFrontend::PrintDebugInfo(2, "Record = %s", entity->m_TypeData->m_szRecordName);
CFrontend::PrintDebugInfo(3, "Class = %d", entity->m_TypeData->m_ecEntityClass);
CFrontend::PrintDebugInfo(2, "Record = %s", entity->m_pTypeData->m_szRecordName);
CFrontend::PrintDebugInfo(3, "Class = %d", entity->m_pTypeData->m_ecEntityClass);
CFrontend::PrintDebugInfo(4, "Health = %f", entity->m_fHealth);
CFrontend::PrintDebugInfo(5, "Position = X:%.3f Y:%.3f Z:%.3f", entity->GetLocation()->x, entity->GetLocation()->y, entity->GetLocation()->z);
CFrontend::PrintDebugInfo(6, "Flags = 0x%x", entity->m_iEntityFlags);
Expand Down
59 changes: 59 additions & 0 deletions source/code/plugin/eQoLChanges.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
#include "eQoLChanges.h"
#include "..\manhunt\core.h"
#include "..\manhunt\Player.h"
#include "..\manhunt\Hunter.h"
#include "..\manhunt\TypeData.h"
#include "..\manhunt\Scene.h"
#include "..\core\eSettingsManager.h"

void eQoLChanges::Init()
{
if (eSettingsManager::bSkipIntroSequence) SkipIntro();
// InjectHook(0x5A53A7, FixCerberusExecutionAudio, PATCH_JUMP);
}

void eQoLChanges::SkipIntro()
{
Expand All @@ -10,4 +21,52 @@ void eQoLChanges::SkipIntro()

}

void __declspec(naked) eQoLChanges::FixCerberusExecutionAudio()
{
// todo: unload somehow
static int cerberus_set_true = 0x5A53BD;
static int cerberus_set_false = 0x5A53C7;

_asm {
pushad
}

static CPlayer* plr;
static CHunter* enemy;
static CCharacterTypeData* typedata;

plr = (CPlayer*)CScene::FindPlayer();

enemy = plr->m_pExecuteHunter;

if (enemy)
{
typedata = (CCharacterTypeData*)enemy->m_pTypeData;

if (typedata->m_nVoice == CERBERUS || typedata->m_nVoice == CERBERUS_LEADER)
{
printf("CERB EXEC\n");
_asm {
popad
jmp cerberus_set_true
}
}
else
{
_asm {
popad
jmp cerberus_set_false
}
}
}
else
{
_asm {
popad
jmp cerberus_set_false
}
}

}


4 changes: 3 additions & 1 deletion source/code/plugin/eQoLChanges.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

class eQoLChanges {
public:
static void SkipIntro();
static void Init();

static void SkipIntro();
static void FixCerberusExecutionAudio();
};
14 changes: 8 additions & 6 deletions source/code/plugin/menu/eMenu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "..\..\manhunt\PtrList.h"
#include "..\..\manhunt\Graph.h"
#include "..\..\manhunt\Camera.h"
#include "..\..\manhunt\MusicManager.h"

#include "..\..\core\eSettingsManager.h"
#include "..\..\core\eMain.h"
Expand Down Expand Up @@ -115,6 +116,7 @@ void eMenu::Initialize()
AddWeaponEntry(CT_CHAINSAW_PLAYER);
AddWeaponEntry(CT_PIGSY_WIRE);
AddWeaponEntry(CT_PIGSY_SHARD);
AddWeaponEntry(CT_BAG);

AddCategory("Weapons", true);

Expand All @@ -131,7 +133,7 @@ void eMenu::Initialize()
list = *(int*)(list + 8);

if (entity)
AddEntityEntry(entity->m_TypeData->m_szRecordName);
AddEntityEntry(entity->m_pTypeData->m_szRecordName);


} while (entity);
Expand Down Expand Up @@ -169,8 +171,8 @@ void eMenu::Initialize()
AddSliderFloatEntry("Aim Camera Offset X", &TheCamera.m_vAimingCameraOffset.x, -INT_MAX, INT_MAX);
AddSliderFloatEntry("Aim Camera Offset Y", &TheCamera.m_vAimingCameraOffset.y, -INT_MAX, INT_MAX);
AddSliderFloatEntry("Aim Camera Offset Z", &TheCamera.m_vAimingCameraOffset.z, -INT_MAX, INT_MAX);
AddSliderFloatEntry("Free Camera Rotation Speed", &CCam::ms_freeCameraRotationSpeed, -INT_MAX, INT_MAX);
AddSliderFloatEntry("Free Camera Speed", &CCam::ms_freeCameraSpeed, -INT_MAX, INT_MAX);
AddSliderFloatEntry("Free Camera Rotation Speed", &CCamera::ms_freeCameraRotationSpeed, -INT_MAX, INT_MAX);
AddSliderFloatEntry("Free Camera Speed", &CCamera::ms_freeCameraSpeed, -INT_MAX, INT_MAX);
AddCategory("Camera");

AddFunctionEntry("Free", CWeather::SetWeatherFree);
Expand Down Expand Up @@ -213,7 +215,7 @@ void eMenu::ProcessMenu()
CHunter* hunter = plr->m_pExecuteHunter;

if (hunter)
sprintf(buffer, "Execute: %s Time: %f Stage: %d", hunter->m_TypeData->m_szRecordName, plr->m_fExecuteTime, plr->GetExecuteStage());
sprintf(buffer, "Execute: %s Time: %f Stage: %d", hunter->m_pTypeData->m_szRecordName, plr->m_fExecuteTime, plr->GetExecuteStage());
else
sprintf(buffer, "No Entity to execute");

Expand Down Expand Up @@ -1024,7 +1026,7 @@ void PrintEntities()

if (entity)
{
TheConsole.m_messages.push_back(entity->m_TypeData->m_szRecordName);
TheConsole.m_messages.push_back(entity->m_pTypeData->m_szRecordName);
}

} while (entity);
Expand All @@ -1036,7 +1038,7 @@ void PrintExecuteHunter()
CPlayer* plr = (CPlayer*)CScene::FindPlayer();
CEntity* hunt = *(CEntity**)((int)plr + 0x8B4);
if (hunt)
printf("%x %s\n", hunt, hunt->m_TypeData->m_szRecordName);
printf("%x %s\n", hunt, hunt->m_pTypeData->m_szRecordName);
else
printf("no execute\n");
}
Expand Down
40 changes: 38 additions & 2 deletions source/code/plugin/modloader/eCustomClumpDict.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,47 @@ CClump * eCustomClumpDict::FindClumpDescription(const char * name)
clump = eCustomClumpDictManager::m_vecClumps[i]->FindClumpDescription(name);
if (clump)
break;

}



if (!clump)
clump = dict->FindClumpDescription(name);
eLog::Message(__FUNCTION__, "Loading model: %s",name);

if (!clump)
eLog::Message(__FUNCTION__, "Could not load model %s!", name);



return clump;
}

CClump * eCustomClumpDict::FindClump(const char * name)
{
CClump* clump = nullptr;
CClumpDict* dict = (CClumpDict*)this;

// custom dffs first
for (int i = 0; i < eCustomClumpDictManager::m_vecClumps.size(); i++)
{
clump = eCustomClumpDictManager::m_vecClumps[i]->FindClump(name);
if (clump)
break;

}



if (!clump)
clump = dict->FindClump(name);

if (!clump)
eLog::Message(__FUNCTION__, "Could not load model %s!", name);

return clump;
}

void eCustomClumpDict::Destroy()
{
CClumpDict* dict = (CClumpDict*)this;
Expand All @@ -44,6 +73,13 @@ void eCustomClumpDictManager::InitHooks()
InjectHook(0x433A91, &eCustomClumpDict::FindClumpDescription, PATCH_CALL);
InjectHook(0x433BFF, &eCustomClumpDict::FindClumpDescription, PATCH_CALL);
InjectHook(0x433C10, &eCustomClumpDict::FindClumpDescription, PATCH_CALL);
//
InjectHook(0x4F1239, &eCustomClumpDict::FindClump, PATCH_CALL);
//InjectHook(0x4F1269, &eCustomClumpDict::FindClump, PATCH_CALL);
//InjectHook(0x5CE2E1, &eCustomClumpDict::FindClump, PATCH_CALL);
//InjectHook(0x5D0132, &eCustomClumpDict::FindClump, PATCH_CALL);
//InjectHook(0x5D04D3, &eCustomClumpDict::FindClump, PATCH_CALL);

InjectHook(0x43797B, &eCustomClumpDict::Destroy, PATCH_CALL);
}

Expand All @@ -61,7 +97,7 @@ char * eCustomClumpDictManager::TranslateClumpPtr(int ptr)
return "Character";
break;
default:
return "Unknown";
return "Unknown/Custom";
break;
}
return nullptr;
Expand Down
1 change: 1 addition & 0 deletions source/code/plugin/modloader/eCustomClumpDict.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,6 @@ class eCustomClumpDictManager {
class eCustomClumpDict {
public:
CClump* FindClumpDescription(const char* name);
CClump* FindClump(const char* name);
void Destroy();
};

0 comments on commit 0a018f2

Please sign in to comment.