吾爱尚玩资源基地

标题: WOWSF服务端的一个修改经验倍率的GM命令 [打印本页]

作者: admin    时间: 2016-4-23 00:00
标题: WOWSF服务端的一个修改经验倍率的GM命令
下面是一个关于修改经验倍率的GM命令,GM可以随时在游戏里面修改经验倍率。。这样就可以实时的调整

适用于T端(Trinity-Core服务端)
diff --git src/server/game/Chat/Chat.cpp src/server/game/Chat/Chat.cpp
index 035fbaf..aa4c61f 100755
--- src/server/game/Chat/Chat.cpp
+++ src/server/game/Chat/Chat.cpp
@@ -414,6 +414,7 @@ ChatCommand* ChatHandler::getCommandTable()
         { "bindsight",      SEC_ADMINISTRATOR,  false, OldHandler<&ChatHandler::HandleBindSightCommand>,           "", NULL },
         { "unbindsight",    SEC_ADMINISTRATOR,  false, OldHandler<&ChatHandler::HandleUnbindSightCommand>,         "", NULL },
         { "playall",        SEC_GAMEMASTER,  false, OldHandler<&ChatHandler::HandlePlayAllCommand>,             "", NULL },
+        { "xprate",         SEC_PLAYER,         false, OldHandler<&ChatHandler::HandleXpRateCommand>,              "", NULL },
         { NULL,             0,                  false, NULL,                                           "", NULL }
     };

diff --git src/server/game/Chat/Chat.h src/server/game/Chat/Chat.h
index 2311f4b..a612fa5 100755
--- src/server/game/Chat/Chat.h
+++ src/server/game/Chat/Chat.h
@@ -252,6 +252,7 @@ class ChatHandler
         bool HandleStartCommand(const char* args);
         bool HandleDismountCommand(const char* args);
         bool HandleSaveCommand(const char* args);
+        bool HandleXpRateCommand(const char* args);

         bool HandleSummonCommand(const char* args);
         bool HandleAppearCommand(const char* args);
diff --git src/server/game/Chat/Commands/Level0.cpp src/server/game/Chat/Commands/Level0.cpp
index 6d33a57..5c0a292 100755
--- src/server/game/Chat/Commands/Level0.cpp
+++ src/server/game/Chat/Commands/Level0.cpp
@@ -157,3 +157,26 @@ bool ChatHandler::HandleServerMotdCommand(const char* /*args*/)
     return true;
}

+// Allow the player to set their own exp modifier
+#define MAX_XP_RATE 5
+bool ChatHandler::HandleXpRateCommand(const char* args)
+{
+    Player* chr = m_session->GetPlayer();
+
+    if (!*args)
+        return false;
+
+    float xp_rate = atof((char*)args);
+
+    if (xp_rate < 0 || xp_rate > MAX_XP_RATE)
+    {
+        SendSysMessage(LANG_BAD_VALUE);
+        SetSentErrorMessage(true);
+        return false;
+    }
+
+    chr->SetXpRate(xp_rate);
+    PSendSysMessage("Your XP rate is now: %f", chr->GetXpRate());
+
+    return true;
+}
diff --git src/server/game/Entities/Creature/GossipDef.cpp src/server/game/Entities/Creature/GossipDef.cpp
index a39bd8e..8cf7dab 100755
--- src/server/game/Entities/Creature/GossipDef.cpp
+++ src/server/game/Entities/Creature/GossipDef.cpp
@@ -366,7 +366,7 @@ void PlayerMenu::SendQuestGiverQuestDetails(Quest const* quest, uint64 npcGUID,
         }

         data << uint32(quest->GetRewOrReqMoney());
-        data << uint32(quest->XPValue(_session->GetPlayer()) * sWorld->getRate(RATE_XP_QUEST));
+        data << uint32(quest->XPValue(_session->GetPlayer()) * sWorld->getRate(RATE_XP_QUEST) * _session->GetPlayer()->GetXpRate());
     }

     // rewarded honor points. Multiply with 10 to satisfy client
@@ -598,7 +598,7 @@ void PlayerMenu::SendQuestGiverOfferReward(Quest const* quest, uint64 npcGUID, b
     }

     data << uint32(quest->GetRewOrReqMoney());
-    data << uint32(quest->XPValue(_session->GetPlayer()) * sWorld->getRate(RATE_XP_QUEST));
+    data << uint32(quest->XPValue(_session->GetPlayer()) * sWorld->getRate(RATE_XP_QUEST) * _session->GetPlayer()->GetXpRate());

     // rewarded honor points. Multiply with 10 to satisfy client
     data << 10 * Trinity::Honor::hk_honor_at_level(_session->GetPlayer()->getLevel(), quest->GetRewHonorMultiplier());
diff --git src/server/game/Entities/Player/Player.cpp src/server/game/Entities/Player/Player.cpp
index 38af97f..38709bc 100755
--- src/server/game/Entities/Player/Player.cpp
+++ src/server/game/Entities/Player/Player.cpp
@@ -6843,6 +6843,7 @@ void Player::CheckAreaExploreAndOutdoor()
                     XP = uint32(sObjectMgr->GetBaseXP(p->area_level)*sWorld->getRate(RATE_XP_EXPLORE));
                 }

+                XP = uint32(XP * GetXpRate());
                 GiveXP(XP, NULL);
                 SendExplorationExperience(area, XP);
             }
@@ -14998,7 +14999,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
     bool rewarded = (m_RewardedQuests.find(quest_id) != m_RewardedQuests.end());

     // Not give XP in case already completed once repeatable quest
-    uint32 XP = rewarded ? 0 : uint32(quest->XPValue(this)*sWorld->getRate(RATE_XP_QUEST));
+    uint32 XP = rewarded ? 0 : uint32(quest->XPValue(this)*sWorld->getRate(RATE_XP_QUEST) * GetXpRate());

     // handle SPELL_AURA_MOD_XP_QUEST_PCT auras
     Unit::AuraEffectList const& ModXPPctAuras = GetAuraEffectsByType(SPELL_AURA_MOD_XP_QUEST_PCT);
diff --git src/server/game/Entities/Player/Player.h src/server/game/Entities/Player/Player.h
index 489b4ea..fe0e560 100755
--- src/server/game/Entities/Player/Player.h
+++ src/server/game/Entities/Player/Player.h
@@ -1188,6 +1188,9 @@ class Player : public Unit, public GridObject
             time_inn_enter = time;
         }

+        float GetXpRate() const { return m_xp_rate; }
+        void SetXpRate(float xp_rate) { m_xp_rate = xp_rate; }
+
         float GetRestBonus() const { return m_rest_bonus; }
         void SetRestBonus(float rest_bonus_new);

@@ -2797,6 +2800,8 @@ class Player : public Unit, public GridObject

         uint8 m_grantableLevels;

+        float m_xp_rate;
+
     private:
         // internal common parts for CanStore/StoreItem functions
         InventoryResult CanStoreItem_InSpecificSlot(uint8 bag, uint8 slot, ItemPosCountVec& dest, ItemTemplate const* pProto, uint32& count, bool swap, Item* pSrcItem) const;
diff --git src/server/game/Miscellaneous/Formulas.h src/server/game/Miscellaneous/Formulas.h
index 4faacc1..414b9b0 100755
--- src/server/game/Miscellaneous/Formulas.h
+++ src/server/game/Miscellaneous/Formulas.h
@@ -179,6 +179,7 @@ namespace Trinity
                 }

                 gain = uint32(gain * sWorld->getRate(RATE_XP_KILL));
+                gain = uint32(gain * player->GetXpRate());
             }

             sScriptMgr->OnGainCalculation(gain, player, u);



回复下载完整代码




作者: chaich173    时间: 2021-12-27 08:55
真不错,学习啊




欢迎光临 吾爱尚玩资源基地 (http://bbs.523play.com/) Powered by Discuz! X3.4