How to disable attacks?

Users who are viewing this thread

Hello! I want to implement a defend mechanism and I have been trying to find a way to disable AI attacks for a few days. My last attempt was with the


But it only works one time, any other subsequent calls cause the NPC to run at the enemy and follow it, without doing anything. I checked the value of the scripted flags for the NPC and it only shows the NoAttack flag. Any suggestions?

Thank you!
I tried with this as well, but this makes the NPC not respond to any order given unless I add the AgentFlag.CanAttack flag back. It just finishes the order given before setting the flag and then sits idle. I need something that just lets me disable attacking, but still allows for orders to be given. Even just a hint or idea as to why the above is happening would be great, I've been looking everywhere through the source code but can't find a reason.
Last edited:
Thank you for the suggestion! Just setting this doesn't seem to work, the NPC still attacks... I made a prefix for the SetAiRelatedProperties method and I'm now trying to find what values to set all the Attack/Defense related agentDrivenProperties so that it doesn't attack.

agentDrivenProperties.AISetNoAttackTimerAfterBeingHitAbility = MBMath.Lerp(0.33f, 1f, num, 1E-05f);
agentDrivenProperties.AISetNoAttackTimerAfterBeingParriedAbility = MBMath.Lerp(0.2f, 1f, num * num, 1E-05f);
agentDrivenProperties.AISetNoDefendTimerAfterHittingAbility = MBMath.Lerp(0.1f, 0.99f, num * num, 1E-05f);
agentDrivenProperties.AISetNoDefendTimerAfterParryingAbility = MBMath.Lerp(0.15f, 1f, num * num, 1E-05f);

Does anyone know what these do? ^
I tried setting the AISetNoAttackTimers to their min(0.33f and 0.2f) and max(1f) values, same for the AISetNoDefendTimers, min(0.1f and 0.15f) and max(0.99 and 1f), but there didnt seem to be any difference.
But they both call base.SetAiRelatedProperties(agent, agentDrivenProperties, weaponComponentData, secondaryItem), right? It seems to me that patching AgentStatCalculateModel.SetAiRelatedProperties is enough. Again, just setting agentDrivenProperties.AIAttackOnDecideChance=0f doesnt disable attacks completely, and I haven't figured a configuration that disables them completely.

I managed through some data analysis and testing to figure out a more optimal defensive configuration though
(eg. running a 1v1 for 30 mins resulted in 1.477832512315271% attacks 87.192118226601% defend 11.330049261083744% direction switch for the configured npc compared to 40.0% attacks 37.64705882352941% defend 22.35294117647059% direction switch for the normal npc)
Top Bottom