• Please note that we've updated the Mount & Blade II: Bannerlord save file system which requires you to take certain steps in order for your save files to be compatible with e1.7.1 and any later updates. You can find the instructions here.

Suggestion General API Request

Users who are viewing this thread

Hexnibbler

Recruit
Is there any plan to adds method "SetTargetAgent" to the "Agent" class ?

There is a GetTargetAgent (that is a pointer to an engine method sets by the engine itself)

Alternatively, if for some reason such a write operation is not feasible : a delegate called by the engine when it is safe to overwrite its own internal TargetAgent.

I.E instead of a Agent.SetTargetAgent, a AgentPtr Agent.OnTargetSet() called by the engine, so that modders can modify the TargetAgent by implementing it and returning the value they wish the engine would use as a target.

Thanks.
 

Hexnibbler

Recruit
Hi @Hexnibbler, what are you trying to achieve with your mod? How would the above change help you?
gain (more) control over individual soldiers within the c# scripts to modify they individual behaviors, specifically who they chose to attack/defend against.

My initial thought was that I would try to maintain a list (-for every soldier-) of all enemy targetting them in melee at the "agent" level.
from there I would be able to modify which enemy should be targetted by other soldier of the formation.
Agent level : list of pointer to enemy soldier targetting him (updated per tick/cb)
Formation level : list of friendly agent sorted so that friendly soldier that have the most enemy on their list (=targetting them) are first.

So that when an agent select a new target
a) he first check his own list of who targets him to decide wheter he should act defensively or not (lots of enemy = he doesn't just try to attack someone as if he had any chance to stay alive.)
b) if he's relatively "free" of threat, he chose to attack someone from the list of enemy of one of his teammate (obtained from the list at the formation level). (because the list at the formation would contain pointer to friendly agent, and those friendly agent would contain a list of pointer to enemy agent, the iteration should be low cost). and take within that list enemies that, themselves, have no one trying to fight them.

so that instead of having lots of soldiers targetting the same target and lots of soldiers being free of threat is reduced towards more "duels" within the melee fight.

for a) the idea was to iterate every tick over the list of enemies in the agent list, unless the current target is releasing a blow (so that he can try to block that blow).
for b) it would be "weighted" by the distance he has with those enemies so that agent don't run on the other side of the formation to help if they can help closer friendly soldiers.

tldr : a system that try to simulate soldiers within a formation taking into account the situation of their teammate through target selection. As if their teammate were shouting for help when overwhelmed.
 
Top Bottom