[SA] Add ped anims

This commit is contained in:
Grinch_ 2022-01-09 18:09:48 +06:00
parent 2b58d9488d
commit cd6850c018
5 changed files with 53 additions and 26 deletions

View File

@ -28,8 +28,6 @@ If you have those mentioned versions installed follow the steps below,
### For III & VC ### For III & VC
3. Install [D3D8to9 wrapper](https://github.com/crosire/d3d8to9/releases). Sometimes the asi loader blocks **d3d8.dll** file. Just delete the **Globals.ini** file and you should be good to go. 3. Install [D3D8to9 wrapper](https://github.com/crosire/d3d8to9/releases). Sometimes the asi loader blocks **d3d8.dll** file. Just delete the **Globals.ini** file and you should be good to go.
Be sure to check [here](https://github.com/user-grinch/Cheat-Menu/issues/48) to know about incompatibilities with other mods.
## Incompatible Mods ## Incompatible Mods
### GTA SA ### GTA SA
1. **ENB/ SA_DirectX 2.0** **FIX:** Disable Effect/ Enable water 1. **ENB/ SA_DirectX 2.0** **FIX:** Disable Effect/ Enable water

View File

@ -147,15 +147,15 @@ void Animation::_PlayAnimation(RpClump* pClump, int animGroup, int animID, float
void Animation::PlayAnimation(std::string& ifp, std::string& anim, std::string& value) void Animation::PlayAnimation(std::string& ifp, std::string& anim, std::string& value)
{ {
CPlayerPed *pPlayer = FindPlayerPed(); CPed *pPed = m_PedAnim ? m_pTarget : FindPlayerPed();
if (!pPlayer) if (!pPed)
{ {
return; return;
} }
#ifdef GTASA #ifdef GTASA
int hplayer = CPools::GetPedRef(pPlayer); int hped = CPools::GetPedRef(pPed);
if (ifp != "PED") if (ifp != "PED")
{ {
@ -163,14 +163,14 @@ void Animation::PlayAnimation(std::string& ifp, std::string& anim, std::string&
Command<Commands::LOAD_ALL_MODELS_NOW>(); Command<Commands::LOAD_ALL_MODELS_NOW>();
} }
Command<Commands::CLEAR_CHAR_TASKS>(hplayer); Command<Commands::CLEAR_CHAR_TASKS>(hped);
if (m_bSecondary) if (m_bSecondary)
{ {
Command<Commands::TASK_PLAY_ANIM_SECONDARY>(hplayer, anim.c_str(), ifp.c_str(), 4.0, m_Loop, 0, 0, 0, -1); Command<Commands::TASK_PLAY_ANIM_SECONDARY>(hped, anim.c_str(), ifp.c_str(), 4.0, m_Loop, 0, 0, 0, -1);
} }
else else
{ {
Command<Commands::TASK_PLAY_ANIM>(hplayer, anim.c_str(), ifp.c_str(), 4.0, m_Loop, 0, 0, 0, -1); Command<Commands::TASK_PLAY_ANIM>(hped, anim.c_str(), ifp.c_str(), 4.0, m_Loop, 0, 0, 0, -1);
} }
if (ifp != "PED") if (ifp != "PED")
@ -179,11 +179,11 @@ void Animation::PlayAnimation(std::string& ifp, std::string& anim, std::string&
} }
#else #else
if (pPlayer) if (pPed)
{ {
int groupID, animID; int groupID, animID;
sscanf(value.c_str(), "%d$%d,", &groupID, &animID); sscanf(value.c_str(), "%d$%d,", &groupID, &animID);
_PlayAnimation(pPlayer->m_pRwClump, groupID, animID, 4.0f); _PlayAnimation(pPed->m_pRwClump, groupID, animID, 4.0f);
} }
#endif #endif
} }
@ -193,11 +193,11 @@ Animation::Animation()
#ifdef GTASA #ifdef GTASA
Events::processScriptsEvent += [this] Events::processScriptsEvent += [this]
{ {
CPlayerPed* pPlayer = FindPlayerPed();
if (m_Cutscene::m_bRunning) if (m_Cutscene::m_bRunning)
{ {
if (Command<Commands::HAS_CUTSCENE_FINISHED>()) if (Command<Commands::HAS_CUTSCENE_FINISHED>())
{ {
CPlayerPed* pPlayer = FindPlayerPed();
if (!pPlayer) if (!pPlayer)
{ {
return; return;
@ -217,6 +217,16 @@ Animation::Animation()
m_Cutscene::m_bRunning = true; m_Cutscene::m_bRunning = true;
} }
} }
if (pPlayer && pPlayer->m_pPlayerTargettedPed)
{
m_pTarget = pPlayer->m_pPlayerTargettedPed;
}
if (m_pTarget && !m_pTarget->IsAlive())
{
m_pTarget = nullptr;
}
}; };
#elif GTAVC #elif GTAVC
// mov al, 01 // mov al, 01
@ -242,7 +252,7 @@ void Animation::Draw()
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::BeginTabItem("Anims")) if (ImGui::BeginTabItem("Animation##TABBAR"))
{ {
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::Button("Stop animation", Ui::GetSize())) if (ImGui::Button("Stop animation", Ui::GetSize()))
@ -260,20 +270,29 @@ void Animation::Draw()
ImGui::Spacing(); ImGui::Spacing();
ImGui::Columns(2, nullptr, false); ImGui::Columns(2, nullptr, false);
ImGui::Checkbox("Loop", &m_Loop); Ui::CheckboxWithHint("Loop", &m_Loop, "Keep playing the animation on repeat");
Ui::ShowTooltip("Keep playing the animation on repeat"); Ui::CheckboxWithHint("Secondary", &m_bSecondary, "Player can move while playing the animation");
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::Checkbox("Secondary", &m_bSecondary); #ifdef GTASA
Ui::ShowTooltip("Player can move while playing the animation"); Ui::CheckboxWithHint("Ped anim", &m_PedAnim, "Play animation on other peds.\nSelect with weapon target.");
#endif
ImGui::Columns(1); ImGui::Columns(1);
ImGui::Spacing(); ImGui::Spacing();
if (ImGui::BeginChild("Anims Child")) if (m_PedAnim && !m_pTarget)
{ {
ImGui::Spacing(); ImGui::TextWrapped("No player target found. Aim a ped with a weapon to select it for animation player.");
Ui::DrawJSON(m_AnimData, PlayAnimation, RemoveAnimation);
ImGui::EndChild();
} }
else
{
if (ImGui::BeginChild("Anims Child"))
{
ImGui::Spacing();
Ui::DrawJSON(m_AnimData, PlayAnimation, RemoveAnimation);
ImGui::EndChild();
}
}
ImGui::EndTabItem(); ImGui::EndTabItem();
} }
if (ImGui::BeginTabItem("Custom")) if (ImGui::BeginTabItem("Custom"))

View File

@ -11,7 +11,9 @@ private:
static inline char m_nIfpBuffer[INPUT_BUFFER_SIZE]; static inline char m_nIfpBuffer[INPUT_BUFFER_SIZE];
static inline bool m_Loop; // loop animation static inline bool m_Loop; // loop animation
static inline bool m_bSecondary; // play animation as secondary static inline bool m_bSecondary; // play animation as secondary
static inline bool m_PedAnim;
static inline CPed *m_pTarget = nullptr;
#ifdef GTASA #ifdef GTASA
// Cutscene player // Cutscene player
struct m_Cutscene struct m_Cutscene

View File

@ -327,7 +327,9 @@ bool Ui::CheckboxWithHint(const char* label, bool* v, const char* hint, bool is_
} }
if (ImGui::IsItemHovered() && !is_disabled) if (ImGui::IsItemHovered() && !is_disabled)
{
color = ImGui::GetColorU32(ImGuiCol_FrameBgHovered); color = ImGui::GetColorU32(ImGuiCol_FrameBgHovered);
}
// draw the button // draw the button
ImVec2 min = ImGui::GetItemRectMin(); ImVec2 min = ImGui::GetItemRectMin();
@ -414,15 +416,17 @@ bool Ui::CheckboxAddressEx(const char* label, const int addr, int enabled_val, i
int val = 0; int val = 0;
patch::GetRaw(addr, &val, 1, false); patch::GetRaw(addr, &val, 1, false);
if (val == enabled_val) state = (val == enabled_val);
state = true;
if (CheckboxWithHint(label, &state, hint) && addr != NULL) if (CheckboxWithHint(label, &state, hint) && addr != NULL)
{ {
if (state) if (state)
{
patch::SetRaw(addr, &enabled_val, 1, false); patch::SetRaw(addr, &enabled_val, 1, false);
}
else else
{
patch::SetRaw(addr, &disabled_val, 1, false); patch::SetRaw(addr, &disabled_val, 1, false);
}
rtn = true; rtn = true;
} }
@ -450,9 +454,13 @@ bool Ui::CheckboxAddressVarEx(const char* label, bool val, int addr, int enabled
if (CheckboxWithHint(label, &state, hint)) if (CheckboxWithHint(label, &state, hint))
{ {
if (state) if (state)
{
patch::SetRaw(addr, &enabled_val, 1, false); patch::SetRaw(addr, &enabled_val, 1, false);
}
else else
{
patch::SetRaw(addr, &disabled_val, 1, false); patch::SetRaw(addr, &disabled_val, 1, false);
}
rtn = true; rtn = true;
} }

View File

@ -1105,9 +1105,9 @@ void Vehicle::Draw()
ImGui::RadioButton("Tertiary", &m_Paint::m_nRadioButton, 3); ImGui::RadioButton("Tertiary", &m_Paint::m_nRadioButton, 3);
ImGui::RadioButton("Quaternary", &m_Paint::m_nRadioButton, 4); ImGui::RadioButton("Quaternary", &m_Paint::m_nRadioButton, 4);
#else #else
ImGui::RadioButton("Primary", &m_Color::m_nRadioButton, 1); ImGui::RadioButton("Primary", &m_Paint::m_nRadioButton, 1);
ImGui::NextColumn(); ImGui::NextColumn();
ImGui::RadioButton("Secondary", &m_Color::m_nRadioButton, 2); ImGui::RadioButton("Secondary", &m_Paint::m_nRadioButton, 2);
#endif #endif
ImGui::Spacing(); ImGui::Spacing();
ImGui::Columns(1); ImGui::Columns(1);