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] Add HUD animation speed parameter support in ltx files. #1763

Merged
merged 4 commits into from
Feb 5, 2025

Conversation

Neloreck
Copy link
Contributor

@Neloreck Neloreck commented Jan 5, 2025

Still testing it while integrating some weapons from CoC/anomaly. Without it game crashes on assertions / has de-synced sounds.

Changes

  • Adding support of third parameter in weapon hud sections, CoC and anomaly uses it everywhere

Examples

anm_idle = protecta_idle
anm_idle_aim = protecta_aim
anm_idle_aim_moving = protecta_move, idle, 0.75
anm_idle_aim_moving_crouch = protecta_move, idle, 0.7
anm_idle_moving = protecta_move
anm_idle_sprint = protecta_sprint
anm_idle_moving_crouch_w_gl_aim = sg550_crouch_w_gl
anm_idle_moving_g = sg550_move_g
anm_idle_moving_g_aim = sg550_move_g, idle, 0.75
anm_idle_moving_w_gl = sg550_move_w_gl
anm_idle_moving_w_gl_aim = sg550_move_w_gl, idle, 0.75

Links

https://github.com/revolucas/CoC-Xray/blob/551dfba681928b7a1292949cb2156c24174d96d6/src/xrGame/player_hud.cpp#L77
https://github.com/revolucas/CoC-Xray/blob/551dfba681928b7a1292949cb2156c24174d96d6/src/xrGame/player_hud.cpp#L352

@Xottab-DUTY Xottab-DUTY requested a review from yohjimane January 5, 2025 22:52
src/xrGame/player_hud.cpp Outdated Show resolved Hide resolved
}
else
{
R_ASSERT2(_GetItemCount(anm.c_str()) == 2, anm.c_str());
R_ASSERT2(_GetItemCount(anm.c_str()) <= 3, anm.c_str());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The code below requires at least one parameter, and uses additional two.
It's more logical to use this condition:

Suggested change
R_ASSERT2(_GetItemCount(anm.c_str()) <= 3, anm.c_str());
R_ASSERT2(_GetItemCount(anm.c_str()) > 0, anm.c_str());

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logics before:
1 parameter - use name as base and additional parameter
2+ parameters - assert it is only 2 params and read both

Logics after:
1 parameter - same as before
2+ parameters - make sure it is either 2 or 3 parameters, if someone leaves empty space and wants to only add animation speed


Seems like:
1 - adding < 0 assertion and storing count as variant makes sense
2 - probably I should add trimming for pm.m_additional_name strlen check? Or parser of comma separated values already does it? Will need to check it

src/xrGame/player_hud.cpp Outdated Show resolved Hide resolved
@@ -414,8 +418,6 @@ void attachable_hud_item::reload_measures()

u32 attachable_hud_item::anim_play(const shared_str& anm_name_b, BOOL bMixIn, const CMotionDef*& md, u8& rnd_idx)
{
const float speed = CalcMotionSpeed(anm_name_b);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we reuse this somehow? We still support multiplayer.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This util used for two different classes. Can add one more param to use as base and keep it pure function or copy-paste as separate methods/util functions. Sounds like first variant is better

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Updated util / excluded non-singleplayer games from animation speed calculations.

@Xottab-DUTY Xottab-DUTY added Enhancement Modmaker Experience Modmaker experience with OpenXRay Mods This issue is related to mods. labels Jan 5, 2025
@Neloreck Neloreck requested a review from Xottab-DUTY January 8, 2025 19:33
@Neloreck Neloreck force-pushed the coc-animation-speed-parameter branch from 803f745 to ba4277f Compare January 11, 2025 23:36
@Neloreck Neloreck force-pushed the coc-animation-speed-parameter branch from ba4277f to ebb3ee7 Compare January 19, 2025 01:46
@Xottab-DUTY Xottab-DUTY merged commit 8bf122b into OpenXRay:dev Feb 5, 2025
33 of 34 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Modmaker Experience Modmaker experience with OpenXRay Mods This issue is related to mods.
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants