NSMonster: Add MeleeMaxDistance() and MeleeCondition(), so classes can

easily override condition and distance of their melee attacks.
This commit is contained in:
Marco Cawthorne 2022-01-24 12:27:15 -08:00
parent f1ab2201fb
commit 7963b11a7d
Signed by: eukara
GPG key ID: C196CD8BA993248A
5 changed files with 20 additions and 6 deletions

View file

@ -441,6 +441,7 @@ func_button::Respawn(void)
m_vecPos2 = (m_vecPos1 + m_vecMoveDir * (fabs(m_vecMoveDir * size) - m_flLip));
}
m_iValue = 0;
m_iState = STATE_LOWERED;
}

View file

@ -94,7 +94,7 @@ multisource::QueryTargets(void)
} else {
dprint(" is ^2ON^7, name: ");
}
dprint(tTemp.targetname);
dprint(tTemp.target);
dprint("\n");
} else {
/* exit out immediately as there's no point unless in-dev */

View file

@ -202,9 +202,6 @@ scripted_sequence::RunOnEntity(entity targ)
f.m_vecSequenceAngle = angles;
f.m_iSequenceFlags = spawnflags;
if (spawnflags & SSFL_REPEATABLE)
f.SetOrigin(origin);
if (m_iMove == SS_NO) {
dprint("\tType: SS_NO\n");
} else if (m_iMove == SS_WALK) {

View file

@ -245,6 +245,9 @@ class NSMonster:NSSurfacePropEntity
virtual int(void) AttackMelee;
virtual int(void) AttackRanged;
virtual float(void) MeleeMaxDistance;
virtual int(void) MeleeCondition;
/* sequences */
virtual void(void) FreeState;
virtual void(void) FreeStateMoved;

View file

@ -125,6 +125,19 @@ NSMonster::IsFriend(int al)
return (0);
}
/* The maximum distance to which we should attempt an attack */
float
NSMonster::MeleeMaxDistance(void)
{
return 96;
}
/* Whether or not we should attempt a melee attack */
int
NSMonster::MeleeCondition(void)
{
return (vlen(origin - m_eEnemy.origin) < MeleeMaxDistance()) ? TRUE : FALSE;
}
float
NSMonster::SeeFOV(void)
@ -212,7 +225,7 @@ NSMonster::AttackThink(void)
if (m_iMState == MONSTER_AIMING) {
int m;
if (vlen(origin - m_eEnemy.origin) < 96)
if (MeleeCondition() == TRUE)
m = AttackMelee();
else {
m = AttackRanged();
@ -510,7 +523,7 @@ NSMonster::Physics(void)
SetFrame(AnimIdle());
} else if (spvel <= 140) {
SetFrame(AnimWalk());
} else if (spvel <= 240) {
} else /*if (spvel <= 240)*/ {
SetFrame(AnimRun());
}
}