Skip to content

Commit

Permalink
Add motion suffix generator
Browse files Browse the repository at this point in the history
  • Loading branch information
Shtrecker committed Jun 6, 2024
1 parent 22da859 commit 6b60686
Show file tree
Hide file tree
Showing 31 changed files with 114 additions and 535 deletions.
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_abakan.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ anm_show_g = abakan_draw_w_gl ;abakan_draw_gre
anm_hide_g = abakan_holster_w_gl ;abakan_holster_grenade
anm_idle_g = abakan_idle_w_gl ;abakan_idle_grenade
anm_reload_g = abakan_reload_grenade
anm_idle_g_aim = abakan_idle_aim_w_gl ;abakan_idle_grenade
anm_idle_aim_g = abakan_idle_aim_w_gl ;abakan_idle_grenade
anm_shots_g = abakan_shoot_grenade
anm_idle_sprint_g = abakan_idle_sprint_w_gl ;abakan_idle_sprint_grenade
anm_idle_moving_g = abakan_idle_moving_w_gl ;abakan_idle_moving_grenade
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_ak74.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ anm_show_g = ak74_draw_w_gl ;abakan_draw_grenade
anm_hide_g = ak74_holster_w_gl ;abakan_holster_grenade
anm_idle_g = ak74_idle_w_gl ;abakan_idle_grenade
anm_reload_g = ak74_reload_grenade
anm_idle_g_aim = ak74_idle_aim_w_gl ;abakan_idle_grenade
anm_idle_aim_g = ak74_idle_aim_w_gl ;abakan_idle_grenade
anm_shots_g = ak74_shoot_grenade
anm_idle_sprint_g = ak74_idle_sprint_w_gl ;abakan_idle_sprint_grenade
anm_idle_moving_g = ak74_idle_moving_w_gl ;abakan_idle_moving_grenade
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_ak74u.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ anm_bore = ak74u_idle_bore
;anm_hide_g = ak74_holster_w_gl ;abakan_holster_grenade
;anm_idle_g = ak74_idle_w_gl ;abakan_idle_grenade
;anm_reload_g = ak74_reload_grenade
;anm_idle_g_aim = ak74_idle_aim_w_gl ;abakan_idle_grenade
;anm_idle_aim_g = ak74_idle_aim_w_gl ;abakan_idle_grenade
;anm_shots_g = ak74_shoot_grenade
;anm_idle_sprint_g = ak74_idle_sprint_w_gl ;abakan_idle_sprint_grenade
;anm_idle_moving_g = ak74_idle_moving_w_gl ;abakan_idle_moving_grenade
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_beretta.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ anm_hide_empty = beretta_holster, beretta_opened
anm_idle = beretta_idle
anm_idle_empty = beretta_idle, beretta_opened
anm_shots = beretta_shoot
anm_shot_l = beretta_shoot, beretta_open
anm_shots_l = beretta_shoot, beretta_open
anm_idle_aim = beretta_idle_aim
anm_idle_aim_empty = beretta_idle_aim, beretta_opened
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_colt1911.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ anm_idle = colt1911_idle
anm_idle_empty = colt1911_idle, colt1911_opened
anm_shots = colt1911_shoot
anm_shot_l = colt1911_shoot, colt1911_open
anm_shots_l = colt1911_shoot, colt1911_open
anm_idle_aim = colt1911_idle_aim
anm_idle_aim_empty = colt1911_idle_aim, colt1911_opened
anm_reload = colt1911_reload
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_desert_eagle.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ anm_idle = desert_eagle_idle
anm_idle_empty = desert_eagle_idle, desert_eagle_opened
anm_shots = desert_eagle_shoot
anm_shot_l = desert_eagle_shoot, desert_eagle_open
anm_shots_l = desert_eagle_shoot, desert_eagle_open
anm_idle_aim = desert_eagle_idle_aim
anm_idle_aim_empty = desert_eagle_idle_aim, desert_eagle_opened
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_fn2000.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -267,7 +267,7 @@ anm_show_g = fn_2000_draw_gl
anm_hide_g = fn_2000_holster_gl
anm_idle_g = fn_2000_idle_gl
anm_reload_g = fn_2000_reload_gl
anm_idle_g_aim = fn_2000_idle_aim_gl
anm_idle_aim_g = fn_2000_idle_aim_gl
anm_shots_g = fn_2000_shoot_gl
anm_idle_sprint_g = fn_2000_idle_sprint_gl
anm_idle_moving_g = fn_2000_idle_moving_gl
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_fort.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ anm_idle = fort_idle
anm_idle_empty = fort_idle, fort_opened
anm_shots = fort_shoot
anm_shot_l = fort_shoot, fort_open
anm_shots_l = fort_shoot, fort_open
anm_idle_aim = fort_idle_aim
anm_idle_aim_empty = fort_idle_aim, fort_opened
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_g36.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ anm_show_g = g36_draw_grenade
anm_hide_g = g36_holster_grenade
anm_idle_g = g36_idle_grenade
anm_reload_g = g36_reload_grenade
anm_idle_g_aim = g36_idle_grenade
anm_idle_aim_g = g36_idle_grenade
anm_shots_g = g36_shoot_grenade
anm_idle_sprint_g = g36_idle_sprint_grenade
anm_idle_moving_g = g36_idle_moving_grenade
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_groza.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ anm_show_g = groza_draw_grenade
anm_hide_g = groza_holster_grenade
anm_idle_g = groza_idle_grenade
anm_reload_g = groza_reload_grenade
anm_idle_g_aim = groza_idle_aim_grenade
anm_idle_aim_g = groza_idle_aim_grenade
anm_shots_g = groza_shoot_grenade
anm_idle_sprint_g = groza_idle_sprint_grenade
anm_idle_moving_g = groza_idle_moving_grenade
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_hpsa.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ anm_idle = hpsa_idle
anm_idle_empty = hpsa_idle, hpsa_opened
anm_shots = hpsa_shoot
anm_shot_l = hpsa_shoot, hpsa_open
anm_shots_l = hpsa_shoot, hpsa_open
anm_idle_aim = hpsa_idle_aim
anm_idle_aim_empty = hpsa_idle_aim, hpsa_opened
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_l85.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ anm_show_g = l85_draw_grenade
anm_hide_g = l85_holster_grenade
anm_idle_g = l85_idle_grenade
anm_reload_g = l85_reload_grenade
anm_idle_g_aim = l85_idle_grenade
anm_idle_aim_g = l85_idle_grenade
anm_shots_g = l85_shoot_grenade
anm_idle_sprint_g = l85_idle_sprint_grenade
anm_idle_moving_g = l85_idle_moving_grenade
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_lr300.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,7 @@ anm_show_g = lr300_draw_grenade ;lr300_draw_grenade
anm_hide_g = lr300_holster_grenade ;lr300_holster_grenade
anm_idle_g = lr300_idle_grenade ;lr300_idle_grenade
anm_reload_g = lr300_reload_grenade
anm_idle_g_aim = lr300_idle_grenade ;lr300_idle_grenade
anm_idle_aim_g = lr300_idle_grenade ;lr300_idle_grenade
anm_shots_g = lr300_shoot_grenade
anm_idle_sprint_g = lr300_idle_sprint_grenade ;lr300_idle_sprint_grenade
anm_idle_moving_g = lr300_idle_moving_grenade ;lr300_idle_moving_grenade
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_mp5.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ anm_bore = mp5_idle_bore
;anm_hide_g = mp5_holster_w_gl;mp5_holster_grenade
;anm_idle_g = mp5_idle_w_gl;mp5_idle_grenade
;anm_reload_g = mp5_reload_grenade
;anm_idle_g_aim = mp5_idle_aim_w_gl;mp5_idle_grenade
;anm_idle_aim_g = mp5_idle_aim_w_gl;mp5_idle_grenade
;anm_shots_g = mp5_shoot_grenade
;anm_idle_sprint_g = mp5_idle_sprint_w_gl;mp5_idle_sprint_grenade
;anm_idle_moving_g = mp5_idle_moving_w_gl;mp5_idle_moving_grenade
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_pb.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ anm_idle = pb_idle
anm_idle_empty = pb_idle, pb_opened
anm_shots = pb_shoot
anm_shot_l = pb_shoot, pb_open
anm_shots_l = pb_shoot, pb_open
anm_idle_aim = pb_idle_aim
anm_idle_aim_empty = pb_idle_aim, pb_opened
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_pm.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ anm_idle = pm_idle
anm_idle_empty = pm_idle, pm_opened
anm_shots = pm_shoot
anm_shot_l = pm_shoot, pm_open
anm_shots_l = pm_shoot, pm_open
anm_idle_aim = pm_idle_aim
anm_idle_aim_empty = pm_idle_aim, pm_opened
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_sig220.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ anm_idle = sig220_idle
anm_idle_empty = sig220_idle, sig220_opened
anm_shots = sig220_shoot
anm_shot_l = sig220_shoot, sig220_open
anm_shots_l = sig220_shoot, sig220_open
anm_idle_aim = sig220_idle_aim
anm_idle_aim_empty = sig220_idle_aim, sig220_opened
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_sig550.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ anm_show_g = sig550_draw_grenade
anm_hide_g = sig550_holster_grenade
anm_idle_g = sig550_idle_grenade
anm_reload_g = sig550_reload_grenade
anm_idle_g_aim = sig550_idle_grenade
anm_idle_aim_g = sig550_idle_grenade
anm_shots_g = sig550_shoot_grenade
anm_idle_sprint_g = sig550_idle_sprint_grenade
anm_idle_moving_g = sig550_idle_moving_grenade
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_usp45.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ anm_idle = usp45_idle
anm_idle_empty = usp45_idle, usp45_opened
anm_shots = usp45_shoot
anm_shot_l = usp45_shoot, usp45_open
anm_shots_l = usp45_shoot, usp45_open
anm_idle_aim = usp45_idle_aim
anm_idle_aim_empty = usp45_idle_aim, usp45_opened
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_vintorez.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ anm_bore = vintorez_idle_bore
;anm_hide_g = vintorez_holster_grenade
;anm_idle_g = vintorez_idle_grenade
;anm_reload_g = vintorez_reload_grenade
;anm_idle_g_aim = vintorez_idle_grenade
;anm_idle_aim_g = vintorez_idle_grenade
;anm_shots_g = vintorez_shoot_grenade
;anm_idle_sprint_g = vintorez_idle_sprint_grenade
;anm_idle_moving_g = vintorez_idle_moving_grenade
Expand Down
2 changes: 1 addition & 1 deletion gamedata/configs/weapons/w_walther.ltx
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ anm_idle = walter99_idle
anm_idle_empty = walter99_idle, walter99_opened
anm_shots = walter99_shoot
anm_shot_l = walter99_shoot, walter99_open
anm_shots_l = walter99_shoot, walter99_open
anm_idle_aim = walter99_idle_aim
anm_idle_aim_empty = walter99_idle_aim, walter99_opened
Expand Down
23 changes: 19 additions & 4 deletions src/xrGame/HudItem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,15 @@ void CHudItem::on_a_hud_attach()
}
}

u32 CHudItem::PlayHUDMotion(const shared_str& M, BOOL bMixIn, CHudItem* W, u32 state)
u32 CHudItem::PlayHUDMotion(const xr_string M, BOOL bMixIn, CHudItem* W, u32 state, bool need_suffix)
{
u32 anim_time = PlayHUDMotion_noCB(M, bMixIn);
if (anim_time>0)
xr_string new_name = M;

if (need_suffix)
NeedAddSuffix(new_name);

u32 anim_time = PlayHUDMotion_noCB(new_name.c_str(), bMixIn);
if (anim_time > 0)
{
m_bStopAtEndAnimIsRunning = true;
m_dwMotionStartTm = Device.dwTimeGlobal;
Expand All @@ -316,7 +321,6 @@ u32 CHudItem::PlayHUDMotion(const shared_str& M, BOOL bMixIn, CHudItem* W, u32
return anim_time;
}


u32 CHudItem::PlayHUDMotion_noCB(const shared_str& motion_name, BOOL bMixIn)
{
m_current_motion = motion_name;
Expand All @@ -340,6 +344,17 @@ u32 CHudItem::PlayHUDMotion_noCB(const shared_str& motion_name, BOOL bMixIn)
}
}

void CHudItem::AddSuffix(xr_string& M, const xr_string suffix, const xr_string test_suffix)
{
xr_string new_name = M + suffix;
xr_string test_name = new_name + test_suffix;

if (isHUDAnimationExist(new_name.c_str()))
M = new_name;
else if (isHUDAnimationExist(test_name.c_str()))
M = test_name;
}

void CHudItem::StopCurrentAnimWithoutCallback()
{
m_dwMotionStartTm = 0;
Expand Down
4 changes: 3 additions & 1 deletion src/xrGame/HudItem.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,9 @@ class CHudItem :public CHUDState

virtual void UpdateXForm () = 0;

u32 PlayHUDMotion (const shared_str& M, BOOL bMixIn, CHudItem* W, u32 state);
u32 PlayHUDMotion (const xr_string M, BOOL bMixIn, CHudItem* W, u32 state, bool need_suffix = true);
virtual void NeedAddSuffix (xr_string& M) {}
void AddSuffix (xr_string& M, const xr_string suffix, const xr_string test_suffix = "");
u32 PlayHUDMotion_noCB (const shared_str& M, BOOL bMixIn);
void StopCurrentAnimWithoutCallback();

Expand Down
58 changes: 26 additions & 32 deletions src/xrGame/WeaponMagazined.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ CWeaponMagazined::CWeaponMagazined(ESoundTypes eSoundType) : CWeapon()
m_eSoundShot = ESoundTypes(SOUND_TYPE_WEAPON_SHOOTING | eSoundType);
m_eSoundEmptyClick = ESoundTypes(SOUND_TYPE_WEAPON_EMPTY_CLICKING | eSoundType);
m_eSoundReload = ESoundTypes(SOUND_TYPE_WEAPON_RECHARGING | eSoundType);
m_eSoundClose = ESoundTypes(SOUND_TYPE_WEAPON_RECHARGING | eSoundType);

m_sSndShotCurrent = NULL;
m_sSilencerFlameParticles = m_sSilencerSmokeParticles = NULL;
Expand All @@ -49,7 +50,6 @@ CWeaponMagazined::CWeaponMagazined(ESoundTypes eSoundType) : CWeapon()
m_iShotNum = 0;
m_iQueueSize = WEAPON_ININITE_QUEUE;
m_bLockType = false;
bMisfireReload = false;
}

CWeaponMagazined::~CWeaponMagazined()
Expand Down Expand Up @@ -95,6 +95,9 @@ void CWeaponMagazined::Load (LPCSTR section)
if (WeaponSoundExist(section, "snd_reload_misfire") && isHUDAnimationExist("anm_reload_misfire"))
m_sounds.LoadSound(section, "snd_reload_misfire", "sndReloadMis", true, m_eSoundReload);

if (WeaponSoundExist(section, "snd_slose"))
m_sounds.LoadSound(section, "snd_close", "sndClose", false, m_eSoundClose);

m_sSndShotCurrent = "sndShot";

//звуки и партиклы глушителя, еслит такой есть
Expand Down Expand Up @@ -646,11 +649,8 @@ void CWeaponMagazined::OnAnimationEnd(u32 state)
bAmmotypeKeyPressed = false;
}

if (bMisfireReload)
{
if (IsMisfire() && isHUDAnimationExist("anm_reload_misfire"))
bMisfire = false;
bMisfireReload = false;
}
else
ReloadMagazine();
SwitchState(eIdle);
Expand All @@ -669,6 +669,21 @@ void CWeaponMagazined::OnAnimationEnd(u32 state)
inherited::OnAnimationEnd(state);
}

void CWeaponMagazined::NeedAddSuffix(xr_string& M)
{
if (IsZoomed())
AddSuffix(M, "_aim");

if (IsMisfire())
AddSuffix(M, "_misfire");

if (iAmmoElapsed == 0)
AddSuffix(M, "_empty");

if (iAmmoElapsed == 1)
AddSuffix(M, "_l");
}

void CWeaponMagazined::switch2_Idle ()
{
SetPending (FALSE);
Expand Down Expand Up @@ -742,7 +757,7 @@ void CWeaponMagazined::switch2_Empty()

void CWeaponMagazined::PlayReloadSound()
{
if (m_sounds.FindSoundItem("sndReloadMis", false) && isHUDAnimationExist("anm_reload_misfire") && IsMisfire() && bMisfireReload)
if (m_sounds.FindSoundItem("sndReloadMis", false) && isHUDAnimationExist("anm_reload_misfire") && IsMisfire())
PlaySound("sndReloadMis", get_LastFP());
else if (m_sounds.FindSoundItem("sndReloadEmpty", false) && isHUDAnimationExist("anm_reload_empty") && iAmmoElapsed == 0)
PlaySound("sndReloadEmpty", get_LastFP());
Expand All @@ -763,7 +778,10 @@ void CWeaponMagazined::switch2_Hiding()
OnZoomOut();
CWeapon::FireEnd();

PlaySound ("sndHide",get_LastFP());
if (m_sounds.FindSoundItem("sndClose", false) && iAmmoElapsed == 0)
PlaySound("sndClose", get_LastFP());
else
PlaySound("sndHide", get_LastFP());

PlayAnimHide ();
SetPending (TRUE);
Expand Down Expand Up @@ -1088,31 +1106,7 @@ void CWeaponMagazined::PlayAnimHide()
void CWeaponMagazined::PlayAnimReload()
{
VERIFY(GetState() == eReload);

if (isHUDAnimationExist("anm_reload_misfire") && IsMisfire())
{
PlayHUDMotion("anm_reload_misfire", TRUE, this, GetState());
bMisfireReload = true;
}
else if (isHUDAnimationExist("anm_reload_empty") && iAmmoElapsed == 0)
PlayHUDMotion("anm_reload_empty", TRUE, this, GetState());
else
PlayHUDMotion("anm_reload", TRUE, this, GetState());
}

void CWeaponMagazined::PlayAnimAim()
{
PlayHUDMotion("anm_idle_aim", TRUE, NULL, GetState());
}

void CWeaponMagazined::PlayAnimIdle()
{
VERIFY(GetState()==eIdle);
if(IsZoomed())
{
PlayAnimAim();
}else
inherited::PlayAnimIdle();
PlayHUDMotion("anm_reload", TRUE, this, GetState());
}

void CWeaponMagazined::PlayAnimShoot()
Expand Down
6 changes: 2 additions & 4 deletions src/xrGame/WeaponMagazined.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ class CWeaponMagazined: public CWeapon
ESoundTypes m_eSoundShot;
ESoundTypes m_eSoundEmptyClick;
ESoundTypes m_eSoundReload;
ESoundTypes m_eSoundClose;
// General
//кадр момента пересчета UpdateSounds
u32 dwUpdateSounds_Frame;
Expand Down Expand Up @@ -94,8 +95,6 @@ class CWeaponMagazined: public CWeapon

virtual void GetBriefInfo (xr_string& str_name, xr_string& icon_sect_name, xr_string& str_count, string16& fire_mode);

bool bMisfireReload;

public:
virtual bool SwitchMode ();
virtual bool SingleShotMode () {return 1 == m_iQueueSize;}
Expand Down Expand Up @@ -144,15 +143,14 @@ class CWeaponMagazined: public CWeapon

protected:
virtual bool AllowFireWhileWorking() {return false;}
virtual void NeedAddSuffix(xr_string& M);

//виртуальные функции для проигрывания анимации HUD
virtual void PlayAnimShow ();
virtual void PlayAnimHide ();
virtual void PlayAnimReload ();
virtual void PlayAnimIdle ();
virtual void PlayAnimShoot ();
virtual void PlayReloadSound ();
virtual void PlayAnimAim ();

virtual int ShotsFired () { return m_iShotNum; }
virtual float GetWeaponDeterioration ();
Expand Down
Loading

0 comments on commit 6b60686

Please sign in to comment.