[HL25] Backport changes to RPG
One exception: ITEM_FLAG_NOAUTOSWITCHTO has not been set to flags due to differences between Updated and HL25's weapon switch code.
This commit is contained in:
parent
450c27de55
commit
9b9d6c3b0b
3 changed files with 53 additions and 14 deletions
61
dlls/rpg.cpp
61
dlls/rpg.cpp
|
@ -86,10 +86,10 @@ LINK_ENTITY_TO_CLASS(rpg_rocket, CRpgRocket);
|
|||
|
||||
CRpgRocket::~CRpgRocket()
|
||||
{
|
||||
if (m_pLauncher)
|
||||
if (m_hLauncher)
|
||||
{
|
||||
// my launcher is still around, tell it I'm dead.
|
||||
static_cast<CRpg*>(static_cast<CBaseEntity*>(m_pLauncher))->m_cActiveRockets--;
|
||||
static_cast<CRpg*>(static_cast<CBaseEntity*>(m_hLauncher))->m_cActiveRockets--;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -103,7 +103,7 @@ CRpgRocket* CRpgRocket::CreateRpgRocket(Vector vecOrigin, Vector vecAngles, CBas
|
|||
pRocket->pev->angles = vecAngles;
|
||||
pRocket->Spawn();
|
||||
pRocket->SetTouch(&CRpgRocket::RocketTouch);
|
||||
pRocket->m_pLauncher = pLauncher; // remember what RPG fired me.
|
||||
pRocket->m_hLauncher = pLauncher; // remember what RPG fired me.
|
||||
pLauncher->m_cActiveRockets++; // register this missile as active for the launcher
|
||||
pRocket->pev->owner = pOwner->edict();
|
||||
|
||||
|
@ -191,6 +191,14 @@ void CRpgRocket::IgniteThink()
|
|||
}
|
||||
|
||||
|
||||
CRpg* CRpgRocket::GetLauncher()
|
||||
{
|
||||
if (!m_hLauncher)
|
||||
return NULL;
|
||||
|
||||
return (CRpg*)((CBaseEntity*)m_hLauncher);
|
||||
}
|
||||
|
||||
void CRpgRocket::FollowThink()
|
||||
{
|
||||
CBaseEntity* pOther = NULL;
|
||||
|
@ -207,8 +215,16 @@ void CRpgRocket::FollowThink()
|
|||
// Examine all entities within a reasonable radius
|
||||
while ((pOther = UTIL_FindEntityByClassname(pOther, "laser_spot")) != NULL)
|
||||
{
|
||||
UTIL_TraceLine(pev->origin, pOther->pev->origin, dont_ignore_monsters, ENT(pev), &tr);
|
||||
// ALERT( at_console, "%f\n", tr.flFraction );
|
||||
Vector vSpotLocation = pOther->pev->origin;
|
||||
|
||||
/*if (UTIL_PointContents(vSpotLocation) == CONTENTS_SKY)
|
||||
{
|
||||
ALERT(at_console, "laser spot is in the sky...\n");
|
||||
}*/
|
||||
|
||||
UTIL_TraceLine(pev->origin, vSpotLocation, dont_ignore_monsters, ENT(pev), &tr);
|
||||
//ALERT(at_console, "fraction: %f\n", tr.flFraction);
|
||||
|
||||
if (tr.flFraction >= 0.90)
|
||||
{
|
||||
vecDir = pOther->pev->origin - pev->origin;
|
||||
|
@ -260,7 +276,27 @@ void CRpgRocket::FollowThink()
|
|||
Detonate();
|
||||
}
|
||||
}
|
||||
// ALERT( at_console, "%.0f\n", flSpeed );
|
||||
|
||||
if (GetLauncher())
|
||||
{
|
||||
float flDistance = (pev->origin - GetLauncher()->pev->origin).Length();
|
||||
|
||||
// if we've travelled more than max distance the player can send a spot, stop tracking the original launcher (allow it to reload)
|
||||
if (flDistance > 8192.0f || gpGlobals->time - m_flIgniteTime > 6.0f)
|
||||
{
|
||||
// ALERT(at_console, "RPG too far (%f)!\n", flDistance);
|
||||
GetLauncher()->m_cActiveRockets--;
|
||||
m_hLauncher = NULL;
|
||||
}
|
||||
|
||||
//ALERT(at_console, "%.0f, m_pLauncher: %u, flDistance: %f\n", flSpeed, GetLauncher(), flDistance);
|
||||
}
|
||||
|
||||
if ((UTIL_PointContents(pev->origin) == CONTENTS_SKY))
|
||||
{
|
||||
//ALERT( at_console, "Rocket is in the sky, detonating...\n");
|
||||
Detonate();
|
||||
}
|
||||
|
||||
pev->nextthink = gpGlobals->time + 0.1;
|
||||
}
|
||||
|
@ -270,6 +306,8 @@ void CRpgRocket::FollowThink()
|
|||
|
||||
void CRpg::Reload()
|
||||
{
|
||||
//ALERT(at_console, "RPG Reload, m_cActiveRockets: %d, m_fSpotActive: %d\n", m_cActiveRockets, m_fSpotActive);
|
||||
|
||||
if (m_iClip == 1)
|
||||
{
|
||||
// don't bother with any of this if don't need to reload.
|
||||
|
@ -293,6 +331,8 @@ void CRpg::Reload()
|
|||
|
||||
if (0 != m_cActiveRockets && m_fSpotActive)
|
||||
{
|
||||
//ALERT(at_console, "RPG reload failed, m_cActiveRockets: %d, m_fSpotActive: %d\n", m_cActiveRockets, m_fSpotActive);
|
||||
|
||||
// no reloading when there are active missiles tracking the designator.
|
||||
// ward off future autoreload attempts by setting next attack time into the future for a bit.
|
||||
return;
|
||||
|
@ -453,6 +493,8 @@ void CRpg::PrimaryAttack()
|
|||
|
||||
m_flNextPrimaryAttack = GetNextAttackDelay(1.5);
|
||||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 1.5;
|
||||
|
||||
ResetEmptySound();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -480,12 +522,6 @@ void CRpg::SecondaryAttack()
|
|||
|
||||
void CRpg::WeaponIdle()
|
||||
{
|
||||
// Reset when the player lets go of the trigger.
|
||||
if ((m_pPlayer->pev->button & (IN_ATTACK | IN_ATTACK2)) == 0)
|
||||
{
|
||||
ResetEmptySound();
|
||||
}
|
||||
|
||||
UpdateSpot();
|
||||
|
||||
if (m_flTimeWeaponIdle > UTIL_WeaponTimeBase())
|
||||
|
@ -514,6 +550,7 @@ void CRpg::WeaponIdle()
|
|||
m_flTimeWeaponIdle = UTIL_WeaponTimeBase() + 6.1;
|
||||
}
|
||||
|
||||
ResetEmptySound();
|
||||
SendWeaponAnim(iAnim);
|
||||
}
|
||||
else
|
||||
|
|
|
@ -1393,7 +1393,7 @@ IMPLEMENT_SAVERESTORE(CRpg, CBasePlayerWeapon);
|
|||
TYPEDESCRIPTION CRpgRocket::m_SaveData[] =
|
||||
{
|
||||
DEFINE_FIELD(CRpgRocket, m_flIgniteTime, FIELD_TIME),
|
||||
DEFINE_FIELD(CRpgRocket, m_pLauncher, FIELD_EHANDLE),
|
||||
DEFINE_FIELD(CRpgRocket, m_hLauncher, FIELD_EHANDLE),
|
||||
};
|
||||
IMPLEMENT_SAVERESTORE(CRpgRocket, CGrenade);
|
||||
|
||||
|
|
|
@ -831,9 +831,11 @@ public:
|
|||
void EXPORT RocketTouch(CBaseEntity* pOther);
|
||||
static CRpgRocket* CreateRpgRocket(Vector vecOrigin, Vector vecAngles, CBaseEntity* pOwner, CRpg* pLauncher);
|
||||
|
||||
CRpg* GetLauncher();
|
||||
|
||||
int m_iTrail;
|
||||
float m_flIgniteTime;
|
||||
EHANDLE m_pLauncher; // handle back to the launcher that fired me.
|
||||
EHANDLE m_hLauncher; // handle back to the launcher that fired me.
|
||||
};
|
||||
|
||||
#define GAUSS_PRIMARY_CHARGE_VOLUME 256 // how loud gauss is while charging
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue