mirror of
https://github.com/mod-playerbots/mod-playerbots
synced 2025-11-29 15:58:20 +08:00
fix equip replace bug
This commit is contained in:
@@ -1271,7 +1271,7 @@ void PlayerbotFactory::InitEquipment(bool incremental)
|
||||
if (!CanEquipUnseenItem(slot, dest, newItemId))
|
||||
continue;
|
||||
|
||||
float cur_score = CalculateItemScore(newItemId);
|
||||
float cur_score = CalculateItemScore(newItemId, bot);
|
||||
if (cur_score > bestScoreForSlot) {
|
||||
bestScoreForSlot = cur_score;
|
||||
bestItemForSlot = newItemId;
|
||||
@@ -2866,7 +2866,7 @@ void PlayerbotFactory::LoadEnchantContainer()
|
||||
}
|
||||
}
|
||||
|
||||
float PlayerbotFactory::CalculateItemScore(uint32 item_id)
|
||||
float PlayerbotFactory::CalculateItemScore(uint32 item_id, Player* bot)
|
||||
{
|
||||
float score = 0;
|
||||
int tab = AiFactory::GetPlayerSpecTab(bot);
|
||||
@@ -2989,7 +2989,7 @@ float PlayerbotFactory::CalculateItemScore(uint32 item_id)
|
||||
+ defense * 0.25 + dodge * 0.25 + armor * 0.5 + stamina * 1.5
|
||||
+ hit * 1 + crit * 1 + haste * 0.5 + expertise * 3;
|
||||
}
|
||||
if (proto->Class == ITEM_CLASS_ARMOR && NotSameArmorType(proto->SubClass))
|
||||
if (proto->Class == ITEM_CLASS_ARMOR && NotSameArmorType(proto->SubClass, bot))
|
||||
{
|
||||
score *= 0.8;
|
||||
}
|
||||
@@ -3008,7 +3008,7 @@ float PlayerbotFactory::CalculateItemScore(uint32 item_id)
|
||||
(cls == CLASS_ROGUE) ||
|
||||
(cls == CLASS_DEATH_KNIGHT && tab == 1) ||
|
||||
(cls == CLASS_WARRIOR && tab == 1 && !bot->HasSpell(46917)) ||
|
||||
IsShieldTank())) {
|
||||
IsShieldTank(bot))) {
|
||||
score *= 0.1;
|
||||
}
|
||||
// spec with double hand
|
||||
@@ -3026,13 +3026,13 @@ float PlayerbotFactory::CalculateItemScore(uint32 item_id)
|
||||
// return score;
|
||||
}
|
||||
|
||||
bool PlayerbotFactory::IsShieldTank()
|
||||
bool PlayerbotFactory::IsShieldTank(Player* bot)
|
||||
{
|
||||
int tab = AiFactory::GetPlayerSpecTab(bot);
|
||||
return (bot->getClass() == CLASS_WARRIOR && tab == 2) || (bot->getClass() == CLASS_PALADIN && tab == 1);
|
||||
}
|
||||
|
||||
bool PlayerbotFactory::NotSameArmorType(uint32 item_subclass_armor)
|
||||
bool PlayerbotFactory::NotSameArmorType(uint32 item_subclass_armor, Player* bot)
|
||||
{
|
||||
if (bot->HasSkill(SKILL_PLATE_MAIL)) {
|
||||
return item_subclass_armor != ITEM_SUBCLASS_ARMOR_PLATE;
|
||||
|
||||
@@ -114,6 +114,7 @@ class PlayerbotFactory : public InventoryAction
|
||||
void InitSkills();
|
||||
|
||||
static uint32 tradeSkills[];
|
||||
static float CalculateItemScore(uint32 item_id, Player* bot);
|
||||
|
||||
private:
|
||||
void Prepare();
|
||||
@@ -164,10 +165,9 @@ class PlayerbotFactory : public InventoryAction
|
||||
static void AddPrevQuests(uint32 questId, std::list<uint32>& questIds);
|
||||
void LoadEnchantContainer();
|
||||
void ApplyEnchantTemplate();
|
||||
void ApplyEnchantTemplate(uint8 spec);
|
||||
float CalculateItemScore(uint32 item_id);
|
||||
bool IsShieldTank();
|
||||
bool NotSameArmorType(uint32 item_subclass_armor);
|
||||
void ApplyEnchantTemplate(uint8 spec);
|
||||
static bool IsShieldTank(Player* bot);
|
||||
static bool NotSameArmorType(uint32 item_subclass_armor, Player* bot);
|
||||
EnchantContainer::const_iterator GetEnchantContainerBegin() { return m_EnchantContainer.begin(); }
|
||||
EnchantContainer::const_iterator GetEnchantContainerEnd() { return m_EnchantContainer.end(); }
|
||||
|
||||
|
||||
@@ -169,6 +169,7 @@ bool SummonAction::Teleport(Player* summoner, Player* player)
|
||||
if (bot->isDead() && botAI->GetMaster()->IsAlive())
|
||||
{
|
||||
bot->ResurrectPlayer(1.0f, false);
|
||||
bot->DurabilityRepairAll(false, 1.0f, false);
|
||||
botAI->TellMasterNoFacing("I live, again!");
|
||||
}
|
||||
|
||||
|
||||
@@ -3,8 +3,10 @@
|
||||
*/
|
||||
|
||||
#include "ItemUsageValue.h"
|
||||
#include "AiFactory.h"
|
||||
#include "ChatHelper.h"
|
||||
#include "GuildTaskMgr.h"
|
||||
#include "PlayerbotFactory.h"
|
||||
#include "Playerbots.h"
|
||||
#include "RandomItemMgr.h"
|
||||
#include "ServerFacade.h"
|
||||
@@ -180,8 +182,9 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto)
|
||||
}
|
||||
|
||||
bool shouldEquip = false;
|
||||
uint32 statWeight = sRandomItemMgr->GetLiveStatWeight(bot, itemProto->ItemId);
|
||||
if (statWeight)
|
||||
// uint32 statWeight = sRandomItemMgr->GetLiveStatWeight(bot, itemProto->ItemId);
|
||||
float itemScore = PlayerbotFactory::CalculateItemScore(itemProto->ItemId, bot);
|
||||
if (itemScore)
|
||||
shouldEquip = true;
|
||||
|
||||
if (itemProto->Class == ITEM_CLASS_WEAPON && !sRandomItemMgr->CanEquipWeapon(bot->getClass(), itemProto))
|
||||
@@ -201,10 +204,11 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto)
|
||||
ItemTemplate const* oldItemProto = oldItem->GetTemplate();
|
||||
if (oldItem)
|
||||
{
|
||||
uint32 oldStatWeight = sRandomItemMgr->GetLiveStatWeight(bot, oldItemProto->ItemId);
|
||||
if (statWeight || oldStatWeight)
|
||||
// uint32 oldStatWeight = sRandomItemMgr->GetLiveStatWeight(bot, oldItemProto->ItemId);
|
||||
float oldScore = PlayerbotFactory::CalculateItemScore(oldItemProto->ItemId, bot);
|
||||
if (itemScore || oldScore)
|
||||
{
|
||||
shouldEquip = statWeight >= oldStatWeight;
|
||||
shouldEquip = itemScore >= oldScore * 1.2;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ class PlayerbotAI;
|
||||
class LootStrategyValue : public ManualSetValue<LootStrategy*>
|
||||
{
|
||||
public:
|
||||
LootStrategyValue(PlayerbotAI* botAI, std::string const name = "loot strategy") : ManualSetValue<LootStrategy*>(botAI, normal, name) { }
|
||||
LootStrategyValue(PlayerbotAI* botAI, std::string const name = "loot strategy") : ManualSetValue<LootStrategy*>(botAI, all, name) { }
|
||||
virtual ~LootStrategyValue();
|
||||
|
||||
std::string const Save() override;
|
||||
|
||||
Reference in New Issue
Block a user