mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-02-21 02:20:00 +01:00
fix equip replace bug
This commit is contained in:
parent
88fcfc9c65
commit
c21b534e47
@ -1271,7 +1271,7 @@ void PlayerbotFactory::InitEquipment(bool incremental)
|
|||||||
if (!CanEquipUnseenItem(slot, dest, newItemId))
|
if (!CanEquipUnseenItem(slot, dest, newItemId))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
float cur_score = CalculateItemScore(newItemId);
|
float cur_score = CalculateItemScore(newItemId, bot);
|
||||||
if (cur_score > bestScoreForSlot) {
|
if (cur_score > bestScoreForSlot) {
|
||||||
bestScoreForSlot = cur_score;
|
bestScoreForSlot = cur_score;
|
||||||
bestItemForSlot = newItemId;
|
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;
|
float score = 0;
|
||||||
int tab = AiFactory::GetPlayerSpecTab(bot);
|
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
|
+ defense * 0.25 + dodge * 0.25 + armor * 0.5 + stamina * 1.5
|
||||||
+ hit * 1 + crit * 1 + haste * 0.5 + expertise * 3;
|
+ 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;
|
score *= 0.8;
|
||||||
}
|
}
|
||||||
@ -3008,7 +3008,7 @@ float PlayerbotFactory::CalculateItemScore(uint32 item_id)
|
|||||||
(cls == CLASS_ROGUE) ||
|
(cls == CLASS_ROGUE) ||
|
||||||
(cls == CLASS_DEATH_KNIGHT && tab == 1) ||
|
(cls == CLASS_DEATH_KNIGHT && tab == 1) ||
|
||||||
(cls == CLASS_WARRIOR && tab == 1 && !bot->HasSpell(46917)) ||
|
(cls == CLASS_WARRIOR && tab == 1 && !bot->HasSpell(46917)) ||
|
||||||
IsShieldTank())) {
|
IsShieldTank(bot))) {
|
||||||
score *= 0.1;
|
score *= 0.1;
|
||||||
}
|
}
|
||||||
// spec with double hand
|
// spec with double hand
|
||||||
@ -3026,13 +3026,13 @@ float PlayerbotFactory::CalculateItemScore(uint32 item_id)
|
|||||||
// return score;
|
// return score;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool PlayerbotFactory::IsShieldTank()
|
bool PlayerbotFactory::IsShieldTank(Player* bot)
|
||||||
{
|
{
|
||||||
int tab = AiFactory::GetPlayerSpecTab(bot);
|
int tab = AiFactory::GetPlayerSpecTab(bot);
|
||||||
return (bot->getClass() == CLASS_WARRIOR && tab == 2) || (bot->getClass() == CLASS_PALADIN && tab == 1);
|
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)) {
|
if (bot->HasSkill(SKILL_PLATE_MAIL)) {
|
||||||
return item_subclass_armor != ITEM_SUBCLASS_ARMOR_PLATE;
|
return item_subclass_armor != ITEM_SUBCLASS_ARMOR_PLATE;
|
||||||
|
|||||||
@ -114,6 +114,7 @@ class PlayerbotFactory : public InventoryAction
|
|||||||
void InitSkills();
|
void InitSkills();
|
||||||
|
|
||||||
static uint32 tradeSkills[];
|
static uint32 tradeSkills[];
|
||||||
|
static float CalculateItemScore(uint32 item_id, Player* bot);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void Prepare();
|
void Prepare();
|
||||||
@ -165,9 +166,8 @@ class PlayerbotFactory : public InventoryAction
|
|||||||
void LoadEnchantContainer();
|
void LoadEnchantContainer();
|
||||||
void ApplyEnchantTemplate();
|
void ApplyEnchantTemplate();
|
||||||
void ApplyEnchantTemplate(uint8 spec);
|
void ApplyEnchantTemplate(uint8 spec);
|
||||||
float CalculateItemScore(uint32 item_id);
|
static bool IsShieldTank(Player* bot);
|
||||||
bool IsShieldTank();
|
static bool NotSameArmorType(uint32 item_subclass_armor, Player* bot);
|
||||||
bool NotSameArmorType(uint32 item_subclass_armor);
|
|
||||||
EnchantContainer::const_iterator GetEnchantContainerBegin() { return m_EnchantContainer.begin(); }
|
EnchantContainer::const_iterator GetEnchantContainerBegin() { return m_EnchantContainer.begin(); }
|
||||||
EnchantContainer::const_iterator GetEnchantContainerEnd() { return m_EnchantContainer.end(); }
|
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())
|
if (bot->isDead() && botAI->GetMaster()->IsAlive())
|
||||||
{
|
{
|
||||||
bot->ResurrectPlayer(1.0f, false);
|
bot->ResurrectPlayer(1.0f, false);
|
||||||
|
bot->DurabilityRepairAll(false, 1.0f, false);
|
||||||
botAI->TellMasterNoFacing("I live, again!");
|
botAI->TellMasterNoFacing("I live, again!");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -3,8 +3,10 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include "ItemUsageValue.h"
|
#include "ItemUsageValue.h"
|
||||||
|
#include "AiFactory.h"
|
||||||
#include "ChatHelper.h"
|
#include "ChatHelper.h"
|
||||||
#include "GuildTaskMgr.h"
|
#include "GuildTaskMgr.h"
|
||||||
|
#include "PlayerbotFactory.h"
|
||||||
#include "Playerbots.h"
|
#include "Playerbots.h"
|
||||||
#include "RandomItemMgr.h"
|
#include "RandomItemMgr.h"
|
||||||
#include "ServerFacade.h"
|
#include "ServerFacade.h"
|
||||||
@ -180,8 +182,9 @@ ItemUsage ItemUsageValue::QueryItemUsageForEquip(ItemTemplate const* itemProto)
|
|||||||
}
|
}
|
||||||
|
|
||||||
bool shouldEquip = false;
|
bool shouldEquip = false;
|
||||||
uint32 statWeight = sRandomItemMgr->GetLiveStatWeight(bot, itemProto->ItemId);
|
// uint32 statWeight = sRandomItemMgr->GetLiveStatWeight(bot, itemProto->ItemId);
|
||||||
if (statWeight)
|
float itemScore = PlayerbotFactory::CalculateItemScore(itemProto->ItemId, bot);
|
||||||
|
if (itemScore)
|
||||||
shouldEquip = true;
|
shouldEquip = true;
|
||||||
|
|
||||||
if (itemProto->Class == ITEM_CLASS_WEAPON && !sRandomItemMgr->CanEquipWeapon(bot->getClass(), itemProto))
|
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();
|
ItemTemplate const* oldItemProto = oldItem->GetTemplate();
|
||||||
if (oldItem)
|
if (oldItem)
|
||||||
{
|
{
|
||||||
uint32 oldStatWeight = sRandomItemMgr->GetLiveStatWeight(bot, oldItemProto->ItemId);
|
// uint32 oldStatWeight = sRandomItemMgr->GetLiveStatWeight(bot, oldItemProto->ItemId);
|
||||||
if (statWeight || oldStatWeight)
|
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*>
|
class LootStrategyValue : public ManualSetValue<LootStrategy*>
|
||||||
{
|
{
|
||||||
public:
|
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();
|
virtual ~LootStrategyValue();
|
||||||
|
|
||||||
std::string const Save() override;
|
std::string const Save() override;
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user