Mine attack animation fix

- also added commented code for using the placement animation, but it doesn't look good and is buggy.
This commit is contained in:
pierow 2024-04-29 17:21:50 -04:00
parent f191b913d3
commit fb214971d5
5 changed files with 62 additions and 1 deletions

0
main/events/Mine.sc Normal file
View file

View file

@ -229,6 +229,7 @@ AVH_DECLARE_EVENT(SonicGun)
AVH_DECLARE_EVENT(HeavyMachineGun)
AVH_DECLARE_EVENT(GrenadeGun)
AVH_DECLARE_EVENT(Grenade)
AVH_DECLARE_EVENT(Mine)
// Alien weapon events
AVH_DECLARE_EVENT(SpitGun)
@ -324,6 +325,7 @@ void Game_HookEvents( void )
gEngfuncs.pfnHookEvent( kHMGEventName, EV_HeavyMachineGun );
gEngfuncs.pfnHookEvent( kGGEventName, EV_GrenadeGun );
gEngfuncs.pfnHookEvent( kGREventName, EV_Grenade );
gEngfuncs.pfnHookEvent( kMineEventName, EV_Mine );
// Alien weapon events
gEngfuncs.pfnHookEvent( kSpitGEventName, EV_SpitGun );
@ -1273,6 +1275,16 @@ void EV_Grenade(struct event_args_s* inArgs)
// }
}
void EV_Mine(struct event_args_s* inArgs)
{
if (EV_IsLocal(inArgs->entindex))
{
int theAnimation = max(inArgs->iparam2, 0);
gEngfuncs.pEventAPI->EV_WeaponAnimation(theAnimation, 2);
}
}
char *EV_HLDM_DamageDecal( physent_t *pe );
void CreateDecal(struct pmtrace_s* inTrace)
@ -3614,6 +3626,7 @@ void EV_WeaponAnimation(struct event_args_s* inArgs)
{
int theAnimation = max(inArgs->iparam2, 0);
// 2024 - Set this here to be checked in weapons think later to force animations if needed since event playback doesn't always work.
gEngfuncs.Con_Printf("setanim %d\n", theAnimation);
HUD_SetWeaponAnim(theAnimation);
gEngfuncs.pEventAPI->EV_WeaponAnimation(theAnimation, 2);
}

View file

@ -136,6 +136,7 @@ const float kMineROF = 1.0f;
#define kTripmineActivateSound "weapons/mine_activate.wav"
#define kTripmineChargeSound "weapons/mine_charge.wav"
#define kTripmineStepOnSound "weapons/mine_step.wav"
#define kMineEventName "events/Mine.sc"
#define kMineMinSize Vector( -8, -8, 0)
#define kMineMaxSize Vector(8, 8, 2)

View file

@ -530,14 +530,20 @@ public:
virtual void Precache(void);
//virtual void PrimaryAttack(void);
virtual bool Resupply();
//virtual BOOL ShouldWeaponIdle(void);
virtual void Spawn();
virtual bool UsesAmmo(void) const;
virtual BOOL UseDecrement(void);
//virtual void WeaponIdle(void);
protected:
virtual void FireProjectiles(void);

View file

@ -120,6 +120,8 @@ int AvHMine::GetShootAnimation() const
{
// Return deploy animation for now, this should play fire animation, then a little later, play the deploy animation
return 2;
//// Attack animation test.
//return 4;
}
void AvHMine::Holster(int skiplocal)
@ -307,14 +309,34 @@ void AvHMine::Precache()
UTIL_PrecacheOther(kwsDeployedMine);
this->mEvent = PRECACHE_EVENT(1, kWeaponAnimationEvent);
this->mEvent = PRECACHE_EVENT(1, kMineEventName);
}
//// Attack animation test.
//void AvHMine::PrimaryAttack(void)
//{
// AvHMarineWeapon::PrimaryAttack();
//
// // This makes the predicted clip size go down if you can't place a mine for some reason.
// this->m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 0.666666f;
//
// if (this->m_flTimeWeaponIdle < 0)
// {
// this->m_flTimeWeaponIdle = 0.666666f;
// }
//}
bool AvHMine::Resupply()
{
return false;
}
//////// Attack animation test.
//BOOL AvHMine::ShouldWeaponIdle(void)
//{
// return TRUE;
//}
void AvHMine::Spawn()
{
this->Precache();
@ -353,3 +375,22 @@ BOOL AvHMine::UseDecrement(void)
return true;
}
//// Attack animation test.
//void AvHMine::WeaponIdle(void)
//{
// //if (this->m_flTimeWeaponIdle <= UTIL_WeaponTimeBase() && this->m_flNextPrimaryAttack > UTIL_WeaponTimeBase())
// if (this->m_flNextPrimaryAttack > UTIL_WeaponTimeBase() && this->m_flNextPrimaryAttack < UTIL_WeaponTimeBase() + 0.333333f)
// {
// this->SendWeaponAnim(2);
// //m_pPlayer->m_flNextAttack
// this->m_pPlayer->SetAnimation(PLAYER_IDLE);
// this->SetNextIdle();
// ALERT(at_console, "mine special idle\n");
// }
// else
// {
// ALERT(at_console, "mine normal idle timeidle:%f nextprimatk:%f\n", this->m_flTimeWeaponIdle, this->m_flNextPrimaryAttack);
// AvHMarineWeapon::WeaponIdle();
// }
//}