随机附魔笔记

#define MAX_ITEM_PROTO_DAMAGES 2   //最多支持的伤害数                       // changed in 3.1.0

#define MAX_ITEM_PROTO_SOCKETS 3  //最多支持的插槽数

#define MAX_ITEM_PROTO_SPELLS  5  //最多支持的技能数

#define MAX_ITEM_PROTO_STATS  10  //最多支持的属性数

 

StatsCount 当前设置的属性数

 

随机附魔主要用到两个属性

MAX_ITEM_PROTO_SPELLS、MAX_ITEM_PROTO_STATS

 

首先说说

MAX_ITEM_PROTO_STATS 最多支持的属性数 

 

 

对应出现在:

itemTemplate.h //item_template对象

 

itemHandler.cpp

void ItemTemplate::InitializeQueryData() //初始化物品对象中的data到服务端

void WorldSession::HandleItemQuerySingleOpcode(WorldPacket & recvData) //缓存到玩家客户端

 

Object_Mgr.cpp //加载数据库item_template到服务端

 

结论:在缓存到玩家客户端时,读取自定义表中的数据,做算法计算,重新发到玩家客户端。

 

 

 


说到MAX_ITEM_PROTO_STATS,需要说下StatsCount

 

对应出现在:

itemTemplate.h //item_template对象

 

Player.cpp 

void Player::_ApplyItemBonuses(ItemTemplate const* proto, uint8 slot, bool apply, bool only_level_scale /*= false*/) //和Item GetTemplate()相关

 

StatSystem.cpp

void Player::UpdateAttackPowerAndDamage(bool ranged) //和 Player->m_items相关

 

Object_Mgr.cpp //加载数据库item_template到服务端

 

itemHandler.cpp //同MAX_ITEM_PROTO_STATS

 

结论:猜测是为了节省内存,使用statscount,做了遍历限制。

 

 

 

MAX_ITEM_PROTO_SPELLS 最多支持的技能数

item.cpp

bool Item::Create(uint32 guidlow, uint32 itemid, Player const* owner) //

m_items

结论:所有的技能读取,都是通过item->GetTemplate()

 

 

最终结论:

Item.cpp中修改

static Item* CreateItem(uint32 item, uint32 count, Player const* player = NULL, bool clone = false, uint32 randomPropertyId = 0);

Item* CloneItem(uint32 count, Player const* player = NULL) const;

Item();

virtual bool Create(uint32 guidlow, uint32 itemid, Player const* owner);

ItemTemplate const* GetTemplate() const;

 

 

//创建一个Item,从数据库中读取后,加上自定义属性数据。

Item* Item::CreateItem(uint32 item, uint32 count, Player const* player, bool clone, uint32 randomPropertyId)

//获取Item中的Template

//从Item中获取Template,必定是用于角色,所以改角色需要改这里

ItemTemplate const* Item::GetTemplate() const

 

 

 

 

 

 

 

 

 

 

 

猜你喜欢

转载自www.cnblogs.com/needly/p/12166679.html