NSProjectile: made hitscans overridable

NSWeapon: Allow override of Weapon Fire/Release events with FiredWeapon(fireInfo), ReleasedWeapon(string)
This commit is contained in:
Marco Cawthorne 2024-07-24 18:50:46 -07:00
parent ff1681901f
commit 52af82b985
Signed by: eukara
GPG key ID: CE2032F0A2882A22
6 changed files with 27 additions and 56 deletions

1
.gitignore vendored
View file

@ -97,4 +97,3 @@ ts/
valve/
wastes/
zp/

View file

@ -274,10 +274,10 @@ fteqcc:
# stock engine
fteqw:
cd ThirdParty/fteqw/engine && $(MAKE) makelibs ARCH=stock-x86_64
cp $(GAME)/engine.h ./ThirdParty/fteqw/engine/common/config_$(GAME).h
cd ThirdParty/fteqw/engine && $(MAKE) m-dbg FTE_CONFIG=fteqw ARCH=stock-x86_64
install -m 0777 ./ThirdParty/fteqw/engine/debug/fteqw ./fteqw
cd ThirdParty/fteqw/engine && $(MAKE) makelibs ARCH=x86_64
cd ThirdParty/fteqw/engine && $(MAKE) $(ENGINE_CLBUILD) ARCH=x86_64
install -m 0777 ./ThirdParty/fteqw/engine/debug/fteqw ./
fteqwglqw64.exe:
cd ThirdParty/fteqw/engine && $(MAKE) makelibs FTE_TARGET=win64
cd ThirdParty/fteqw/engine && $(MAKE) m-rel FTE_TARGET=win64

View file

@ -114,8 +114,6 @@ private:
float m_flDamage;
string m_strDecalGroup;
float m_flRange;
int m_iTotalPenetrations;
float m_flMaxThickness;
/* Nuclide additions */
bool m_bStickToWorld;
@ -168,7 +166,7 @@ public:
nonvirtual void _FuseEnded(void);
nonvirtual void _Explode(void);
nonvirtual void _LaunchHitscan(vector, vector, float);
virtual void _LaunchHitscan(vector, vector, float);
/* launch the projectile into the world */
virtual void Launch(vector, vector, float, float, float);

View file

@ -769,31 +769,9 @@ NSProjectile::_LaunchHitscan(vector startPos, vector launchDir, float dmgMultipl
vecDir = v_forward;
}
#ifndef BULLETPATTERNS
vecDir += random(-1,1) * m_vecSpread[0] * v_right;
vecDir += random(-1,1) * m_vecSpread[1] * v_up;
#else
/* FOR NOW Monsters will not be able to do spread like players if patterns are enabled */
if (!(owner.flags & FL_CLIENT)) {
vecDir += random(-1,1) * m_vecSpread[0] * v_right;
vecDir += random(-1,1) * m_vecSpread[1] * v_up;
} else {
player pl = (player) owner;
/* weapons have already applied their multiplier... so attempt this */
int multiplier = pl.cs_shotmultiplier - m_iShots;
float frand = (multiplier / 6);
/* shoddy attempt at spray patterns */
if (frand < 1)
frand = frand;
else if (frand <= 2)
frand = 2 - (frand * 1.5);
vecDir += frand * m_vecSpread[0] * v_right;
vecDir += (m_vecSpread[1] * v_up) * 2;
}
#endif
_FireSingle(startPos, vecDir, m_flDamage, m_flRange);
m_iShots--;
}
@ -940,30 +918,6 @@ NSProjectile::_FireSingle(vector vecPos, vector vecAngles, float flDamage, float
m_iMultiValue += flDamage;
}
}
#ifdef BULLETPENETRATION
if (m_iTotalPenetrations > 0) {
float cont;
#if 0
if (!(trace_surfaceflagsi & SURF_PENETRATE))
m_iTotalPenetrations -= 1;
#endif
/* check if this wall is 6 units thick... */
if (m_iTotalPenetrations > 0) {
cont = pointcontents(endPos + v_forward * 5);
if (cont == CONTENT_SOLID)
m_iTotalPenetrations -= 1; /* deduct 1 penetration power */
}
cont = pointcontents(endPos + v_forward * m_flMaxThickness);
if (cont == CONTENT_EMPTY)
_FireSingle(endPos + (v_forward * 2), vecAngles, flDamage / 2, flRange);
}
#endif
}
void

View file

@ -137,6 +137,11 @@ public:
virtual bool CanIdle(void);
virtual bool UseAmmo(string);
/** Overridable: Called when the weapon has been fired. */
virtual void FiredWeapon(string);
/** Overridable: Called when the weapon has been released. */
virtual void ReleasedWeapon(string);
/** Overridable: Called when we've switched to this weapon successfully. */
virtual void SwitchedToWeapon(void);
/** Overridable: Called when we've switched from this weapon successfully. */

View file

@ -731,6 +731,20 @@ NSWeapon::DetonateDef(string defName)
return (success);
}
void
NSWeapon::FiredWeapon(string fireInfo)
{
NSClientPlayer ourOwner = (NSClientPlayer)GetOwner();
ourOwner.AttackByDef(fireInfo, false);
}
void
NSWeapon::ReleasedWeapon(string fireInfo)
{
NSClientPlayer ourOwner = (NSClientPlayer)GetOwner();
ourOwner.AttackByDef(fireInfo, true);
}
void
NSWeapon::Attack(string fireInfo)
{
@ -858,10 +872,11 @@ NSWeapon::Attack(string fireInfo)
#ifdef SERVER
v_angle = input_angles;
ourOwner.AttackByDef(fireInfo, false);
ourOwner.StartSoundDef(m_fiSndFire, CHAN_WEAPON, true);
#endif
FiredWeapon(fireInfo);
if (m_iClipSize > 0 && m_iClip == 0)
shotAnim = GetSubDefAct(fireInfo, "actFireLast");
@ -1091,7 +1106,7 @@ NSWeapon::Release(void)
}
}
ourOwner.AttackByDef(m_strLastFireInfo, true);
ReleasedWeapon(m_strLastFireInfo);
m_fiWillRelease = false;
SetWeaponFrame(idleAnim);
SetAttackNext(1.0f);