Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CoC/Anomaly] Optional grenade launcher switch animation usage. #1768

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 6 additions & 5 deletions src/xrGame/HudItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ bool CHudItem::TryPlayAnimIdle()
}

//AVO: check if animation exists
bool CHudItem::isHUDAnimationExist(pcstr anim_name) const
bool CHudItem::isHUDAnimationExist(pcstr anim_name, bool silent) const
{
if (const auto* data = HudItemData()) // First person
{
Expand All @@ -399,16 +399,17 @@ bool CHudItem::isHUDAnimationExist(pcstr anim_name) const
else
return false; // No hud section, no warning
#ifdef DEBUG
Msg("~ [WARNING] ------ Animation [%s] does not exist in [%s]", anim_name, HudSection().c_str());
if (!silent)
Msg("~ [WARNING] ------ Animation [%s] does not exist in [%s]", anim_name, HudSection().c_str());
#endif
return false;
}

pcstr CHudItem::WhichHUDAnimationExist(pcstr anim_name, pcstr anim_name2) const
pcstr CHudItem::WhichHUDAnimationExist(pcstr anim_name, pcstr anim_name2, bool silent) const
{
if (isHUDAnimationExist(anim_name))
if (isHUDAnimationExist(anim_name, silent))
return anim_name;
if (isHUDAnimationExist(anim_name2))
if (isHUDAnimationExist(anim_name2, silent))
return anim_name2;
return nullptr;
}
Expand Down
4 changes: 2 additions & 2 deletions src/xrGame/HudItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,6 @@ class CHudItem : public CHUDState

virtual CHudItem* cast_hud_item() { return this; }
void PlayAnimIdleMovingCrouch(); //AVO: new crouch idle animation
bool isHUDAnimationExist(pcstr anim_name) const;
pcstr WhichHUDAnimationExist(pcstr anim_name, pcstr anim_name2) const;
bool isHUDAnimationExist(pcstr anim_name, bool silent = false) const;
pcstr WhichHUDAnimationExist(pcstr anim_name, pcstr anim_name2, bool silent = false) const;
};
10 changes: 7 additions & 3 deletions src/xrGame/WeaponMagazinedWGrenade.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -736,10 +736,14 @@ void CWeaponMagazinedWGrenade::PlayAnimShoot()

void CWeaponMagazinedWGrenade::PlayAnimModeSwitch()
{
if (m_bGrenadeMode)
PlayHUDMotion("anm_switch_g", "anim_switch_grenade_on", /*FALSE*/ TRUE, this, eSwitch); //AVO: fix fast anim switch
// Respect SOC/CS/COP animations naming with two possible animation assignments and do not spam in logs on checks.
// Possible place to inject anm_switch_g_empty / anm_switch_empty logics later with CoC/anomaly-like implementation.
cpcstr animation = m_bGrenadeMode ? WhichHUDAnimationExist("anm_switch_g", "anim_switch_grenade_on", true) : WhichHUDAnimationExist("anm_switch", "anim_switch_grenade_off", true);

if (animation)
PlayHUDMotion(animation, TRUE, this, eSwitch);
else
PlayHUDMotion("anm_switch", "anim_switch_grenade_off", /*FALSE*/ TRUE, this, eSwitch); //AVO: fix fast anim switch
SwitchState(eSwitch);
}

void CWeaponMagazinedWGrenade::PlayAnimBore()
Expand Down
Loading