关灯
开启左侧

WOWSF服务端的一个修改经验倍率的GM命令

  [复制链接]
admin实名认证 发表于 2016-4-23 00:00:03 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
 
下面是一个关于修改经验倍率的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);



回复下载完整代码
游客,如果您要查看本帖隐藏内容请回复




标签:服务端
 

精彩评论1

倒序浏览
chaich173 发表于 2021-12-27 08:55:25 | 显示全部楼层
 
真不错,学习啊
 
VIP介绍
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 最佳新人

    注册账号后积极发帖的会员
  • 活跃会员

    经常参与各类话题的讨论,发帖内容较有主见
  • 热心会员

    经常帮助其他会员答疑
  • 推广达人

    积极宣传本站,为本站带来更多注册会员
  • 宣传达人

    积极宣传本站,为本站带来更多的用户访问量
  • 灌水之王

    经常在论坛发帖,且发帖量较大
  • 突出贡献

    长期对论坛的繁荣而不断努力,或多次提出建设性意见
  • 优秀版主

    活跃且尽责职守的版主
  • 荣誉管理

    曾经为论坛做出突出贡献目前已离职的版主
  • 论坛元老

    为论坛做出突出贡献的会员

0关注

5粉丝

3421帖子

排行榜
作者专栏

QQ交流群&&微信订阅号

QQ交流群

微信订阅号

吾爱尚玩资源基地永久域名:

Www.523Play.Com

在线管理员QQ:1589479632

邮箱:Email@523play.com

QQ交流群:558936238

Copyright   ©2015-2116  吾爱尚玩资源基地|523play.comPowered by©523Pplay.Com技术支持:吾爱尚玩资源基地