How to deal damage to an agent

Users who are viewing this thread

duck123

Recruit
Hi,

I have written code to deal damage to an agent when they get too close to an object. The code works however when the player dies the game crashes. There are alot of options I could set and im not sure what I need to in order to get a proper death and avoid a crash, all im doing now is:

AttackCollisionData damageData = new AttackCollisionData();
damageBlow = new Blow(gameAgent.Index);
damageBlow.InflictedDamage = 1;
gameAgent.RegisterBlow(damageBlow, in damageData);

Basically the idea is that the damage is being delt by the player against themselves, kind of like how if you fall to your death I assume thats self inflicted.
 
Hi,

I have written code to deal damage to an agent when they get too close to an object. The code works however when the player dies the game crashes. There are alot of options I could set and im not sure what I need to in order to get a proper death and avoid a crash, all im doing now is:

AttackCollisionData damageData = new AttackCollisionData();
damageBlow = new Blow(gameAgent.Index);
damageBlow.InflictedDamage = 1;
gameAgent.RegisterBlow(damageBlow, in damageData);

Basically the idea is that the damage is being delt by the player against themselves, kind of like how if you fall to your death I assume thats self inflicted.
I suggest you ask on the #bl-coding channel of the Mount & Blade Modding discord as it's rare for active coders to respond to questions on these forums.

BTW the discord invite is the large blue button at the top of the main Modding page on these forums. You can also find github links to the source code of other mods here https://forums.taleworlds.com/index.php?threads/source-code-for-bannerlord-mods.448829/

PS remember to look at the official api documentation https://apidoc.bannerlord.com/v/1.0..._interfaces_1_1_agent_apply_damage_model.html
 
Last edited:
Upvote 0
Back
Top Bottom