Index: Chat.cpp===================================================================
--- Chat.cpp (revision 414)
+++ Chat.cpp (working copy)
@@ -470,6 +470,7 @@
{ "player_loot_template", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadPlayerLootTemplateCommand, "", NULL }, //重载玩家掉率
{ "creature_addtemp", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadCreatureAddtempCommand, "", NULL }, //重载灾变系统
{ "spell_cost", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadSpellCostCommand, "", NULL }, //使用技能的消耗数据库从载
+ { "item_price", SEC_ADMINISTRATOR, true, &ChatHandler::HandleReloadBuyItemPriceCommand, "", NULL }, //购买物品消耗系统
{ NULL, 0, false, NULL, "", NULL }
};
Index: Chat.h
===================================================================
--- Chat.h (revision 414)
+++ Chat.h (working copy)
@@ -396,6 +396,7 @@
bool HandleReloadPlayerLootTemplateCommand(const char* args); //重载玩家掉率
bool HandleReloadCreatureAddtempCommand(const char* args); //重载灾变秒年2 2系统
bool HandleReloadSpellCostCommand(const char* args); //使用技能的消耗数据库从载
+ bool HandleReloadBuyItemPriceCommand(const char* args); //购买物品消耗系统
bool HandleResetAchievementsCommand(const char * args);
bool HandleResetAllCommand(const char * args);
Index: Level3.cpp
===================================================================
--- Level3.cpp (revision 414)
+++ Level3.cpp (working copy)
@@ -168,6 +168,7 @@
HandleReloadPlayerLootTemplateCommand("a"); //重载玩家掉率
HandleReloadCreatureAddtempCommand("a"); //重载灾变系统
HandleReloadSpellCostCommand("a"); //使用技能的消耗数据库从载
+ HandleReloadBuyItemPriceCommand("a"); //购买物品消耗系统
return true;
}
@@ -807,6 +808,17 @@
return true;
}
+bool ChatHandler::HandleReloadBuyItemPriceCommand(const char* /*arg*/) //购买物品消耗系统
+{
+ sLog.outString( "Re-Loading item price table...");
+
+ objmgr.LoadBuyItemPriceEntrys();
+
+ SendGlobalSysMessage("DB table `item_price` reloaded.");
+
+ return true;
+}
+
bool ChatHandler::HandleReloadLocalesAchievementRewardCommand(const char*)
{
sLog.outString( "Re-Loading Locales Achievement Reward Data..." );
Index: ObjectMgr.cpp
===================================================================
--- ObjectMgr.cpp (revision 414)
+++ ObjectMgr.cpp (working copy)
@@ -7246,6 +7246,57 @@
sLog.outString( ">> Loaded %u spell cost from `spell_cost`", total_count);
}//重载技能消耗系统
+void ObjectMgr::LoadBuyItemPriceEntrys() //购买物品消耗系统
+{
+ m_BuyItem_Price.clear();
+ QueryResult *result = WorldDatabase.Query("SELECT entry, BuyItem, BuyItemCount FROM item_price");
+
+ uint32 total_count = 0;
+
+ if( !result )
+ {
+ barGoLink bar( 1 );
+ bar.step();
+
+ sLog.outString();
+ sLog.outString( ">> Loaded %u item price", total_count );
+ return;
+ }
+
+ barGoLink bar( result->GetRowCount() );
+
+ Field* fields;
+ do
+ {
+ BuyItemPrice temp; //定义内存
+ bar.step();
+ fields = result->Fetch();
+ uint32 entry = fields[0].GetUInt32();
+ if(!sItemStore.LookupEntry(entry))
+ {
+ sLog.outDebug("item entry %u from `item_price` is your custom items.",entry);
+ //continue;
+ }
+ temp.itemid = entry;
+ temp.buyitem = fields[1].GetUInt32();
+ if(!sItemStore.LookupEntry(temp.buyitem))
+ {
+ sLog.outDebug("BuyItem entry %u from `item_price` is your custom items.",temp.buyitem);
+ //continue;
+ }
+ temp.itemcount = fields[2].GetUInt32();
+
+ m_BuyItem_Price[entry] = temp; //把值放到内存
+
+ ++total_count;
+ } while ( result->NextRow() );
+
+ delete result;
+
+ sLog.outString();
+ sLog.outString( ">> Loaded %u item price from `item_price`", total_count);
+}//重载物品购买消费系统
+
void ObjectMgr::LoadFishingBaseSkillLevel()
{
mFishingBaseForArea.clear(); // for reload case
Index: ObjectMgr.h
===================================================================
--- ObjectMgr.h (revision 414)
+++ ObjectMgr.h (working copy)
@@ -104,6 +104,14 @@
uint32 itemcount;
};
+struct BuyItemPrice //购买物品消耗系统
+{
+ uint32 entry;
+ uint32 itemid;
+ uint32 buyitem;
+ uint32 itemcount;
+};
+
struct ScriptInfo
{
uint32 id;
@@ -353,6 +361,8 @@
typedef UNORDERED_MAP<uint32, SpellCost> SpellCostMap;//法术使用消耗物品系统
+ typedef UNORDERED_MAP<uint32, BuyItemPrice> BuyItemPriceMap;//购买物品消耗系统
+
typedef UNORDERED_MAP<uint32, uint32> AreaTriggerScriptMap;
typedef UNORDERED_MAP<uint32, ReputationOnKillEntry> RepOnKillMap;
@@ -468,6 +478,15 @@
}
SpellCostMap const& GetSpellCost() const { return m_Spell_Cost; }
+ BuyItemPrice const* GetItemPrice(uint32 id) const //购买物品消耗系统
+ {
+ BuyItemPriceMap::const_iterator itr = m_BuyItem_Price.find(id);
+ if( itr != m_BuyItem_Price.end( ) )
+ return &itr->second;
+ return NULL;
+ }
+ BuyItemPriceMap const& GetItemPrice() const { return m_BuyItem_Price; }
+
uint32 GetQuestForAreaTrigger(uint32 Trigger_ID) const
{
QuestAreaTriggerMap::const_iterator itr = mQuestAreaTriggerMap.find(Trigger_ID);
@@ -812,6 +831,8 @@
void LoadSpellCostEntrys(); //重载技能消耗物品系统
+ void LoadBuyItemPriceEntrys(); //重载购买物品消耗系统
+
int GetIndexForLocale(LocaleConstant loc);
LocaleConstant GetLocaleForIndex(int i);
@@ -947,6 +968,8 @@
SpellCostMap m_Spell_Cost;//技能消耗物品系统
+ BuyItemPriceMap m_BuyItem_Price;//购买物品消耗系统
+
GraveYardMap mGraveYardMap;
GameTeleMap m_GameTeleMap;
Index: Player.cpp
===================================================================
--- Player.cpp (revision 414)
+++ Player.cpp (working copy)
@@ -17573,6 +17575,33 @@
}
}
+ //购买物品消耗系统
+ uint32 mItemid;
+ uint32 mBuyitemid;
+ uint32 mItemcount;
+ if (sConfig.GetIntDefault("BuyItem.Price.On.Off", 0) == 1 )
+ {
+ //Player* pl;
+ ObjectMgr::BuyItemPriceMap const& cBuyItemPrice = objmgr.GetItemPrice();
+ for (ObjectMgr::BuyItemPriceMap::const_iterator itr = cBuyItemPrice.begin(); itr != cBuyItemPrice.end(); ++itr)
+ {
+ mItemid = itr->second.itemid;
+ mBuyitemid = itr->second.buyitem;
+ mItemcount= itr->second.itemcount;
+
+ if (pProto->ItemId == mItemid && mItemid != 0)
+ {
+ //判断物品是否足够
+ if (!HasItemCount(mBuyitemid,mItemcount) && mItemid > 0 && mItemcount > 0 )
+ {
+ GetSession()->SendAreaTriggerMessage(GetSession()->GetMangosString(15030),GetItemCharName(mBuyitemid),mItemcount);
+ return false;
+ }
+ }
+ }//for循环结束
+ }//结束
+
+
uint32 price = pProto->BuyPrice * count;
// reputation discount
@@ -17595,6 +17624,10 @@
}
ModifyMoney( -(int32)price );
+ if (sConfig.GetIntDefault("BuyItem.Price.On.Off", 0) == 1 )//购买物品消耗系统
+ {
+ DestroyItemCount(mBuyitemid, mItemcount, true);
+ }
if (crItem->ExtendedCost) // case for new honor system
{
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
@@ -17640,6 +17673,10 @@
}
ModifyMoney( -(int32)price );
+ if (sConfig.GetIntDefault("BuyItem.Price.On.Off", 0) == 1 )//购买物品消耗系统
+ {
+ DestroyItemCount(mBuyitemid, mItemcount, true);
+ }
if (crItem->ExtendedCost) // case for new honor system
{
ItemExtendedCostEntry const* iece = sItemExtendedCostStore.LookupEntry(crItem->ExtendedCost);
Index: World.cpp
===================================================================
--- World.cpp (revision 414)
+++ World.cpp (working copy)
@@ -1355,6 +1355,9 @@
sLog.outString( "Loading Spell Cost..." );//载入入技能消耗物品系统
objmgr.LoadSpellCostEntrys();
+ sLog.outString( "Loading Item Price..." );//载入购买物品消耗系统
+ objmgr.LoadBuyItemPriceEntrys();
+
sLog.outString( "Loading Loot Tables..." );
sLog.outString();
LoadLootTables();
|