mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 02:30:43 -05:00
Check for child items of ammo boxes before adding more prior to mailing
This commit is contained in:
parent
24fb4e0578
commit
e8a589a2f8
@ -393,7 +393,7 @@ export class MailSendService {
|
||||
dt: dialogueMessage.dt,
|
||||
type: dialogueMessage.type,
|
||||
uid: dialogueMessage.uid,
|
||||
text: dialogueMessage.text
|
||||
text: dialogueMessage.text,
|
||||
};
|
||||
break;
|
||||
}
|
||||
@ -478,11 +478,16 @@ export class MailSendService {
|
||||
reward.slotId = "main";
|
||||
}
|
||||
|
||||
// Boxes can contain sub-items
|
||||
// Ammo boxes should contain sub-items
|
||||
if (this.itemHelper.isOfBaseclass(itemTemplate._id, BaseClasses.AMMO_BOX)) {
|
||||
const boxAndCartridges: IItem[] = [reward];
|
||||
this.itemHelper.addCartridgesToAmmoBox(boxAndCartridges, itemTemplate);
|
||||
|
||||
const childItems = itemsToSendToPlayer.data?.filter((x) => x.parentId === reward._id);
|
||||
if (childItems.length > 0) {
|
||||
// Ammo box reward already has ammo, don't add
|
||||
itemsToSendToPlayer.data.push(reward);
|
||||
} else {
|
||||
const boxAndCartridges: IItem[] = [reward];
|
||||
this.itemHelper.addCartridgesToAmmoBox(boxAndCartridges, itemTemplate);
|
||||
}
|
||||
// Push box + cartridge children into array
|
||||
itemsToSendToPlayer.data.push(...boxAndCartridges);
|
||||
} else {
|
||||
|
Loading…
x
Reference in New Issue
Block a user