NSMonster: add spawn key "leap_damage", to define the sort of damage the monster can apply when leaping towards you.

This commit is contained in:
Marco Cawthorne 2023-07-30 08:12:56 -07:00
parent 571ef536a1
commit 83202a6174
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
2 changed files with 30 additions and 0 deletions

View File

@ -494,6 +494,9 @@ private:
float m_flWalkSpeed; float m_flWalkSpeed;
float m_flRunSpeed; float m_flRunSpeed;
float m_flLeapDamage;
bool m_bLeapAttacked;
nonvirtual void _LerpTurnToEnemy(void); nonvirtual void _LerpTurnToEnemy(void);
nonvirtual void _LerpTurnToPos(vector); nonvirtual void _LerpTurnToPos(vector);
nonvirtual void _LerpTurnToYaw(vector); nonvirtual void _LerpTurnToYaw(vector);

View File

@ -92,6 +92,8 @@ NSMonster::NSMonster(void)
m_flWalkSpeed = autocvar_ai_walkSpeed; m_flWalkSpeed = autocvar_ai_walkSpeed;
m_flRunSpeed = autocvar_ai_runSpeed; m_flRunSpeed = autocvar_ai_runSpeed;
m_flLeapDamage = 0;
m_bLeapAttacked = false;
#endif #endif
} }
@ -196,6 +198,8 @@ NSMonster::Save(float handle)
SaveString(handle, "m_strBodyOnDraw", m_strBodyOnDraw); SaveString(handle, "m_strBodyOnDraw", m_strBodyOnDraw);
SaveFloat(handle, "m_flWalkSpeed", m_flWalkSpeed); SaveFloat(handle, "m_flWalkSpeed", m_flWalkSpeed);
SaveFloat(handle, "m_flRunSpeed", m_flRunSpeed); SaveFloat(handle, "m_flRunSpeed", m_flRunSpeed);
SaveFloat(handle, "m_flLeapDamage", m_flLeapDamage);
SaveBool(handle, "m_bLeapAttacked", m_bLeapAttacked);
} }
void void
@ -437,6 +441,12 @@ NSMonster::Restore(string strKey, string strValue)
case "m_flRunSpeed": case "m_flRunSpeed":
m_flRunSpeed = ReadFloat(strValue); m_flRunSpeed = ReadFloat(strValue);
break; break;
case "m_flLeapDamage":
m_flLeapDamage = ReadFloat(strValue);
break;
case "m_bLeapAttacked":
m_bLeapAttacked = ReadBool(strValue);
break;
default: default:
super::Restore(strKey, strValue); super::Restore(strKey, strValue);
break; break;
@ -1313,6 +1323,11 @@ NSMonster::Physics(void)
input_angles = angles; input_angles = angles;
m_bTurning = false; m_bTurning = false;
/* unset the leap attack */
if (m_bLeapAttacked == true && HasFlags(FL_ONGROUND) == true) {
m_bLeapAttacked = false;
}
/* when stuck in a sequence, forget enemies, combat stance */ /* when stuck in a sequence, forget enemies, combat stance */
if (GetSequenceState() != SEQUENCESTATE_NONE) { if (GetSequenceState() != SEQUENCESTATE_NONE) {
m_eEnemy = __NULL__; m_eEnemy = __NULL__;
@ -1381,6 +1396,15 @@ NSMonster::Physics(void)
void void
NSMonster::Touch(entity eToucher) NSMonster::Touch(entity eToucher)
{ {
/* leap test, are we no longer on the ground? */
if (m_flLeapDamage && m_bLeapAttacked == false)
if (HasFlags(FL_ONGROUND) == false) {
if (eToucher.takedamage == DAMAGE_YES) {
Damage_Apply(eToucher, this, m_flLeapDamage, WEAPON_NONE, DMG_BLUNT);
m_bLeapAttacked = true;
}
}
if (movetype != MOVETYPE_WALK) if (movetype != MOVETYPE_WALK)
return; return;
@ -1766,6 +1790,9 @@ NSMonster::SpawnKey(string strKey, string strValue)
case "health": case "health":
base_health = Skill_GetDefValue(strValue); base_health = Skill_GetDefValue(strValue);
break; break;
case "leap_damage":
m_flLeapDamage = Skill_GetDefValue(strValue);
break;
default: default:
NSSurfacePropEntity::SpawnKey(strKey, strValue); NSSurfacePropEntity::SpawnKey(strKey, strValue);
break; break;