Ok, I think I understand what the problem is.
Each time your loop finds an item (*any* item), it adds inventory[inventaireused+1] then increases inventaireused by one.
Naturally, this will simply iterate over all AGS inventory items of your game, regardless of what the enemy actually possesses.
However,Code: ags means that the enemy possesses at least one ofCode: ags which is one of your loot items.
So the next step would be to use the loot item's information and add the correct AGS inventory item to the enemy.
I'm not sure how you're getting from the info stored in
Code: ags to an actual AGS inventory item though.
Each time your loop finds an item (*any* item), it adds inventory[inventaireused+1] then increases inventaireused by one.
Naturally, this will simply iterate over all AGS inventory items of your game, regardless of what the enemy actually possesses.
However,
enemy_item[i].enemyId == enemyId && enemy_item[i].count > 0
loot[enemy_item[i].itemId]
So the next step would be to use the loot item's information and add the correct AGS inventory item to the enemy.
I'm not sure how you're getting from the info stored in
Struct loot{
int sprite;
String Nameitem;
int bonus;
...
}