diff --git a/modules/UI/botmgr/botmgr.client.ts b/modules/UI/botmgr/botmgr.client.ts index 9c98685..d1a8fb4 100644 --- a/modules/UI/botmgr/botmgr.client.ts +++ b/modules/UI/botmgr/botmgr.client.ts @@ -334,11 +334,14 @@ if(!aio.AddAddon()) { if(button == "LeftButton") { PickupItem(itemId); return; - } - //botStorage.EquipBotItem(botId, frame.GetID(), itemId); + } } if(compItem) { + const slot = frame.GetID(); + + aio.Handle("BotMgr", "EquipItem",botId, slot, compItemId); + // Attempt to equip the item. PlaySound("INTERFACESOUND_CURSORDROPOBJECT"); ClearCursor(); } diff --git a/modules/UI/botmgr/botmgr.server.ts b/modules/UI/botmgr/botmgr.server.ts index 510b074..68ae78a 100644 --- a/modules/UI/botmgr/botmgr.server.ts +++ b/modules/UI/botmgr/botmgr.server.ts @@ -114,10 +114,41 @@ function GetBotDetails(bot: Creature): BotData { } } - return NpcDetailStorage[bot.GetEntry()]; - + return NpcDetailStorage[bot.GetEntry()]; } +/** + * Equip an item for the bot and update bot details + * @param event + * @param player + * @param command + * @returns + */ +function EquipItem(botEntry: number, slot: BotEquipmentSlotNum, item: number): void { + + + print(`Bot: ${botEntry} Slot: ${slot} Item: ${item}`); + + // const isEligible = bot.BotCanEquipItem(item, slot); + + + + // if(!isEligible) { + // log.error(`Bot cannot equip item: ${item} in slot: ${slot}`); + // return; + // } + + // if(bot.BotEquipItem(item, slot)) { + // NpcDetailStorage[bot.GetEntry()].equipment[slot] = item; + // aio.Handle(bot.GetBotOwner(), 'BotMgr', 'EquipSuccess', { slot, item}); + // } else { + // log.error(`Bot failed to equip item: ${item} in slot: ${slot}`); + // aio.Handle(bot.GetBotOwner(), 'BotMgr', 'EquipFail', { slot, item}); + // } + +} + + const ShowBotMgr: player_event_on_command = (event: number,player: Player, command: string): boolean => { if(command == 'botmgr') { @@ -154,8 +185,6 @@ function GetBotPanelInfo(player: Player): void { return; } - - try { const target = player.GetSelection(); @@ -169,22 +198,10 @@ function GetBotPanelInfo(player: Player): void { print(`BotMgr: Error parsing bot entry: ${e}`); } } - -function ShowComplexArray(items: Record) { - - try { - for (const [key, value] of Object.entries(items)) { - print(`${key}: ${value}`); - } - } catch (e) { - PrintError(`BotMgr: Error showing complex array: ${e}`); - } - -} - const botMgrHandlers = aio.AddHandlers('BotMgr', { TargetIsEligible, - GetBotPanelInfo + GetBotPanelInfo, + EquipItem }); RegisterPlayerEvent(