吾爱尚玩资源基地
标题:
魔兽世界sf服务端mangos端中强制限制玩家速度的代码
[打印本页]
作者:
admin
时间:
2016-4-23 16:42
标题:
魔兽世界sf服务端mangos端中强制限制玩家速度的代码
比较老的代码了。现在已经有了很多其他的方式来实现玩家速度的控制,所以下面的代码只是以个参考
(供研究和学习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
欢迎光临 吾爱尚玩资源基地 (http://bbs.523play.com/)
Powered by Discuz! X3.4