Last active
January 14, 2019 10:20
-
-
Save codenulls/ad59dc3797ac5d8e2e723fd7e7b0901a to your computer and use it in GitHub Desktop.
Print all GTA III animation groups by pressing 1.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include "plugin.h" | |
#include "common.h" | |
#include "CTimer.h" | |
#include "InputManager.h" | |
#include "CAnimManager.h" | |
using namespace plugin; | |
class GTA3Animation { | |
public: | |
GTA3Animation() { | |
// Initialise your plugin here | |
if (AllocConsole()) | |
{ | |
freopen("CONIN$", "r", stdin); | |
freopen("CONOUT$", "w", stdout); | |
freopen("CONOUT$", "w", stderr); | |
} | |
Events::initGameEvent += [&] | |
{ | |
std::printf("Events::initGameEvent called\n"); | |
if (!theInputManager.Initialize()) | |
{ | |
MessageBox(0, "Direct Input Initialization Failed", "Error", MB_OK); | |
return; | |
} | |
theInputManager.RegisterKeyBoardCallBack(std::bind(>A3Animation::OnKeyPress, this, | |
std::placeholders::_1, std::placeholders::_2)); | |
theInputManager.RegisterMouseButtonCallBack(std::bind(>A3Animation::OnMouseButtonPress, this, | |
std::placeholders::_1, std::placeholders::_2, std::placeholders::_3)); | |
}; | |
/*Events::drawMenuBackgroundEvent += [&] | |
{ | |
theInputManager.UnAcquire(); | |
};*/ | |
// Initialise your plugin here | |
Events::gameProcessEvent += [&] | |
{ | |
theInputManager.ProcessInput(); | |
}; | |
} | |
void OnKeyPress(unsigned char key, PressState state) | |
{ | |
if (state == PRESS_DOWN) | |
{ | |
switch (key) | |
{ | |
case DIK_1: | |
{ | |
CPlayerPed* pLocalPlayer = FindPlayerPed(); | |
if (pLocalPlayer) | |
{ | |
PrintAllGroups(); | |
} | |
break; | |
} | |
} | |
} | |
} | |
void OnMouseButtonPress(MouseButton button, PressState state, POINT & position) | |
{ | |
if (button == MOUSE_BUTTON_LEFT && state == PRESS_DOWN) | |
{ | |
} | |
} | |
bool existsInMap(std::string& animName) | |
{ | |
return false; | |
} | |
void PrintAllGroups() | |
{ | |
for (int i = 0; i < CAnimManager::ms_numAnimAssocDefinitions; i++) | |
{ | |
CAnimationStyleDescriptor* pAssocDef = (CAnimationStyleDescriptor*)((BYTE*)CAnimManager::ms_aAnimAssocDefinitions + sizeof(CAnimationStyleDescriptor) * i); | |
CAnimBlendAssocGroup* pAssocGroup = (CAnimBlendAssocGroup*)((BYTE*)(*(DWORD*)CAnimManager::ms_aAnimAssocGroups) + sizeof(CAnimBlendAssocGroup) * i); // CAnimManager::ms_aAnimAssocGroups[i]; | |
//std::printf("ANIM_GROUP_%s = %d,\n", pAssocDef->groupName, i); | |
std::printf("// GroupName : %s | Group ID: %d | BlockName: %s | Total Animations: %d\nenum e%sAnimGroup \n{\n", pAssocDef->groupName, i, pAssocDef->blockName, pAssocDef->animsCount, pAssocDef->groupName); | |
CAnimBlock* pAnimBlock = CAnimManager::GetAnimationBlock(pAssocDef->blockName); | |
if (pAnimBlock) | |
{ | |
for (int animIndex = 0; animIndex < pAssocDef->animsCount; animIndex++) | |
{ | |
DWORD animID = animIndex + pAssocDef->animDesc->animId; | |
char theAnimName[32]; | |
char * animName = pAssocDef->animNames[animIndex]; | |
//std::printf("going to memcpy | source: %p | %s\n", animName, animName); | |
memcpy(theAnimName, animName, strlen(animName) + 1); | |
std::string theAnimNameString(theAnimName); | |
if (theAnimNameString.empty()) | |
{ | |
std::stringstream enumElementStr; | |
enumElementStr << pAssocDef->groupName << "_unknown_" << animIndex; | |
std::string enumElementString = enumElementStr.str(); | |
std::transform(enumElementString.begin(), enumElementString.end(), enumElementString.begin(), ::toupper); | |
std::printf("ANIM_%s = %d,\n", enumElementString.c_str(), animID); | |
} | |
else | |
{ | |
std::stringstream enumElementStr; | |
enumElementStr << pAssocDef->groupName << "_" << theAnimName; | |
std::string enumElementString = enumElementStr.str(); | |
std::transform(enumElementString.begin(), enumElementString.end(), enumElementString.begin(), ::toupper); | |
if (animNameDuplicateCount.find(enumElementString) == animNameDuplicateCount.end()) { | |
std::printf("ANIM_%s = %d,\n", enumElementString.c_str(), animID); | |
animNameDuplicateCount[enumElementString] = 0; | |
} | |
else { | |
int count = animNameDuplicateCount[enumElementString]; | |
count += 1; | |
std::printf("ANIM_%s_%d = %d,\n", enumElementString.c_str(), count, animID); | |
animNameDuplicateCount[enumElementString] = count; | |
} | |
} | |
} | |
std::printf("};\n\n"); | |
} | |
else | |
{ | |
std::printf("\nBLOCK IS NOT LOADED groupID: %d\n\n", i); | |
break; | |
} | |
} | |
} | |
private: | |
InputManager theInputManager; | |
std::unordered_map<std::string, int> animNameDuplicateCount; | |
} gTA3Animation; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment