NPC friendly unless you attack it. Created 5 years ago2019-02-17 14:54:03 UTC by abbadon abbadon

Created 5 years ago2019-02-17 14:54:03 UTC by abbadon abbadon

Posted 5 years ago2019-02-17 14:54:03 UTC Post #342050
Hi. i am sure I have seen this on a tutorial ages ago, but i am not able to find it. So my question is, how can I make a friendly NPC attack you if you attck it?. I know how to make it change its relationship if it is hurt, but i cannot figure hot to make it attack the provoker.

I have seen this in the iSlave monsterĀ“s code
//=========================================================
// TakeDamage - get provoked when injured
//=========================================================

int CISlave :: TakeDamage( entvars_t* pevInflictor, entvars_t* pevAttacker, float flDamage, int bitsDamageType)
{
    // don't slash one of your own
    if ((bitsDamageType & DMG_SLASH) && pevAttacker && IRelationship( Instance(pevAttacker) )<= R_DL )
        return 0;

    m_afMemory |= bits_MEMORY_PROVOKED;
    return CSquadMonster::TakeDamage(pevInflictor, pevAttacker, flDamage, bitsDamageType);
}
But I cannot understand well how to modify it so the enemy attacks you...
Posted 5 years ago2019-03-01 11:28:58 UTC Post #342098
bits_MEMORY_PROVOKED is only used to determine whether to attack the player or not for the islave.
In CTalkMonster::IRelationship bits_MEMORY_PROVOKED is used to determine whether to attack the player or not.

If you want a friendly monster to attack you if attacked do something similar to CTalkMonster::IRelationship (and set bits_MEMORY_PROVOKED in TakeDamange too of course).
You must be logged in to post a response.