坐骑召唤处理:

处理“随机召唤坐骑”召唤随机所起,OK
处理“双击列表菜单”召唤固定座机,OK
This commit is contained in:
尚美 2025-06-18 01:21:12 +08:00
parent e2f19ffbf9
commit c72b3c1890
5 changed files with 72 additions and 74 deletions

View File

@ -100,52 +100,52 @@ function SM_Collections:HandleAttributesData(msg)
end
-- 处理物品属性数据的函数
function SM_Collections:HandleItemAttributesData(msg)
-- 按换行符分割每一行属性数据
local lines = {}
for line in msg:gmatch("[^\r\n]+") do
table.insert(lines, line)
end
local allAttributes = {}
-- 处理每一行属性数据
for _, line in ipairs(lines) do
-- 使用自定义的MessageSplit函数将每行按"|"分隔符拆分
local data = self:MessageSplit(line, "|")
-- 每3个元素为一组进行循环处理属性名、属性值、属性类型
for i = 1, #data, 3 do
if data[i] and data[i + 1] and data[i + 2] then
-- 创建属性对象
local attribute = {
Name = data[i], -- 属性名称
value = tonumber(data[i + 1]), -- 属性数值
valueType = data[i + 2], -- 属性类型(百分比/固定数值)
isPositive = tonumber(data[i + 1]) >= 0 -- 根据数值正负判断是否为正面属性
}
-- 输出每个属性的值
print("Name= " .. attribute.Name .. ", value= " .. attribute.value .. ", valueType= " .. attribute.valueType)
-- 添加到属性数组
table.insert(allAttributes, attribute)
end
end
end
-- 检查是否存在待处理的回调函数
if self.pendingCallbacks and self.pendingCallbacks.item_attributes then
local response = {
success = true,
data = allAttributes
}
self.pendingCallbacks.item_attributes(response)
self.pendingCallbacks.item_attributes = nil
end
end
function SM_Collections:HandleItemAttributesData(msg)
-- 按换行符分割每一行属性数据
local lines = {}
for line in msg:gmatch("[^\r\n]+") do
table.insert(lines, line)
end
local allAttributes = {}
-- 处理每一行属性数据
for _, line in ipairs(lines) do
-- 使用自定义的MessageSplit函数将每行按"|"分隔符拆分
local data = self:MessageSplit(line, "|")
-- 每3个元素为一组进行循环处理属性名、属性值、属性类型
for i = 1, #data, 3 do
if data[i] and data[i + 1] and data[i + 2] then
-- 创建属性对象
local attribute = {
Name = data[i], -- 属性名称
value = tonumber(data[i + 1]), -- 属性数值
valueType = data[i + 2], -- 属性类型(百分比/固定数值)
isPositive = tonumber(data[i + 1]) >= 0 -- 根据数值正负判断是否为正面属性
}
-- 输出每个属性的值
print("Name= " ..
attribute.Name .. ", value= " .. attribute.value .. ", valueType= " .. attribute.valueType)
-- 添加到属性数组
table.insert(allAttributes, attribute)
end
end
end
-- 检查是否存在待处理的回调函数
if self.pendingCallbacks and self.pendingCallbacks.item_attributes then
local response = {
success = true,
data = allAttributes
}
self.pendingCallbacks.item_attributes(response)
self.pendingCallbacks.item_attributes = nil
end
end
-- 处理小伙伴数据
function SM_Collections:HandleCompanionsData(msg)
local data = self:MessageSplit(msg, "|")

View File

@ -62,7 +62,6 @@ function SM_Collections:CreateMainFrame()
rightSidePanel.CallButon:SetNormalTexture("Interface\\ICONS\\Ability_Mount_RidingHorse.blp")
rightSidePanel.CallButon:SetHighlightTexture("Interface\\ICONS\\Ability_Mount_RidingHorse.blp")
rightSidePanel.CallButon:SetPushedTexture("Interface\\ICONS\\Ability_Mount_RidingHorse.blp")
rightSidePanel.CallButon:SetScript("OnClick", function() print("召唤") end)
rightSidePanel.CallButon = rightSidePanel.CallButon
@ -374,22 +373,20 @@ function SM_Collections:ShowTab(tabID)
-- 坐骑收藏,显示召唤按钮并设置文本为"随机召唤坐骑"
self.MainFrame.RightSidePanel.CallButon:Show()
self.MainFrame.RightSidePanel.CallButon.String:SetText("随机召唤坐骑")
self.MainFrame.RightSidePanel.CallButon:SetNormalTexture(
"Interface\\ICONS\\Ability_Mount_RidingHorse.blp")
self.MainFrame.RightSidePanel.CallButon:SetHighlightTexture(
"Interface\\ICONS\\Ability_Mount_RidingHorse.blp")
self.MainFrame.RightSidePanel.CallButon:SetPushedTexture(
"Interface\\ICONS\\Ability_Mount_RidingHorse.blp")
self.MainFrame.RightSidePanel.CallButon:SetNormalTexture("Interface\\ICONS\\Ability_Mount_RidingHorse.blp")
self.MainFrame.RightSidePanel.CallButon:SetHighlightTexture("Interface\\ICONS\\Ability_Mount_RidingHorse.blp")
self.MainFrame.RightSidePanel.CallButon:SetPushedTexture("Interface\\ICONS\\Ability_Mount_RidingHorse.blp")
self.MainFrame.RightSidePanel.CallButon:SetScript("OnClick", function()
SendAddonMessage("SM_C_SUMMON_MOUNT", 0, "GUILD")
end)
elseif tabID == 2 then
-- 小伙伴收藏,显示召唤按钮并设置文本为"随机召唤小伙伴"
self.MainFrame.RightSidePanel.CallButon:Show()
self.MainFrame.RightSidePanel.CallButon.String:SetText("随机召唤小伙伴")
self.MainFrame.RightSidePanel.CallButon:SetNormalTexture(
"Interface\\ICONS\\Ability_Hunter_BeastCall.blp")
self.MainFrame.RightSidePanel.CallButon:SetHighlightTexture(
"Interface\\ICONS\\Ability_Hunter_BeastCall.blp")
self.MainFrame.RightSidePanel.CallButon:SetPushedTexture(
"Interface\\ICONS\\Ability_Hunter_BeastCall.blp")
self.MainFrame.RightSidePanel.CallButon:SetNormalTexture("Interface\\ICONS\\Ability_Hunter_BeastCall.blp")
self.MainFrame.RightSidePanel.CallButon:SetHighlightTexture("Interface\\ICONS\\Ability_Hunter_BeastCall.blp")
self.MainFrame.RightSidePanel.CallButon:SetPushedTexture("Interface\\ICONS\\Ability_Hunter_BeastCall.blp")
self.MainFrame.RightSidePanel.CallButon:SetScript("OnClick", function() print("随机召唤小伙伴") end)
elseif tabID == 3 then
-- 卡牌收藏,隐藏召唤按钮
self.MainFrame.RightSidePanel.CallButon:Hide()
@ -451,7 +448,7 @@ function SM_Collections:ShowItems()
return panel
end
-- 下面补充内容切换的函数(示例)
-- 内容切换
function SM_Collections:ShowMounts()
--

View File

@ -554,10 +554,17 @@ function SM_Collections:CreateListItems(parent, data, itemType, model, nameText,
OnItemClick(btn, btn.itemData, itemType, panel)
end
-- 列表按钮单击
button:SetScript("OnClick", function()
selectButton(button)
end)
--列表按钮双击
button:SetScript("OnDoubleClick", function()
print("列表按钮双击")
SendAddonMessage("SM_C_SUMMON_MOUNT", item.id, "GUILD")
end)
-- 在鼠标悬停时在工具提示中显示获得状态
button:SetScript("OnEnter", function()
GameTooltip:SetOwner(button, "ANCHOR_RIGHT")

View File

@ -416,6 +416,11 @@ void CollectionMgr::ApplyCollectionBonus(Player* player, CollectionConfig const*
player->ApplyStatBuffMod(STAT_SPIRIT, bonus.value, apply);
break;
case BONUS_ARMOR:
// 护甲值加成
player->HandleStatModifier(UNIT_MOD_ARMOR, modType, bonus.value, apply);
break;
case BONUS_MELEE_ATTACK_POWER:
// 近战攻击强度加成
player->HandleStatModifier(UNIT_MOD_ATTACK_POWER, modType, bonus.value, apply);

View File

@ -156,7 +156,7 @@ public:
}
}
// 玩家获取物品时检查物品收藏
// 玩家获取物品时检查物品收藏
void OnPlayerStoreNewItem(Player* player, Item* item, uint32 count) override
{
if (!player || !player->IsInWorld() || !item)
@ -164,8 +164,8 @@ public:
uint32 itemId = item->GetEntry();
// 检查是否是物品收藏
if (sCollectionMgr->IsCollectibleItem(itemId)) // 您需要实现 CollectionMgr::IsCollectibleItem 方法
// 检查是否是物品收藏
if (sCollectionMgr->IsCollectibleItem(itemId)) // 您需要实现 CollectionMgr::IsCollectibleItem 方法
{
// 检查是否已经收藏
bool alreadyCollected = sCollectionMgr->HasInCollection(player, COLLECTION_ITEM, itemId);
@ -174,18 +174,7 @@ public:
if (added && !alreadyCollected)
{
sLog->outMessage("server", LogLevel::LOG_LEVEL_INFO, "玩家 {} 获得新物品 {},已添加到物品收藏。", player->GetName(), itemId);
// 发送实时更新通知
std::ostringstream updateMsg;
updateMsg << "item|" << itemId << "|1";
sCollectionMgr->SendAddonMessageToPlayer(player, "SM_S_COLLECTION_UPDATE", updateMsg.str(), CHAT_MSG_WHISPER);
// 通知玩家
std::string itemName = item->GetTemplate()->Name1;
std::string message = "您已收集到新物品: " + itemName;
ChatHandler(player->GetSession()).SendNotification(message.c_str());
// 发送更新数据到客户端
// 发送更新数据到客户端
sCollectionMgr->SendItemsData(player);
}
}