关灯
开启左侧

魔兽世界sf服务端mangos端中强制限制玩家速度的代码

  [复制链接]
admin实名认证 发表于 2016-4-23 16:42:14 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
 
比较老的代码了。现在已经有了很多其他的方式来实现玩家速度的控制,所以下面的代码只是以个参考

(供研究和学习MANGOS使用)


Index: src/game/Player.cpp
===================================================================
--- src/game/Player.cpp (revision 6564)
+++ src/game/Player.cpp (working copy)
@@ -416,6 +416,15 @@
m_miniPet = 0;
m_bgAfkReportedTimer = 0;

+ baseMoveSpeed[MOVE_WALK] = 2.5f * sWorld.getRate(RATE_CHARSPEED);
+ baseMoveSpeed[MOVE_RUN] = 7.0f * sWorld.getRate(RATE_CHARSPEED);
+ baseMoveSpeed[MOVE_WALKBACK] = 1.25f * sWorld.getRate(RATE_CHARSPEED);
+ baseMoveSpeed[MOVE_SWIM] = 4.722222f * sWorld.getRate(RATE_CHARSPEED);
+ baseMoveSpeed[MOVE_SWIMBACK] = 4.5f * sWorld.getRate(RATE_CHARSPEED);
+ baseMoveSpeed[MOVE_TURN] = 3.141594f * sWorld.getRate(RATE_CHARSPEED);
+ baseMoveSpeed[MOVE_FLY] = 7.0f * sWorld.getRate(RATE_CHARSPEED);
+ baseMoveSpeed[MOVE_FLYBACK] = 4.5f * sWorld.getRate(RATE_CHARSPEED);
+
m_declinedname = NULL;
}

Index: src/game/Unit.cpp
===================================================================
--- src/game/Unit.cpp (revision 6564)
+++ src/game/Unit.cpp (working copy)
@@ -46,18 +46,6 @@

#include <math.h>

-float baseMoveSpeed[MAX_MOVE_TYPE] =
-{
- 2.5f, // MOVE_WALK
- 7.0f, // MOVE_RUN
- 1.25f, // MOVE_WALKBACK
- 4.722222f, // MOVE_SWIM
- 4.5f, // MOVE_SWIMBACK
- 3.141594f, // MOVE_TURN
- 7.0f, // MOVE_FLY
- 4.5f, // MOVE_FLYBACK
-};
-
// auraTypes contains attacker auras capable of proc'ing cast auras
static Unit::AuraTypeSet GenerateAttakerProcCastAuraTypes()
{
@@ -226,6 +214,16 @@
// remove aurastates allowing special moves
for(int i=0; i < MAX_REACTIVE; ++i)
m_reactiveTimer = 0;
+
+ baseMoveSpeed[MOVE_WALK] = 2.5f;
+ baseMoveSpeed[MOVE_RUN] = 7.0f;
+ baseMoveSpeed[MOVE_WALKBACK] = 1.25f;
+ baseMoveSpeed[MOVE_SWIM] = 4.722222f;
+ baseMoveSpeed[MOVE_SWIMBACK] = 4.5f;
+ baseMoveSpeed[MOVE_TURN] = 3.141594f;
+ baseMoveSpeed[MOVE_FLY] = 7.0f;
+ baseMoveSpeed[MOVE_FLYBACK] = 4.5f;
+
}

Unit::~Unit()
Index: src/game/Unit.h
===================================================================
--- src/game/Unit.h (revision 6564)
+++ src/game/Unit.h (working copy)
@@ -1267,6 +1267,8 @@

uint32 m_reactiveTimer[MAX_REACTIVE];

+ float baseMoveSpeed[MAX_MOVE_TYPE];
+
private:
void SendAttackStop(Unit* victim); // only from AttackStop(Unit*)
void SendAttackStart(Unit* pVictim); // only from Unit::AttackStart(Unit*)
Index: src/game/World.cpp
===================================================================
--- src/game/World.cpp (revision 6564)
+++ src/game/World.cpp (working copy)
@@ -386,6 +386,12 @@
sLog.outError("Rate.Talent (%f) mustbe > 0. Using 1 instead.",rate_values[RATE_TALENT]);
rate_values[RATE_TALENT] = 1;
}
+ rate_values[RATE_CHARSPEED] = sConfig.GetFloatDefault("Rate.CharSpeed",1);
+ if(rate_values[RATE_CHARSPEED] < 0)
+ {
+ sLog.outError("Rate.CharSpeed (%f) mustbe > 0. Using 1 instead.",rate_values[RATE_CHARSPEED]);
+ rate_values[RATE_CHARSPEED] = 1;
+ }
rate_values[RATE_CORPSE_DECAY_LOOTED] = sConfig.GetFloatDefault("Rate.Corpse.Decay.Looted",0.1f);

rate_values[RATE_TARGET_POS_RECALCULATION_RANGE] = sConfig.GetFloatDefault("TargetPosRecalculateRange",1.5f);
Index: src/game/World.h
===================================================================
--- src/game/World.h (revision 6564)
+++ src/game/World.h (working copy)
@@ -204,6 +204,7 @@
RATE_DURABILITY_LOSS_PARRY,
RATE_DURABILITY_LOSS_ABSORB,
RATE_DURABILITY_LOSS_BLOCK,
+ RATE_CHARSPEED,
MAX_RATES
};

Index: src/mangosd/mangosd.conf.in
===================================================================
--- src/mangosd/mangosd.conf.in (revision 6564)
+++ src/mangosd/mangosd.conf.in (working copy)
@@ -831,6 +831,9 @@
# Talent Point rates
# Default: 1
#
+# Rate.CharSpeed
+# Multiply the Default Player Speed (1 - Default, 1.4 - 40% faster, 0.5 - Half Movement Speed)
+#
# Rate.Reputation.Gain
# Reputation Gain rate
# Default: 1
@@ -912,6 +915,7 @@
Rate.Mining.Amount = 1
Rate.Mining.Next = 1
Rate.Talent = 1
+Rate.CharSpeed = 1
Rate.Reputation.Gain = 1
Rate.InstanceResetTime = 1
SkillGain.Crafting = 1
 
VIP介绍
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 最佳新人

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

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

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

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

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

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

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

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

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

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

0关注

5粉丝

3421帖子

排行榜
作者专栏

QQ交流群&&微信订阅号

QQ交流群

微信订阅号

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

Www.523Play.Com

在线管理员QQ:1589479632

邮箱:Email@523play.com

QQ交流群:558936238

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