ralian / eai

Enfusion Artifical Intelligence for DayZ and future Bohemia Interactive games.
Apache License 2.0
68 stars 27 forks source link

how to equip bots?/Как снарядить ботов? #27

Open gikens opened 2 years ago

gikens commented 2 years ago

Привет уважаемый разработчик мода, возникла проблема, в файле HumanLoadout.json и прочих подобных файлов поменял снаряжение для ботов, но они все также спавняться со своим старндартным снаряжением, как исправить?

Hello dear mod developer, there is a problem in the HumanLoadout file.json and other similar files have changed the equipment for bots, but they still spawn with their stardart equipment, how can I fix it?

griha41 commented 10 months ago

I'm using 2 types of weapons on my soldiers, one of them had the accessories for the other, even though the accessory didn't fit into it, did I have to do the same as what you told me? an attachment for each type of weapon?

    weapon_Base weapon = Weapon_Base.Cast(unit.GetItemInHands());

weapon.GetInventory().CreateAttachment("SNAFU_AKTango6T_Black"); weapon.GetInventory().CreateAttachment("SNAFU_NPKPBIPOD"); weapon.GetInventory().CreateAttachment("SNAFU_MTango6T_Black");

Man I had done it! Now you can spawn firearms into the slots of AI.

In few minutes will paste the modded version of OnSpawn function!

griha41 commented 10 months ago

Here the update. I send you an example with reloading secondary firearm (works with mostly except Revolvers type of firearm) OnUnitSpawn_Updated.txt

fiber1985 commented 10 months ago

One question, are you saying that within this parameter I need to put something? ()? I downloaded the original files and I'm just replacing them with the clothes and weapons I want, but if the way you said is better I'll try to do it, because the commands are cleaner.

now the way this one worked out.

5 bots are born, but sometimes 2 come with the rpk and another 3 with a vss.. and all of them are carrying the attachments.. in other words, it worked like this

this work

Weapon_Base weapon = Weapon_Base.Cast(unit.GetItemInHands());
weapon.GetInventory().CreateAttachment("SNAFU_AKTango6T_Black");
weapon.GetInventory().CreateAttachment("SNAFU_NPKPBIPOD");
weapon.GetInventory().CreateAttachment("SNAFU_HNightforce");
fiber1985 commented 10 months ago

Here the update. I send you an example with reloading secondary firearm (works with mostly except Revolvers type of firearm) OnUnitSpawn_Updated.txt

What does this do? for the bot to change weapons? and why does he do this? When does the ammunition run out, for example?

griha41 commented 10 months ago

Here the update. I send you an example with reloading secondary firearm (works with mostly except Revolvers type of firearm) OnUnitSpawn_Updated.txt

What does this do? for the bot to change weapons? and why does he do this? When does the ammunition run out, for example?

eAI has no such information 2nd read script, you had been set unlimited ammo on mag switching, how heck it may run out of ammunition? :-D

fiber1985 commented 10 months ago

hahaha I don't know! but I would like to know lol

Another example does he change weapons? It would be interesting if at long distances the bot used a sniper, and when the player was close he picked up another, faster weapon.

griha41 commented 10 months ago

hahaha I don't know! but I would like to know lol

Another example does he change weapons? It would be interesting if at long distances the bot used a sniper, and when the player was close he picked up another, faster weapon.

The problem of your logic is not understanding of ballistics.

Based on elevation angle bullet my fly on 100 and over 3000 meters...

Same trouble for AI it's finding distance adjusting zeroing to correct distance and if zeroing is not enough calculated additional angel to compensate distance...

That's a trick. Nothing more and nothing less.

fiber1985 commented 10 months ago

hahaha I don't know! but I would like to know lol Another example does he change weapons? It would be interesting if at long distances the bot used a sniper, and when the player was close he picked up another, faster weapon.

The problem of your logic is not understanding of ballistics.

Based on elevation angle bullet my fly on 100 and over 3000 meters...

Same trouble for AI it's finding distance adjusting zeroing to correct distance and if zeroing is not enough calculated additional angel to compensate distance...

That's a trick. Nothing more and nothing less.

I understand, it's not that simple... for me to put this configuration you sent, just put it in place of mine in AI_initi.c?

griha41 commented 10 months ago

hahaha I don't know! but I would like to know lol Another example does he change weapons? It would be interesting if at long distances the bot used a sniper, and when the player was close he picked up another, faster weapon.

The problem of your logic is not understanding of ballistics.

Based on elevation angle bullet my fly on 100 and over 3000 meters...

Same trouble for AI it's finding distance adjusting zeroing to correct distance and if zeroing is not enough calculated additional angel to compensate distance...

That's a trick. Nothing more and nothing less.

I understand, it's not that simple... for me to put this configuration you sent, just put it in place of mine in AI_initi.c?

You shall use it as an example. Everything other you need to do with your hands and mods that you are using.

To install it - you need to copy function into eAI_Init.c, Read comments and include it to yours version of code.

Run server and check that everything works fine if server through the errors, then type here I'll resend the code with fixes.

fiber1985 commented 10 months ago

Friend, I'll be honest, I'm really lost in these commands you sent... I wanted to do something simple, and it already works the way I did, the soldiers are born with the weapons and accessories I placed, but when a zombie comes close they don't shoot and Sometimes it keeps spinning around, doing nothing... so I think this is already in another file, right, because when the zombie gets close the soldier would have to get a melee weapon or just shoot

griha41 commented 10 months ago

Friend, I'll be honest, I'm really lost in these commands you sent... I wanted to do something simple, and it already works the way I did, the soldiers are born with the weapons and accessories I placed, but when a zombie comes close they don't shoot and Sometimes it keeps spinning around, doing nothing... so I think this is already in another file, right, because when the zombie gets close the soldier would have to get a melee weapon or just shoot

It's problem of eAI it self.

There's a "Command Officer AI Unit", if it's dead all units failed to do anything at all.

Simple way could be of Command unit is killed in action or dead, then next AI from group list shall become as Group Commander and so until last one is dead but it's didn't happened.

So basically Command AI gives an order to subunits to engage the target. If Command AI is dead subunits don't receive any command for an engagement. Untill player tager is engage AI unit, then it may kill you otherwise not.

In my server AI accuracy = 0.86, nevertheless I found AI leader (first solder that runs) and kill him in head from 500 meters. And then kill others without any problems.

This is a problem of eAI in basics...

Best thing that we may do is report about it to the developer, but i think that they are know about this problem tho...

fiber1985 commented 10 months ago

I understand, unfortunately not everything works the way we want.

I left my eAIAccuracy at 1.0 and they still miss several shots hahaha

I have a question, I didn't want the bots to leave the loot, but I wanted to leave a reward for whoever kills them, would there be a way to lock their loot, and leave just one item as a reward? like ammunition, magazines etc?

griha41 commented 10 months ago

I understand, unfortunately not everything works the way we want.

I left my eAIAccuracy at 1.0 and they still miss several shots hahaha

I have a question, I didn't want the bots to leave the loot, but I wanted to leave a reward for whoever kills them, would there be a way to lock their loot, and leave just one item as a reward? like ammunition, magazines etc?

You can't do it without reimplementation of eAI. Basic idea is create Player-like AIs that will work by 2 types. Type A: Protect patrol area (means kill everyone except AI) Type B: Protect against enemy's like armed players (who cares weapons in hands) and kill Zombies (that will engage AI because eAI is children type of Player_Base).

You shall search for Survivor Missions - that module may give you such ability (mission where you can get a reward instead of killing Zombies and again eAI will not fit that state because I have no idea do eAI support event handler on eAI Death - that may help you to remove dead unit...), but I never ever before working with eAI on Survivor Missions (instead of Zombies).

fiber1985 commented 10 months ago

For my purpose I wanted to place them to protect military bases, and helicrash... at the bases I wanted to place patrol, and some snipers in strategic points on the map, such as towers and high elevated locations...

griha41 commented 10 months ago

For my purpose I wanted to place them to protect military bases, and helicrash... at the bases I wanted to place patrol, and some snipers in strategic points on the map, such as towers and high elevated locations...

Then create yourself mod based on eAI, but before ask for permission from developers.

There you cold do whatever you want but you'll fail with helicrashes - they're dynamic events of the game and has no connection with eAI.

Bases - pff not a problem at all. Just create the patrols with such road that will covers all base locations and make point of start to point of ending of AI patrol.

fiber1985 commented 10 months ago

So to develop it, I don't even know how to do it, but in the helicrash, I was thinking about taking their coordinates, and putting them to spawn patrols in these locations... then whenever a player came close to the helicrash, the bots would also spawn.

griha41 commented 10 months ago

So to develop it, I don't even know how to do it, but in the helicrash, I was thinking about taking their coordinates, and putting them to spawn patrols in these locations... then whenever a player came close to the helicrash, the bots would also spawn.

The problem is that square size of map is about 20000 km² or 12427.4 mi². You need to call function to get huge list of objects on entire map, filter only helicrashes and only then somehow insert their locations in eAI cfg array for protection patrols.

Fatal problem that it will cost too freaking much server FPS. for 3 minutes each 20 minutes need to renew helicrash locations. Idea is good, really but it's too damn pricey...

fiber1985 commented 10 months ago

Yes, seeing it from this side it gets really heavy,

I'm having a problem here, even though I block the bot from giving loot, his weapon always falls to the ground, do you know if there's a way to avoid this so the player doesn't pick up weapons lying on the ground?

griha41 commented 10 months ago

Yes, seeing it from this side it gets really heavy,

I'm having a problem here, even though I block the bot from giving loot, his weapon always falls to the ground, do you know if there's a way to avoid this so the player doesn't pick up weapons lying on the ground?

It's falling on the ground coz AI unit is dead. In 34% dead bodies keep items in hads because of muscular problems, rest 66% or something about it loose items from hands on death.

In game that stuff was introduced somewhere in 1.0 or 1.10 game patches. So yeah it's a kinda problem that eAI can loose their weapons on the ground. It could be fixed but it requires to override event handler on death for Player_Base, to prevent loosing inhands item, but it causes another problem, that inhamds item shall required it's own slot. Coz player can carry 3 units of weapons at the same time on the body (sholders + hands) - that's problem was solved by throwing away inhands item on death in other case it will disappear...

fiber1985 commented 10 months ago

I understand, I thought about reducing the weapon's health, but when I do that some of them get stuck and the bot can't shoot...

griha41 commented 10 months ago

I understand, I thought about reducing the weapon's health, but when I do that some of them get stuck and the bot can't shoot...

If you added damage to the firearm unit your AI met an awesome problem that they couldn't yet solve.

eAI still don't know how to unjam jammed weapon. So that will not solve your problem.

fiber1985 commented 10 months ago

I understand, I thought about reducing the weapon's health, but when I do that some of them get stuck and the bot can't shoot...

If you added damage to the firearm unit your AI met an awesome problem that they couldn't yet solve.

eAI still don't know how to unjam jammed weapon. So that will not solve your problem.

yes I discovered that yesterday hahaha

fiber1985 commented 10 months ago

my Friend, I'm trying to place some bots in the air base tower, but they always spawn on the ground, I want them to stay up there, is there any parameter for this? I don't want them to walk, they will stay still..

griha41 commented 10 months ago

my Friend, I'm trying to place some bots in the air base tower, but they always spawn on the ground, I want them to stay up there, is there any parameter for this? I don't want them to walk, they will stay still..

It's not about loadout question, so it shouldn't be here.

And as answer - game uses 3D coordinates X Z Y Where Z is height above sea level. I guess the simplest way is spawn barrel in editor and grub coordinates.

fiber1985 commented 10 months ago

To get the coordinates, I'm going to the location and asking for P, but I'm going to open a topic to talk about it.