EQEmulator Forums

EQEmulator Forums (https://www.eqemulator.org/forums/index.php)
-   Support::Windows Servers (https://www.eqemulator.org/forums/forumdisplay.php?f=587)
-   -   "sigh" bot question (https://www.eqemulator.org/forums/showthread.php?t=40058)

Nightrider84 10-01-2015 04:30 PM

It doesnt effect it, I thought it did.

Cilraaz 10-01-2015 04:37 PM

I'm really confused. You were talking about your bot's mana regen being too high. I suggested setting BotManaRegen to 1. You said that your bot started double-quadding.

Was the mana regen ever figured out?

Nightrider84 10-01-2015 04:40 PM

I tried 1 increased the regen, tried 5 didnt decrease it much. I noticed that my bot was quad hitting after the recompile with the stock bot.cpp. I thought it might have been due to the increase in the regen for whatever reason but It wasn't.
And I did delete the bot. I made a wood elf druid but it had the same effect.

Uleat 10-01-2015 04:51 PM

(Am I on the right thread??)

I think there was an issue with weapon speed and something - probably bots - sometime ago.

rencro 10-03-2015 02:15 PM

Nightrider, as to the rubberbanding you mentioned in the OP, as well as in http://www.eqemulator.org/forums/showthread.php?t=39870

If you revert the Haynar movement code pushed on 5-25-15 and all subsequent references to it then that issue goes away, but then you would need to restore all your npc runspeeds back to before the sql change made by 2015_06_30_runspeed_adjustments.sql

Mercs seem to work fine as compared to bots, but havent had time to really make the bots work like mercs in regards to movement, and my wife wants me to fix the leaky toilet we have..

Anyways, here is the revert to the haynar movement code ect to get bots back to normal movement.

Code:

diff --git a/zone/bot.cpp b/zone/bot.cpp
index 052f849..fd4e033 100644
--- a/zone/bot.cpp
+++ b/zone/bot.cpp
@@ -242,8 +242,12 @@ void Bot::ChangeBotArcherWeapons(bool isArcher) {
 
 void Bot::Sit() {
        if(IsMoving()) {
+                //SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget->GetY()));
                moved = false;
-                SetCurrentSpeed(0);
+                SendPosition(); //rencro -- revert haynar
+                SetMoving(false); //rencro -- revert haynar
+                //moved = false;
+                //SetCurrentSpeed(0);
                tar_ndx = 0;
        }
 
@@ -318,7 +322,7 @@ NPCType Bot::FillNPCTypeStruct(uint32 botSpellsID, std::string botName, std::str
        BotNPCType.d_melee_texture2 = 0;
        BotNPCType.qglobal = false;
        BotNPCType.attack_speed = 0;
-        BotNPCType.runspeed = 0.7f;
+        BotNPCType.runspeed = 1.25; //rencro -- revert haynar
        BotNPCType.bodytype = 1;
        BotNPCType.findable = 0;
        BotNPCType.hp_regen = 1;
@@ -349,7 +353,7 @@ NPCType Bot::CreateDefaultNPCTypeStructForBot(std::string botName, std::string b
        Result.drakkin_details = 0;
        Result.drakkin_heritage = 0;
        Result.drakkin_tattoo = 0;
-        Result.runspeed = 0.7f;
+        Result.runspeed = 1.25;
        Result.bodytype = 1;
        Result.findable = 0;
        Result.hp_regen = 1;
@@ -2478,9 +2482,13 @@ void Bot::AI_Process() {
                        if(IsMoving()) {
                                SetHeading(0);
                                SetRunAnimSpeed(0);
-                                SetCurrentSpeed(GetRunspeed());
-                                if(moved)
-                                        SetCurrentSpeed(0);
+                                //SetCurrentSpeed(GetRunspeed()); //rencro -- revert haynar
+                                if (moved) {
+                                        moved = false; //rencro -- revert haynar
+                                        SendPosition(); //rencro -- revert haynar
+                                        SetMoving(false); //rencro -- revert haynar
+                                        //SetCurrentSpeed(0);
+                                }
                        }
                        return;
                }
@@ -2516,10 +2524,12 @@ void Bot::AI_Process() {
                        if(IsMoving()) {
                                SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()));
                                SetRunAnimSpeed(0);
-                                SetCurrentSpeed(0);
+                                //SetCurrentSpeed(0); //rencro -- revert haynar
                                if(moved) {
                                        moved = false;
-                                        SetCurrentSpeed(0);
+                                        SendPosition(); //rencro -- revert haynar
+                                        SetMoving(false); //rencro -- revert haynar
+                                        //SetCurrentSpeed(0);
                                }
                        }
                        atCombatRange = true;
@@ -2533,10 +2543,12 @@ void Bot::AI_Process() {
                if(atCombatRange) {
                        if(IsMoving()) {
                                SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()));
-                                SetCurrentSpeed(0);
+                                //SetCurrentSpeed(0);
                                if(moved) {
                                        moved = false;
-                                        SetCurrentSpeed(0);
+                                        SendPosition(); //rencro -- revert haynar
+                                        SetMoving(false); //rencro -- revert haynar
+                                        //SetCurrentSpeed(0);
                                }
                        }
 
@@ -2718,7 +2730,8 @@ void Bot::AI_Process() {
                                Mob* follow = entity_list.GetMob(GetFollowID());
                                if(follow) {
                                        float dist = DistanceSquared(m_Position, follow->GetPosition());
-                                        int speed = follow->GetRunspeed();
+                                        float speed = follow->GetRunspeed(); //rencro -- revert haynar
+                                        //int speed = follow->GetRunspeed();
                                        if(dist < GetFollowDistance() + 1000)
                                                speed = follow->GetWalkspeed();
 
@@ -2730,7 +2743,9 @@ void Bot::AI_Process() {
                                        } else {
                                                if(moved) {
                                                        moved = false;
-                                                        SetCurrentSpeed(0);
+                                                        SendPosition(); //rencro --revert haynar
+                                                        SetMoving(false); //rencro -- revert haynar
+                                                        //SetCurrentSpeed(0);
                                                }
                                        }
                                }
@@ -2908,7 +2923,7 @@ void Bot::PetAIProcess() {
                                                botPet->SetHeading(botPet->GetTarget()->GetHeading());
                                                if(moved) {
                                                        moved = false;
-                                                        SetCurrentSpeed(0);
+                                                        //SetCurrentSpeed(0);
                                                        botPet->SendPosition();
                                                        botPet->SetMoving(false);
                                                }
@@ -2936,7 +2951,7 @@ void Bot::PetAIProcess() {
                                                botPet->SetHeading(botPet->GetTarget()->GetHeading());
                                                if(moved) {
                                                        moved = false;
-                                                        SetCurrentSpeed(0);
+                                                        //SetCurrentSpeed(0);
                                                        botPet->SendPosition();
                                                        botPet->SetMoving(false);
                                                }
@@ -8043,6 +8058,52 @@ bool Bot::CanHeal() {
 }
 
 bool Bot::CalculateNewPosition2(float x, float y, float z, float speed, bool checkZ) {
+        // 2.5625 is the inverse of 0.3902439. The only difference is in implementation.
+        // NOTE: You can not change just one of the constants below. They are the same number, just expressed inversly of each other.
+        // const float clientOverServerRatio = 2.5625f;
+        const float serverOverClientRatio = 0.3902439f;
+
+        // Use this block if using 2.5625 as the ratio.
+        // const int clientAnimationMovementRateTypeMultiple = 8;
+
+        //        WildcardX: These are valid rates and observations based on painstaking testing of the client response to these values
+        //
+        //
+        //        0 * 8 = 0 : No Movement
+        //        1 * 8 = 8 : Death Walk
+        //        2 * 8 = 16 : Slow Walk
+        //        3 * 8 = 24 : Normal Walk
+        //        4 * 8 = 32 : Jog
+        //        5 * 8 = 40 : Normal Run
+        //        6 * 8 = 48 : Faster Run
+        //        7 * 8 = 56 : Even Faster Run
+        //        8 * 8 = 64 : Fastest Yet Run (Bard Song Speed?)
+        //        9 * 8 = 72 : Faster Fastest Yet Run
+        //        10 * 8 = 80 : .... you get the idea, this is pretty fast
+        //        11 * 8 = 88 : .... warp speed anyone?
+        //        12 * 8 = 96 : .... transwarp drive was invented by gnomes in Norrath
+        //        13 * 8 = 104 : ... who needs warp drives when you can just displace through time and space?
+        //
+        //
+        //        You get the idea here with these... These seem to be "benchmark values" of animation movement and how fast
+        //        the client thinks the Mob is moving so it can make it all look seemless between updates from the server.
+        //        This chart is scalable by the client so you can pass an animation rate of 50 and get a "faster run" but not quite a "even faster run"
+
+        // Convert the Bot movement rate to a value the client understands based on the chart above
+        // Use this block if using 2.5625 as the ratio.
+        // speed *= clientMovementRateTypeMultiple;
+
+
+        // This sets the movement animation rate with the client
+        // Use this block if using 2.5625 as the ratio.
+        // pRunAnimSpeed = speed;
+        pRunAnimSpeed = ((serverOverClientRatio * 10.0f) * speed) * 10.0f;
+
+        // Now convert our "speed" from the value necessary for the client to animate the correct movement type rate to the server side speed
+        // Use this block if using 2.5625 as the ratio.
+        // speed *= serverOverClientRatio;
+        speed = pRunAnimSpeed / serverOverClientRatio;
+
        return MakeNewPositionAndSendUpdate(x, y, z, speed, checkZ);
 }
 
diff --git a/zone/command.cpp b/zone/command.cpp
index 75dec2b..ec0c283 100644
--- a/zone/command.cpp
+++ b/zone/command.cpp
@@ -1495,7 +1495,8 @@ void command_npcstats(Client *c, const Seperator *sep)
                c->Message(0, "Current HP: %i  Max HP: %i",  c->GetTarget()->GetHP(), c->GetTarget()->GetMaxHP());
                //c->Message(0, "Weapon Item Number: %s", c->GetTarget()->GetWeapNo());
                c->Message(0, "Gender: %i  Size: %f  Bodytype: %d",  c->GetTarget()->GetGender(), c->GetTarget()->GetSize(), c->GetTarget()->GetBodyType());
-                c->Message(0, "Runspeed: %.3f  Walkspeed: %.3f",  static_cast<float>(0.025f * c->GetTarget()->GetRunspeed()), static_cast<float>(0.025f * c->GetTarget()->GetWalkspeed()));
+                c->Message(0, "Runspeed: %f  Walkspeed: %f", c->GetTarget()->GetRunspeed(), c->GetTarget()->GetWalkspeed()); //rencro -- revert haynar
+                //c->Message(0, "Runspeed: %.3f  Walkspeed: %.3f",  static_cast<float>(0.025f * c->GetTarget()->GetRunspeed()), static_cast<float>(0.025f * c->GetTarget()->GetWalkspeed()));
                c->Message(0, "Spawn Group: %i  Grid: %i",  c->GetTarget()->CastToNPC()->GetSp2(), c->GetTarget()->CastToNPC()->GetGrid());
                c->Message(0, "EmoteID: %i",  c->GetTarget()->CastToNPC()->GetEmoteID());
                c->GetTarget()->CastToNPC()->QueryLoot(c);
diff --git a/zone/fearpath.cpp b/zone/fearpath.cpp
index 0fd5ffa..ae86379 100644
--- a/zone/fearpath.cpp
+++ b/zone/fearpath.cpp
@@ -123,6 +123,30 @@ void Mob::ProcessFlee()
        }
 }
 
+// rencro -- revert haynar, added back this function
+float Mob::GetFearSpeed()
+{
+        if (flee_mode) {
+                //we know ratio < FLEE_HP_RATIO
+                float speed = GetBaseRunspeed();
+                float ratio = GetHPRatio();
+                float multiplier = RuleR(Combat, FleeMultiplier);
+
+                if (GetSnaredAmount() > 40)
+                        multiplier = multiplier / 6.0f;
+
+                speed = speed * ratio * multiplier / 100;
+
+                //NPC will eventually stop. Snare speeds this up
+                if (speed < 0.09)
+                        speed = 0.0001f;
+
+                return speed;
+        }
+        //fear and blind use their normal run speed
+        return GetRunspeed();
+}
+
 void Mob::CalculateNewFearpoint()
 {
        if(RuleB(Pathing, Fear) && zone->pathing)
diff --git a/zone/merc.cpp b/zone/merc.cpp
index 936dfcc..9490a56 100644
--- a/zone/merc.cpp
+++ b/zone/merc.cpp
@@ -1460,7 +1460,9 @@ void Merc::AI_Process() {
 
                                if(moved) {
                                        moved = false;
-                                        SetCurrentSpeed(0);
+                                        SendPosition(); //rencro -- revert haynar
+                                        SetMoving(false); //rencro -- revert haynar
+                                        //SetCurrentSpeed(0);
                                }
                        }
 
@@ -1496,7 +1498,10 @@ void Merc::AI_Process() {
                                SetRunAnimSpeed(0);
 
                                if(moved) {
-                                        SetCurrentSpeed(0);
+                                        moved = false;
+                                        SendPosition(); //rencro -- revert haynar
+                                        SetMoving(false); //rencro -- revert haynar
+                                        //SetCurrentSpeed(0);
                                }
                        }
 
@@ -1707,7 +1712,8 @@ void Merc::AI_Process() {
                                if(follow)
                                {
                                        float dist = DistanceSquared(m_Position, follow->GetPosition());
-                                        int speed = GetRunspeed();
+                                        float speed = GetRunspeed(); //rencro -- revert haynar
+                                        //int speed = GetRunspeed();
 
                                        if(dist < GetFollowDistance() + 1000)
                                                speed = GetWalkspeed();
@@ -1724,8 +1730,11 @@ void Merc::AI_Process() {
                                        {
                                                if(moved)
                                                {
-                                                SetCurrentSpeed(0);
-                                                moved = false;
+                                                        moved = false; //rencro -- revert haynar
+                                                        SendPosition(); //rencro -- revert haynar
+                                                        SetMoving(false); //rencro -- revert haynar
+                                                        //SetCurrentSpeed(0);
+                                                        //moved = false;
                                                }
                                        }
                                }
diff --git a/zone/mob.cpp b/zone/mob.cpp
index 2bab84b..d3414a1 100644
--- a/zone/mob.cpp
+++ b/zone/mob.cpp
@@ -150,6 +150,8 @@ Mob::Mob(const char* in_name,
        size                = in_size;
        base_size        = size;
        runspeed        = in_runspeed;
+        /* rencro -- revert haynar */
+        /*
        // neotokyo: sanity check
        if (runspeed < 0 || runspeed > 20)
                runspeed = 1.25f;
@@ -171,7 +173,7 @@ Mob::Mob(const char* in_name,
 
 
        current_speed = base_runspeed;
-
+        */
        m_PlayerState        = 0;
 
 
@@ -574,6 +576,81 @@ bool Mob::IsInvisible(Mob* other) const
        return(false);
 }
 
+/* rencro -- revert haynar by adding back this function*/
+float Mob::_GetMovementSpeed(int mod) const
+{
+        // List of movement speed modifiers, including AAs & spells:
+        //http://everquest.allakhazam.com/db/item.html?item=1721 blah blah blah
+        if (IsRooted())
+                return 0.0f;
+        else if (IsPseudoRooted())
+                return 0.00001f;
+
+        float speed_mod = runspeed;
+
+        if (IsClient()) {
+                if (CastToClient()->GetGMSpeed()) {
+                        speed_mod = 3.125f;
+                        if (mod != 0)
+                                speed_mod += speed_mod * static_cast<float>(mod) / 100.0f;
+                        return speed_mod;
+                }
+                else {
+                        Mob *horse = entity_list.GetMob(CastToClient()->GetHorseId());
+                        if (horse) {
+                                speed_mod = horse->GetBaseRunspeed();
+                                if (mod != 0)
+                                        speed_mod += speed_mod * static_cast<float>(mod) / 100.0f;
+                                return speed_mod;
+                        }
+                }
+        }
+
+        int aa_mod = 0;
+        int spell_mod = 0;
+        int runspeedcap = RuleI(Character, BaseRunSpeedCap);
+        int movemod = 0;
+        float frunspeedcap = 0.0f;
+
+        runspeedcap += itembonuses.IncreaseRunSpeedCap + spellbonuses.IncreaseRunSpeedCap + aabonuses.IncreaseRunSpeedCap;
+        aa_mod += itembonuses.BaseMovementSpeed + spellbonuses.BaseMovementSpeed + aabonuses.BaseMovementSpeed;
+        spell_mod += spellbonuses.movementspeed + itembonuses.movementspeed;
+
+        //hard cap
+        if (runspeedcap > 225)
+                runspeedcap = 225;
+
+        if (spell_mod < 0)
+                movemod += spell_mod;
+        else if (spell_mod > aa_mod)
+                movemod = spell_mod;
+        else
+                movemod = aa_mod;
+
+        // cap negative movemods from snares mostly
+        if (movemod < -85)
+                movemod = -85;
+
+        if (movemod != 0)
+                speed_mod += speed_mod * static_cast<float>(movemod) / 100.0f;
+
+        //runspeed caps
+        frunspeedcap = static_cast<float>(runspeedcap) / 100.0f;
+        if (IsClient() && speed_mod > frunspeedcap)
+                speed_mod = frunspeedcap;
+
+        //apply final mod such as the -47 for walking
+        // use runspeed since it should stack with snares
+        // blah blah blah
+        if (mod != 0)
+                speed_mod += runspeed * static_cast<float>(mod) / 100.0f;
+
+        if (speed_mod <= 0.0f)
+                speed_mod = IsClient() ? 0.0001f : 0.0f;
+
+        return speed_mod;
+}
+/*
 int Mob::_GetWalkSpeed() const {
 
        if (IsRooted() || IsStunned() || IsMezzed())
@@ -794,7 +871,8 @@ int Mob::_GetFearSpeed() const {
 
        return speed_mod;
 }
-
+// Rencro -- revert haynar end blocks removed
+*/
 int32 Mob::CalcMaxMana() {
        switch (GetCasterClass()) {
                case 'I':
@@ -1101,7 +1179,7 @@ void Mob::FillSpawnStruct(NewSpawn_Struct* ns, Mob* ForWho)
        ns->spawn.max_hp        = 100;                //this field needs a better name
        ns->spawn.race                = race;
        ns->spawn.runspeed        = runspeed;
-        ns->spawn.walkspeed        = walkspeed;
+        ns->spawn.walkspeed = runspeed * 0.5f; //rencro -- revert haynar walkspeed;
        ns->spawn.class_        = class_;
        ns->spawn.gender        = gender;
        ns->spawn.level                = level;
@@ -1399,6 +1477,7 @@ void Mob::SendPosition()
        PlayerPositionUpdateServer_Struct* spu = (PlayerPositionUpdateServer_Struct*)app->pBuffer;
        MakeSpawnUpdateNoDelta(spu);
        move_tic_count = 0;
+        tar_ndx = 20; //rencro -- revert haynar
        entity_list.QueueClients(this, app, true);
        safe_delete(app);
 }
@@ -1504,7 +1583,8 @@ void Mob::ShowStats(Client* client)
                        if(n->respawn2 != 0)
                                spawngroupid = n->respawn2->SpawnGroupID();
                        client->Message(0, "  NPCID: %u  SpawnGroupID: %u Grid: %i LootTable: %u FactionID: %i SpellsID: %u ", GetNPCTypeID(),spawngroupid, n->GetGrid(), n->GetLoottableID(), n->GetNPCFactionID(), n->GetNPCSpellsID());
-                        client->Message(0, "  Accuracy: %i MerchantID: %i EmoteID: %i Runspeed: %.3f Walkspeed: %.3f", n->GetAccuracyRating(), n->MerchantType, n->GetEmoteID(), static_cast<float>(0.025f * n->GetRunspeed()), static_cast<float>(0.025f * n->GetWalkspeed()));
+                        //client->Message(0, "  Accuracy: %i MerchantID: %i EmoteID: %i Runspeed: %.3f Walkspeed: %.3f", n->GetAccuracyRating(), n->MerchantType, n->GetEmoteID(), static_cast<float>(0.025f * n->GetRunspeed()), static_cast<float>(0.025f * n->GetWalkspeed()));
+                        client->Message(0, "  Accuracy: %i MerchantID: %i EmoteID: %i Runspeed: %f Walkspeed: %f", n->GetAccuracyRating(), n->MerchantType, n->GetEmoteID(), n->GetRunspeed(), n->GetWalkspeed()); //rencro -- revert haynar
                        n->QueryLoot(client);
                }
                if (IsAIControlled()) {
@@ -5901,6 +5981,8 @@ void Mob::SendRemovePlayerState(PlayerState old_state)
        safe_delete(app);
 }
 
+/* rencro -- revert haynar*/
+/*
 void Mob::SetCurrentSpeed(int in){
        if (current_speed != in)
        {
@@ -5912,4 +5994,4 @@ void Mob::SetCurrentSpeed(int in){
                        SendPosition();
                }
        }
-}
+} */
diff --git a/zone/mob.h b/zone/mob.h
index 46a5f1a..07c2d1e 100644
--- a/zone/mob.h
+++ b/zone/mob.h
@@ -464,12 +464,16 @@ public:
        virtual void SetMoving(bool move) { moving = move; m_Delta = glm::vec4(); }
        virtual void GoToBind(uint8 bindnum = 0) { }
        virtual void Gate();
-        int GetWalkspeed() const { return(_GetWalkSpeed()); }
-        int GetRunspeed() const { return(_GetRunSpeed()); }
-        void SetCurrentSpeed(int in);
-        int GetBaseRunspeed() const { return base_runspeed; }
-        int GetBaseWalkspeed() const { return base_walkspeed; }
-        int GetBaseFearSpeed() const { return base_fearspeed; }
+        /* rencro -- revert haynar */       
+        float GetWalkspeed() const { return(_GetMovementSpeed(-47)); }
+        float GetRunspeed() const { return(_GetMovementSpeed(0)); }
+        float GetBaseRunspeed() const { return runspeed; }
+//        int GetWalkspeed() const { return(_GetWalkSpeed()); }
+//        int GetRunspeed() const { return(_GetRunSpeed()); }
+//        void SetCurrentSpeed(int in);
+//        int GetBaseRunspeed() const { return base_runspeed; }
+//        int GetBaseWalkspeed() const { return base_walkspeed; }
+//        int GetBaseFearSpeed() const { return base_fearspeed; }
        float GetMovespeed() const { return IsRunning() ? GetRunspeed() : GetWalkspeed(); }
        bool IsRunning() const { return m_is_running; }
        void SetRunning(bool val) { m_is_running = val; }
@@ -831,7 +835,8 @@ public:
 
        //old fear function
        //void SetFeared(Mob *caster, uint32 duration, bool flee = false);
-        int GetFearSpeed() { return _GetFearSpeed(); }
+        float GetFearSpeed(); //rencro -- revert haynar
+        //int GetFearSpeed() { return _GetFearSpeed(); }
        bool IsFeared() { return (spellbonuses.IsFeared || flee_mode); } // This returns true if the mob is feared or fleeing due to low HP
        inline void StartFleeing() { flee_mode = true; CalculateNewFearpoint(); }
        void ProcessFlee();
@@ -840,8 +845,11 @@ public:
 
        inline bool                        CheckAggro(Mob* other) {return hate_list.IsEntOnHateList(other);}
        float                                CalculateHeadingToTarget(float in_x, float in_y);
-        bool                                CalculateNewPosition(float x, float y, float z, int speed, bool checkZ = false, bool calcheading = true);
-        virtual bool                CalculateNewPosition2(float x, float y, float z, int speed, bool checkZ = true, bool calcheading = true);
+        //rencro -- revert haynar
+        //bool                                CalculateNewPosition(float x, float y, float z, int speed, bool checkZ = false, bool calcheading = true);
+        bool                                CalculateNewPosition(float x, float y, float z, float speed, bool checkZ = false);
+        //virtual bool                CalculateNewPosition2(float x, float y, float z, int speed, bool checkZ = true, bool calcheading = true);
+        virtual bool                CalculateNewPosition2(float x, float y, float z, float speed, bool checkZ = true);
        float                                CalculateDistance(float x, float y, float z);
        float                                GetGroundZ(float new_x, float new_y, float z_offset=0.0);
        void                                SendTo(float new_x, float new_y, float new_z);
@@ -911,8 +919,9 @@ public:
        Timer *GetSpecialAbilityTimer(int ability);
        void ClearSpecialAbilities();
        void ProcessSpecialAbilities(const std::string &str);
-        bool IsMoved() { return moved; }
-        void SetMoved(bool moveflag) { moved = moveflag; }
+        //rencro -- revert haynar
+//        bool IsMoved() { return moved; }
+//        void SetMoved(bool moveflag) { moved = moveflag; }
 
        Shielders_Struct shielder[MAX_SHIELDERS];
        Trade* trade;
@@ -996,10 +1005,12 @@ protected:
        void CommonDamage(Mob* other, int32 &damage, const uint16 spell_id, const SkillUseTypes attack_skill, bool &avoidable, const int8 buffslot, const bool iBuffTic, int special = 0);
        static uint16 GetProcID(uint16 spell_id, uint8 effect_index);
        float _GetMovementSpeed(int mod) const;
-        int _GetWalkSpeed() const;
-        int _GetRunSpeed() const;
-        int _GetFearSpeed() const;
-        virtual bool MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, bool checkZ);
+        // rencro -- revert haynar
+//        int _GetWalkSpeed() const;
+//        int _GetRunSpeed() const;
+//        int _GetFearSpeed() const;
+//        virtual bool MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, bool checkZ);
+        virtual bool MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, bool checkZ);
 
        virtual bool AI_EngagedCastCheck() { return(false); }
        virtual bool AI_PursueCastCheck() { return(false); }
@@ -1095,12 +1106,13 @@ protected:
        float base_size;
        float size;
        float runspeed;
-        float walkspeed;
-        float fearspeed;
-        int base_runspeed;
-        int base_walkspeed;
-        int base_fearspeed;
-        int current_speed;
+        //rencro -- revert haynar
+//        float walkspeed;
+//        float fearspeed;
+//        int base_runspeed;
+//        int base_walkspeed;
+//        int base_fearspeed;
+//        int current_speed;
 
        uint32 pLastChange;
        bool held;
diff --git a/zone/mob_ai.cpp b/zone/mob_ai.cpp
index c865484..5926863 100644
--- a/zone/mob_ai.cpp
+++ b/zone/mob_ai.cpp
@@ -339,7 +339,10 @@ bool NPC::AIDoSpellCast(uint8 i, Mob* tar, int32 mana_cost, uint32* oDontDoAgain
 
        //stop moving if were casting a spell and were not a bard...
        if(!IsBardSong(AIspells[i].spellid)) {
-                SetCurrentSpeed(0);
+                SetRunAnimSpeed(0); //rencro -- revert haynar
+                SendPosition(); //rencro revert haynar
+                SetMoving(false); //rencro revert haynar
+        //        SetCurrentSpeed(0); //rencro revert haynar
        }
 
        return CastSpell(AIspells[i].spellid, tar->GetID(), 1, AIspells[i].manacost == -2 ? 0 : -1, mana_cost, oDontDoAgainBefore, -1, -1, 0, &(AIspells[i].resist_adjust));
@@ -696,7 +699,10 @@ void Client::AI_SpellCast()
                        {
                                if(!IsBardSong(spell_to_cast))
                                {
-                                        SetCurrentSpeed(0);
+                                        SetRunAnimSpeed(0); //rencro -- revert haynar
+                                        SendPosition(); //rencro revert haynar
+                                        SetMoving(false); //rencro revert haynar
+                                //        SetCurrentSpeed(0); //rencro revert haynar
                                }
                                CastSpell(spell_to_cast, tar->GetID(), slot_to_use);
                                return;
@@ -710,7 +716,10 @@ void Client::AI_SpellCast()
                {
                        if(!IsBardSong(spell_to_cast))
                        {
-                                SetCurrentSpeed(0);
+                                SetRunAnimSpeed(0); //rencro -- revert haynar
+                                SendPosition(); //rencro revert haynar
+                                SetMoving(false); //rencro revert haynar
+                        //        SetCurrentSpeed(0); //rencro revert haynar
                        }
                        CastSpell(spell_to_cast, tar->GetID(), slot_to_use);
                        return;
@@ -766,16 +775,21 @@ void Client::AI_Process()
                                {
                                        if(GetTarget())
                                                SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()));
-                                        SetCurrentSpeed(0);
+                                        SetRunAnimSpeed(0); //rencro -- revert haynar
+                                        SendPosition(); //rencro revert haynar
+                                        SetMoving(false); //rencro revert haynar
+                          //        SetCurrentSpeed(0); //rencro revert haynar
                                }
                                //continue on to attack code, ensuring that we execute the engaged code
                                engaged = true;
                        } else {
                                if(AImovement_timer->Check()) {
+                                /*        rencro -- revert haynar
                                        int speed = GetFearSpeed();
                                        animation = speed;
                                        speed *= 2;
-                                        SetCurrentSpeed(speed);
+                                        SetCurrentSpeed(speed); */
+                                        animation = GetFearSpeed() * 21; //rencro - revert haynar
                                        // Check if we have reached the last fear point
                                        if ((std::abs(GetX() - m_FearWalkTarget.x) < 0.1) &&
                                            (std::abs(GetY() - m_FearWalkTarget.y) < 0.1)) {
@@ -783,18 +797,18 @@ void Client::AI_Process()
                                                CalculateNewFearpoint();
                                        }
                                        if(!RuleB(Pathing, Fear) || !zone->pathing)
-                                                CalculateNewPosition2(m_FearWalkTarget.x, m_FearWalkTarget.y, m_FearWalkTarget.z, speed, true);
+                                                CalculateNewPosition2(m_FearWalkTarget.x, m_FearWalkTarget.y, m_FearWalkTarget.z, GetFearSpeed(), true);
                                        else
                                        {
                                                bool WaypointChanged, NodeReached;
 
                                                glm::vec3 Goal = UpdatePath(m_FearWalkTarget.x, m_FearWalkTarget.y, m_FearWalkTarget.z,
-                                                                        speed, WaypointChanged, NodeReached);
+                                                                        GetFearSpeed(), WaypointChanged, NodeReached);
 
                                                if(WaypointChanged)
                                                        tar_ndx = 20;
 
-                                                CalculateNewPosition2(Goal.x, Goal.y, Goal.z, speed);
+                                                CalculateNewPosition2(Goal.x, Goal.y, Goal.z, GetFearSpeed());
                                        }
                                }
                                return;
@@ -833,12 +847,23 @@ void Client::AI_Process()
                        }
 
                        if (AImovement_timer->Check()) {
+                                // rencro -- begin harynar revert
+                                SetRunAnimSpeed(0);
+                        }
+                        if(IsMoving()) {
+                                SetMoving(false);
+                                moved = false;
+                                SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()));
+                                SendPosition();
+                                tar_ndx = 0;
+                                /*
                                if (CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()) !=
                                    m_Position.w) {
                                        SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()));
                                        SendPosition();
                                }
-                                SetCurrentSpeed(0);
+                                SetCurrentSpeed(0);
+                                // rencro -- end harnar revert for this block */
                        }
                        if (GetTarget() && !IsStunned() && !IsMezzed() && !GetFeigned()) {
                                if (attack_timer.Check()) {
@@ -858,31 +883,43 @@ void Client::AI_Process()
                } else {
                        if(!IsRooted())
                        {
-                                if(AImovement_timer->Check())
+                                //rencro -- revert haynar
+                                animation = 21 * GetRunspeed();
+                                if (!RuleB(Pathing, Aggro) || !zone->pathing)
+                                        CalculateNewPosition2(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(), GetRunspeed());
+                                else
+                        //        if(AImovement_timer->Check())
                                {
-                                        int newspeed = GetRunspeed();
-                                        animation = newspeed;
-                                        newspeed *= 2;
-                                        SetCurrentSpeed(newspeed);
-                                        if(!RuleB(Pathing, Aggro) || !zone->pathing)
-                                                CalculateNewPosition2(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(), newspeed);
-                                        else
-                                        {
-                                                bool WaypointChanged, NodeReached;
-                                                glm::vec3 Goal = UpdatePath(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(),
-                                                        GetRunspeed(), WaypointChanged, NodeReached);
-
-                                                if(WaypointChanged)
-                                                        tar_ndx = 20;
-
-                                                CalculateNewPosition2(Goal.x, Goal.y, Goal.z, newspeed);
-                                        }
+                                        bool WaypointChanged, NodeReached;
+                                        glm::vec3 Goal = UpdatePath(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(),
+                                                GetRunspeed(), WaypointChanged, NodeReached);
+                        //                int newspeed = GetRunspeed();
+                        //                animation = newspeed;
+                        //                newspeed *= 2;
+                        //                SetCurrentSpeed(newspeed);
+                        //                if(!RuleB(Pathing, Aggro) || !zone->pathing)
+                        //                        CalculateNewPosition2(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(), newspeed);
+                        //                else
+                        //                {
+                        //                        bool WaypointChanged, NodeReached;
+                        //                        glm::vec3 Goal = UpdatePath(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(),
+                        //                                GetRunspeed(), WaypointChanged, NodeReached);
+
+                                        if(WaypointChanged)
+                                                tar_ndx = 20;
+
+                                        CalculateNewPosition2(Goal.x, Goal.y, Goal.z, GetRunspeed());
+                                //                CalculateNewPosition2(Goal.x, Goal.y, Goal.z, newspeed);
+                                //        }
                                }
                        }
                        else if(IsMoving())
                        {
                                SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()));
-                                SetCurrentSpeed(0);
+                                SetRunAnimSpeed(0); //rencro -- revert haynar
+                                SendPosition(); //rencro revert haynar
+                                SetMoving(false); //rencro revert haynar
+                  //        SetCurrentSpeed(0); //rencro revert haynar
                        }
                }
                AI_SpellCast();
@@ -915,8 +952,12 @@ void Client::AI_Process()
                                return;
 
                        float dist = DistanceSquared(m_Position, owner->GetPosition());
-                        if (dist >= 400)
+                        if (dist >= 100) //rencro -- revert haynar
                        {
+                                float speed = dist >= 225 ? GetRunspeed() : GetWalkspeed(); // rencro -- revert haynar
+                                animation = 21 * speed; //rencro -- revert haynar
+                                CalculateNewPosition2(owner->GetX(), owner->GetY(), owner->GetZ(), speed); //rencro -- revert haynar
+                                /* Revert haynar this whole block
                                if(AImovement_timer->Check())
                                {
                                        int nspeed = (dist >= 5625 ? GetRunspeed() : GetWalkspeed());
@@ -925,14 +966,21 @@ void Client::AI_Process()
                                        SetCurrentSpeed(nspeed);
 
                                        CalculateNewPosition2(owner->GetX(), owner->GetY(), owner->GetZ(), nspeed);
-                                }
+                                } */
                        }
                        else
                        {
+                                SetHeading(owner->GetHeading()); //rencro -- revert haynar
                                if(moved)
                                {
-                                        SetCurrentSpeed(0);
+                                        /* rencro -- revert haynar start block*/
                                        moved = false;
+                                        SetMoving(false);
+                                        SendPosition();
+                                        SetRunAnimSpeed(0);
+                                //        SetCurrentSpeed(0);
+                                //        moved = false;
+                                        /* rencro -- revert haynar end block*/
                                }
                        }
                }
@@ -962,7 +1010,10 @@ void Mob::AI_Process() {
                                {
                                        if(target)
                                                SetHeading(CalculateHeadingToTarget(target->GetX(), target->GetY()));
-                                        SetCurrentSpeed(0);
+                                        SetRunAnimSpeed(0); //rencro -- revert haynar
+                                        SendPosition(); //rencro revert haynar
+                                        SetMoving(false); //rencro revert haynar
+                                //        SetCurrentSpeed(0); //rencro revert haynar
                                        moved=false;
                                }
                                //continue on to attack code, ensuring that we execute the engaged code
@@ -1076,21 +1127,30 @@ void Mob::AI_Process() {
                {
                        if (AImovement_timer->Check())
                        {
-                                if(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()) != m_Position.w)
-                                {
-                                        SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()));
-                                        SendPosition();
-                                }
-                                SetCurrentSpeed(0);
+                                /* rencro -- revert haynar begin block */
+                //                if(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()) != m_Position.w)
+                //                {
+                //                        SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()));
+                //                        SendPosition();
+                //                }
+                //                SetCurrentSpeed(0);
+                                SetRunAnimSpeed(0); //rencro -- revert haynar end block
                        }
                        if(IsMoving())
                        {
-                                if(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()) != m_Position.w)
-                                {
-                                        SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()));
-                                        SendPosition();
-                                }
-                                SetCurrentSpeed(0);
+                                /* rencro -- revert haynar begin*/
+                                SetMoving(false);
+                                moved = false;
+                                SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()));
+                                SendPosition();
+                                tar_ndx = 0;
+                        //        if(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()) != m_Position.w)
+                        //        {
+                        //                SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()));
+                        //                SendPosition();
+                        //        }
+                        //        SetCurrentSpeed(0);
+                                /* rencro -- revert haynar end block*/
                        }
 
                        //casting checked above...
@@ -1303,8 +1363,10 @@ void Mob::AI_Process() {
                                        }
                                        else if(IsMoving()) {
                                                SetHeading(CalculateHeadingToTarget(target->GetX(), target->GetY()));
-                                                SetCurrentSpeed(0);
-
+                                                SetRunAnimSpeed(0); //rencro -- revert haynar
+                                                SendPosition(); //rencro revert haynar
+                                                SetMoving(false); //rencro revert haynar
+                                        //        SetCurrentSpeed(0); //rencro revert haynar
                                        }
                                }
                        }
@@ -1356,6 +1418,7 @@ void Mob::AI_Process() {
                }
                else if (AImovement_timer->Check() && !IsRooted())
                {
+                        SetRunAnimSpeed(0); //rencro -- revert haynar
                        if (IsPet())
                        {
                                // we're a pet, do as we're told
@@ -1374,7 +1437,8 @@ void Mob::AI_Process() {
                                                float dist = DistanceSquared(m_Position, owner->GetPosition());
                                                if (dist >= 400)
                                                {
-                                                        int speed = GetWalkspeed();
+                                                        float speed = GetWalkspeed(); //rencro -- revert haynar
+                                        //                int speed = GetWalkspeed();
                                                        if (dist >= 5625)
                                                                speed = GetRunspeed();
 
@@ -1382,10 +1446,14 @@ void Mob::AI_Process() {
                                                }
                                                else
                                                {
+                                        //                SetHeading(owner->GetHeading()); //rencro -- revert haynar (i think)
                                                        if(moved)
                                                        {
-                                                                SetCurrentSpeed(0);
-                                                                moved = false;
+                                                                moved = false; //rencro -- revert haynar
+                                                                SetMoving(false); // rencro -- revert haynar
+                                                                SendPosition(); //rencro -- revert haynar
+                                        //                        SetCurrentSpeed(0);
+                                        //                        moved = false;
                                                        }
                                                }
 
@@ -1431,15 +1499,22 @@ void Mob::AI_Process() {
 
                                        if (dist2 >= followdist)        // Default follow distance is 100
                                        {
-                                                int speed = GetWalkspeed();
+                                                float speed = GetWalkspeed(); //rencro -- revert haynar
+                        //                        int speed = GetWalkspeed();
                                                if (dist2 >= followdist + 150)
                                                        speed = GetRunspeed();
                                                CalculateNewPosition2(follow->GetX(), follow->GetY(), follow->GetZ(), speed);
                                        }
                                        else
                                        {
-                                                moved = false;
-                                                SetCurrentSpeed(0);
+                                                if (moved) //rencro -- revert haynar
+                                                {
+                                                        moved = false; //rencro -- revert haynar
+                                                        SetMoving(false); //rencro -- revert haynar
+                                                        SendPosition(); //rencro -- revert haynar
+                                                }
+                        //                        moved = false;
+                        //                        SetCurrentSpeed(0);
                                        }
                                }
                        }
@@ -1632,13 +1707,15 @@ void NPC::AI_DoMovement() {
                                Log.Out(Logs::Detail, Logs::AI, "Reached guard point (%.3f,%.3f,%.3f)", m_GuardPoint.x, m_GuardPoint.y, m_GuardPoint.z);
                                ClearFeignMemory();
                                moved=false;
+                                SetMoving(false); //rencro -- revert haynar
                                if (GetTarget() == nullptr || DistanceSquared(m_Position, GetTarget()->GetPosition()) >= 5*5 )
                                {
                                        SetHeading(m_GuardPoint.w);
                                } else {
                                        FaceTarget(GetTarget());
                                }
-                                SetCurrentSpeed(0);
+                                SendPosition(); //rencro -- revert haynar
+                //                SetCurrentSpeed(0);
                                SetAppearance(GetGuardPointAnim());
                        }
                }
@@ -1758,10 +1835,12 @@ void Mob::AI_Event_NoLongerEngaged() {
                pLastFightingDelayMoving += zone->random.Int(minLastFightingDelayMoving, maxLastFightingDelayMoving);
        // So mobs don't keep running as a ghost until AIwalking_timer fires
        // if they were moving prior to losing all hate
+        if(IsMoving()) { //rencro -- revert haynar
        // except if we're a pet, then we might run into some issues with pets backing off when they should immediately be moving
-        if(!IsPet())
-        {
+//        if(!IsPet())
+//        {
                SetRunAnimSpeed(0);
+                SetMoving(false); //rencro -- revert haybar
                SendPosition();
        }
        ClearRampage();
diff --git a/zone/npc.cpp b/zone/npc.cpp
index 8dbab7c..f549bdb 100644
--- a/zone/npc.cpp
+++ b/zone/npc.cpp
@@ -1942,11 +1942,12 @@ void NPC::ModifyNPCStat(const char *identifier, const char *newValue)
        else if(id == "PhR") { PhR = atoi(val.c_str()); return; }
        else if(id == "runspeed") {
                runspeed = (float)atof(val.c_str());
-                base_runspeed = (int)((float)runspeed * 40.0f);
-                base_walkspeed = base_runspeed * 100 / 265;
-                walkspeed = ((float)base_walkspeed) * 0.025f;
-                base_fearspeed = base_runspeed * 100 / 127;
-                fearspeed = ((float)base_fearspeed) * 0.025f;
+                /* rencro -- revert haynar */
+//                base_runspeed = (int)((float)runspeed * 40.0f);
+//                base_walkspeed = base_runspeed * 100 / 265;
+//                walkspeed = ((float)base_walkspeed) * 0.025f;
+//                base_fearspeed = base_runspeed * 100 / 127;
+//                fearspeed = ((float)base_fearspeed) * 0.025f;
                CalcBonuses(); return;
        }
        else if(id == "special_attacks") { NPCSpecialAttacks(val.c_str(), 0, 1); return; }
diff --git a/zone/spells.cpp b/zone/spells.cpp
index 9ff8458..62fb3e2 100644
--- a/zone/spells.cpp
+++ b/zone/spells.cpp
@@ -4775,12 +4775,16 @@ void Client::UnStun() {
 
 void NPC::Stun(int duration) {
        Mob::Stun(duration);
-        SetCurrentSpeed(0);
+        SetRunAnimSpeed(0); //rencro -- revert Haynar runspeed changes
+        SendPosition(); //rencro -- revert Haynar
+        //SetCurrentSpeed(0);
 }
 
 void NPC::UnStun() {
        Mob::UnStun();
-        SetCurrentSpeed(GetRunspeed());
+        SetRunAnimSpeed(0); //rencro -- revert Haynar runspeed changes
+        SendPosition(); //rencro -- revert Haynar
+        //SetCurrentSpeed(GetRunspeed());
 }
 
 void Mob::Mesmerize()
diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp
index e900c68..7cd3502 100644
--- a/zone/waypoints.cpp
+++ b/zone/waypoints.cpp
@@ -438,7 +438,9 @@ void NPC::NextGuardPosition() {
                if(moved)
                {
                        moved = false;
-                        SetCurrentSpeed(0);
+                        SetMoving(false); //rencro -- revert haynar
+                        SendPosition(); //rencro -- revert haynar
+                        //SetCurrentSpeed(0);
                }
        }
 }
@@ -468,16 +470,17 @@ float Mob::CalculateHeadingToTarget(float in_x, float in_y) {
        return (256*(360-angle)/360.0f);
 }
 
-bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, bool checkZ) {
+//bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, bool checkZ) {
+bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, float speed, bool checkZ) {
        if(GetID()==0)
                return true;
-
+        /* //rencro -- revert haynar
        if(speed <= 0)
        {
                SetCurrentSpeed(0);
                return true;
        }
-
+        */
        if ((m_Position.x-x == 0) && (m_Position.y-y == 0)) {//spawn is at target coords
                if(m_Position.z-z != 0) {
                        m_Position.z = z;
@@ -572,12 +575,13 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo
        m_TargetV.x = x - nx;
        m_TargetV.y = y - ny;
        m_TargetV.z = z - nz;
+        /* //rencro -- revert haynar
        SetCurrentSpeed((int8)speed);
        pRunAnimSpeed = speed;
        if(IsClient())
        {
                animation = speed / 2;
-        }
+        } */
        //pRunAnimSpeed = (int8)(speed*NPC_RUNANIM_RATIO);
        //speed *= NPC_SPEED_MULTIPLIER;
 
@@ -587,7 +591,8 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo
        // 2: get unit vector
        // --------------------------------------------------------------------------
        float mag = sqrtf (m_TargetV.x*m_TargetV.x + m_TargetV.y*m_TargetV.y + m_TargetV.z*m_TargetV.z);
-        tar_vector = (float)speed / mag;
+        //tar_vector = (float)speed / mag;
+        tar_vector = speed / mag; //rencro -- revert haynar
 
 // mob move fix
        int numsteps = (int) ( mag * 16.0f / (float)speed + 0.5f);
@@ -600,9 +605,12 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo
                if (numsteps>1)
                {
                        tar_vector=1.0f        ;
-                        m_TargetV.x = m_TargetV.x/(float)numsteps;
-                        m_TargetV.y = m_TargetV.y/(float)numsteps;
-                        m_TargetV.z = m_TargetV.z/(float)numsteps;
+                        m_TargetV.x = m_TargetV.x / numsteps; //rencro
+                        m_TargetV.y = m_TargetV.y / numsteps; //rencro -- revert haynar
+                        m_TargetV.z = m_TargetV.z / numsteps; //rencro
+//                        m_TargetV.x = m_TargetV.x/(float)numsteps;
+//                        m_TargetV.y = m_TargetV.y/(float)numsteps;
+//                        m_TargetV.z = m_TargetV.z/(float)numsteps;
 
                        float new_x = m_Position.x + m_TargetV.x;
                        float new_y = m_Position.y + m_TargetV.y;
@@ -628,13 +636,15 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo
                        m_Position.y = y;
                        m_Position.z = z;
 
+                        tar_ndx = 20; //rencro -- revert haynar
                        Log.Out(Logs::Detail, Logs::AI, "Only a single step to get there... jumping.");
 
                }
        }
 
        else {
-                tar_vector/=16.0f;
+                tar_vector /= 20.0f; //rencro -- revert haynar
+                //tar_vector/=16.0f;
                float dur = Timer::GetCurrentTime() - pLastChange;
                if(dur < 1.0f) {
                        dur = 1.0f;
@@ -701,19 +711,25 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo
        }
        else
        {
+                move_tic_count = RuleI(Zone, NPCPositonUpdateTicCount); //rencro -- revert haynar (WTF is Positon??)
                SendPosUpdate();
                SetAppearance(eaStanding, false);
        }
-
        pLastChange = Timer::GetCurrentTime();
        return true;
 }
 
-bool Mob::CalculateNewPosition2(float x, float y, float z, int speed, bool checkZ, bool calcHeading) {
+//bool Mob::CalculateNewPosition2(float x, float y, float z, int speed, bool checkZ, bool calcHeading) {
+bool Mob::CalculateNewPosition2(float x, float y, float z, float speed, bool checkZ) { //rencro -- revert haynar whole funtion
+        if (IsNPC() || IsClient() || IsPet()) {
+                pRunAnimSpeed = (int8)(speed*NPC_RUNANIM_RATIO);
+                speed *= NPC_SPEED_MULTIPLIER;
+        }
        return MakeNewPositionAndSendUpdate(x, y, z, speed, checkZ);
 }
 
-bool Mob::CalculateNewPosition(float x, float y, float z, int speed, bool checkZ, bool calcHeading) {
+//bool Mob::CalculateNewPosition(float x, float y, float z, int speed, bool checkZ, bool calcHeading) {
+bool Mob::CalculateNewPosition(float x, float y, float z, float speed, bool checkZ) { //rencro -- revert haynar
        if(GetID()==0)
                return true;
 
@@ -722,10 +738,13 @@ bool Mob::CalculateNewPosition(float x, float y, float z, int speed, bool checkZ
        float nz = m_Position.z;
 
        // if NPC is rooted
-        if (speed == 0) {
+        //if (speed == 0) {
+        if (speed == 0.0) { //rencro -- revert haynar
                SetHeading(CalculateHeadingToTarget(x, y));
                if(moved){
-                        SetCurrentSpeed(0);
+                        SendPosition(); //rencro -- revert haynar
+                        SetMoving(false); //rencro -- revert harnar
+                        //SetCurrentSpeed(0);
                        moved=false;
                }
                Log.Out(Logs::Detail, Logs::AI, "Rooted while calculating new position to (%.3f, %.3f, %.3f)", x, y, z);
@@ -739,8 +758,10 @@ bool Mob::CalculateNewPosition(float x, float y, float z, int speed, bool checkZ
 
        if (m_TargetV.x == 0 && m_TargetV.y == 0)
                return false;
-        SetCurrentSpeed((int8)(speed)); //*NPC_RUNANIM_RATIO);
-        //speed *= NPC_SPEED_MULTIPLIER;
+        /* rencro -- revert haynar*/
+        pRunAnimSpeed = (uint8)(speed*NPC_RUNANIM_RATIO);
+        speed *= NPC_SPEED_MULTIPLIER;
+        //SetCurrentSpeed((int8)(speed)); //*NPC_RUNANIM_RATIO);
 
        Log.Out(Logs::Detail, Logs::AI, "Calculating new position to (%.3f, %.3f, %.3f) vector (%.3f, %.3f, %.3f) rate %.3f RAS %d", x, y, z, m_TargetV.x, m_TargetV.y, m_TargetV.z, speed, pRunAnimSpeed);

When I get more time I will try to re-implement Haynar and make the bot movement use this older movement version. Of course, getting bots to work "with" haynar would be best but haven't had much success there yet.

Nightrider84 10-03-2015 06:39 PM

so basically the haynar update changed all the npc's run speed and if I revert it then my run speed will stay at the adjusted speed and ill hafto find the default for them all

rencro 10-04-2015 03:06 AM

Worked on this some more, put haynar back in except for bots area, and bot follow is not too bad, too tired to do the rest of the bot movement stuff tonight but hoping to post this before Monday.

Nightrider84 10-04-2015 07:30 PM

That would be fantastic if the bot movement issue got fixed. Also any damage based spells bots cast show up twice when they strike an enemy. So when hitting with a weapon and hitting with a spell the damage hits twice. Im lost for the time being lol

rencro 10-04-2015 11:18 PM

Heres where I'm at, this uses its own code for bots movement while leaving haynars untouched for use with all other mob entities. I applied this to code pulled on 3 Oct 2015 and ran ok.

At least can have ok movement until someone is able to fix bots to work with haynar's movement code. Also, I did get my toilet fixed..

Code:

diff --git a/zone/bot.cpp b/zone/bot.cpp
index cbc951c..4a6e8af 100644
--- a/zone/bot.cpp
+++ b/zone/bot.cpp
@@ -242,8 +242,10 @@ void Bot::ChangeBotArcherWeapons(bool isArcher) {
 
 void Bot::Sit() {
        if(IsMoving()) {
+                //SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget->GetY()));
                moved = false;
-                SetCurrentSpeed(0);
+                SendPosition(); //rencro -- revert haynar on bots
+                SetMoving(false); //rencro -- revert haynar on bots
                tar_ndx = 0;
        }
 
@@ -318,7 +320,7 @@ NPCType Bot::FillNPCTypeStruct(uint32 botSpellsID, std::string botName, std::str
        BotNPCType.d_melee_texture2 = 0;
        BotNPCType.qglobal = false;
        BotNPCType.attack_speed = 0;
-        BotNPCType.runspeed = 0.7f;
+        BotNPCType.runspeed = 1.25; //rencro -- revert haynar on bots
        BotNPCType.bodytype = 1;
        BotNPCType.findable = 0;
        BotNPCType.hp_regen = 1;
@@ -349,7 +351,7 @@ NPCType Bot::CreateDefaultNPCTypeStructForBot(std::string botName, std::string b
        Result.drakkin_details = 0;
        Result.drakkin_heritage = 0;
        Result.drakkin_tattoo = 0;
-        Result.runspeed = 0.7f;
+        Result.runspeed = 1.25; //rencro revert haynar on bots
        Result.bodytype = 1;
        Result.findable = 0;
        Result.hp_regen = 1;
@@ -2403,7 +2405,7 @@ void Bot::AI_Process() {
                                } else if(!IsRooted()) {
                                        if(GetTarget() && GetTarget()->GetHateTop() && GetTarget()->GetHateTop() != this) {
                                                Log.Out(Logs::Detail, Logs::AI, "Returning to location prior to being summoned.");
-                                                CalculateNewPosition2(m_PreSummonLocation.x, m_PreSummonLocation.y, m_PreSummonLocation.z, GetRunspeed());
+                                                CalculateNewPosition2(m_PreSummonLocation.x, m_PreSummonLocation.y, m_PreSummonLocation.z, GetBotRunspeed()); //rencro
                                                SetHeading(CalculateHeadingToTarget(m_PreSummonLocation.x, m_PreSummonLocation.y));
                                                return;
                                        }
@@ -2478,9 +2480,11 @@ void Bot::AI_Process() {
                        if(IsMoving()) {
                                SetHeading(0);
                                SetRunAnimSpeed(0);
-                                SetCurrentSpeed(GetRunspeed());
-                                if(moved)
-                                        SetCurrentSpeed(0);
+                                if (moved) {
+                                        moved = false; //rencro -- revert haynar on bots
+                                        SendPosition(); //rencro -- revert haynar on bots
+                                        SetMoving(false); //rencro -- revert haynar on bots
+                                }
                        }
                        return;
                }
@@ -2516,10 +2520,10 @@ void Bot::AI_Process() {
                        if(IsMoving()) {
                                SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()));
                                SetRunAnimSpeed(0);
-                                SetCurrentSpeed(0);
                                if(moved) {
                                        moved = false;
-                                        SetCurrentSpeed(0);
+                                        SendPosition(); //rencro -- revert haynar on bots
+                                        SetMoving(false); //rencro -- revert haynar on bots
                                }
                        }
                        atCombatRange = true;
@@ -2533,10 +2537,10 @@ void Bot::AI_Process() {
                if(atCombatRange) {
                        if(IsMoving()) {
                                SetHeading(CalculateHeadingToTarget(GetTarget()->GetX(), GetTarget()->GetY()));
-                                SetCurrentSpeed(0);
                                if(moved) {
                                        moved = false;
-                                        SetCurrentSpeed(0);
+                                        SendPosition(); //rencro -- revert haynar on bots
+                                        SetMoving(false); //rencro -- revert haynar on bots
                                }
                        }
 
@@ -2547,7 +2551,7 @@ void Bot::AI_Process() {
                                        float newY = 0;
                                        float newZ = 0;
                                        if(PlotPositionAroundTarget(GetTarget(), newX, newY, newZ)) {
-                                                CalculateNewPosition2(newX, newY, newZ, GetRunspeed());
+                                                CalculateNewPosition2(newX, newY, newZ, GetBotRunspeed()); //rencro
                                                return;
                                        }
                                }
@@ -2557,7 +2561,7 @@ void Bot::AI_Process() {
                                        float newY = 0;
                                        float newZ = 0;
                                        if(PlotPositionAroundTarget(GetTarget(), newX, newY, newZ, false) && GetArchetype() != ARCHETYPE_CASTER) {
-                                                CalculateNewPosition2(newX, newY, newZ, GetRunspeed());
+                                                CalculateNewPosition2(newX, newY, newZ, GetBotRunspeed()); //rencro
                                                return;
                                        }
                                }
@@ -2679,7 +2683,7 @@ void Bot::AI_Process() {
                        if (AImovement_timer->Check()) {
                                if(!IsRooted()) {
                                        Log.Out(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", GetTarget()->GetCleanName());
-                                        CalculateNewPosition2(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(), GetRunspeed());
+                                        CalculateNewPosition2(GetTarget()->GetX(), GetTarget()->GetY(), GetTarget()->GetZ(), GetBotRunspeed()); //rencro
                                        return;
                                }
 
@@ -2718,9 +2722,9 @@ void Bot::AI_Process() {
                                Mob* follow = entity_list.GetMob(GetFollowID());
                                if(follow) {
                                        float dist = DistanceSquared(m_Position, follow->GetPosition());
-                                        int speed = follow->GetRunspeed();
+                                        float speed = follow->GetBotRunspeed(); //rencro -- revert haynar on bots 0.6999..
                                        if(dist < GetFollowDistance() + 1000)
-                                                speed = follow->GetWalkspeed();
+                                                speed = follow->GetBotWalkspeed();
 
                                        if(dist > GetFollowDistance()) {
                                                CalculateNewPosition2(follow->GetX(), follow->GetY(), follow->GetZ(), speed);
@@ -2730,7 +2734,8 @@ void Bot::AI_Process() {
                                        } else {
                                                if(moved) {
                                                        moved = false;
-                                                        SetCurrentSpeed(0);
+                                                        SendPosition(); //rencro --revert haynar on bots
+                                                        SetMoving(false); //rencro -- revert haynar on bots
                                                }
                                        }
                                }
@@ -2797,14 +2802,14 @@ void Bot::PetAIProcess() {
                                if(botPet->GetClass() == ROGUE && !petHasAggro && !botPet->BehindMob(botPet->GetTarget(), botPet->GetX(), botPet->GetY())) {
                                        // Move the rogue to behind the mob
                                        if(botPet->PlotPositionAroundTarget(botPet->GetTarget(), newX, newY, newZ)) {
-                                                botPet->CalculateNewPosition2(newX, newY, newZ, botPet->GetRunspeed());
+                                                botPet->CalculateNewPosition2(newX, newY, newZ, botPet->GetBotRunspeed()); //rencro
                                                return;
                                        }
                                }
                                else if(GetTarget() == botPet->GetTarget() && !petHasAggro && !botPet->BehindMob(botPet->GetTarget(), botPet->GetX(), botPet->GetY())) {
                                        // If the bot owner and the bot are fighting the same mob, then move the pet to the rear arc of the mob
                                        if(botPet->PlotPositionAroundTarget(botPet->GetTarget(), newX, newY, newZ)) {
-                                                botPet->CalculateNewPosition2(newX, newY, newZ, botPet->GetRunspeed());
+                                                botPet->CalculateNewPosition2(newX, newY, newZ, botPet->GetBotRunspeed()); //rencro
                                                return;
                                        }
                                }
@@ -2819,7 +2824,7 @@ void Bot::PetAIProcess() {
                                                moveBehindMob = true;
 
                                        if(botPet->PlotPositionAroundTarget(botPet->GetTarget(), newX, newY, newZ, moveBehindMob)) {
-                                                botPet->CalculateNewPosition2(newX, newY, newZ, botPet->GetRunspeed());
+                                                botPet->CalculateNewPosition2(newX, newY, newZ, botPet->GetBotRunspeed()); //rencro
                                                return;
                                        }
                                }
@@ -2902,13 +2907,13 @@ void Bot::PetAIProcess() {
                                        botPet->SetRunAnimSpeed(0);
                                        if(!botPet->IsRooted()) {
                                                Log.Out(Logs::Detail, Logs::AI, "Pursuing %s while engaged.", botPet->GetTarget()->GetCleanName());
-                                                botPet->CalculateNewPosition2(botPet->GetTarget()->GetX(), botPet->GetTarget()->GetY(), botPet->GetTarget()->GetZ(), botPet->GetOwner()->GetRunspeed());
+                                                botPet->CalculateNewPosition2(botPet->GetTarget()->GetX(), botPet->GetTarget()->GetY(), botPet->GetTarget()->GetZ(), botPet->GetOwner()->GetBotRunspeed()); //rencro
                                                return;
                                        } else {
                                                botPet->SetHeading(botPet->GetTarget()->GetHeading());
                                                if(moved) {
                                                        moved = false;
-                                                        SetCurrentSpeed(0);
+                                                        //SetCurrentSpeed(0);
                                                        botPet->SendPosition();
                                                        botPet->SetMoving(false);
                                                }
@@ -2930,13 +2935,13 @@ void Bot::PetAIProcess() {
                                        float dist = DistanceSquared(botPet->GetPosition(), botPet->GetTarget()->GetPosition());
                                        botPet->SetRunAnimSpeed(0);
                                        if(dist > 184) {
-                                                botPet->CalculateNewPosition2(botPet->GetTarget()->GetX(), botPet->GetTarget()->GetY(), botPet->GetTarget()->GetZ(), botPet->GetTarget()->GetRunspeed());
+                                                botPet->CalculateNewPosition2(botPet->GetTarget()->GetX(), botPet->GetTarget()->GetY(), botPet->GetTarget()->GetZ(), botPet->GetTarget()->GetBotRunspeed()); //rencro
                                                return;
                                        } else {
                                                botPet->SetHeading(botPet->GetTarget()->GetHeading());
                                                if(moved) {
                                                        moved = false;
-                                                        SetCurrentSpeed(0);
+                                                        //SetCurrentSpeed(0);
                                                        botPet->SendPosition();
                                                        botPet->SetMoving(false);
                                                }
@@ -8043,7 +8048,53 @@ bool Bot::CanHeal() {
 }
 
 bool Bot::CalculateNewPosition2(float x, float y, float z, float speed, bool checkZ) {
-        return MakeNewPositionAndSendUpdate(x, y, z, speed, checkZ);
+        // 2.5625 is the inverse of 0.3902439. The only difference is in implementation.
+        // NOTE: You can not change just one of the constants below. They are the same number, just expressed inversly of each other.
+        // const float clientOverServerRatio = 2.5625f;
+        const float serverOverClientRatio = 0.3902439f;
+
+        // Use this block if using 2.5625 as the ratio.
+        // const int clientAnimationMovementRateTypeMultiple = 8;
+
+        //        WildcardX: These are valid rates and observations based on painstaking testing of the client response to these values
+        //
+        //
+        //        0 * 8 = 0 : No Movement
+        //        1 * 8 = 8 : Death Walk
+        //        2 * 8 = 16 : Slow Walk
+        //        3 * 8 = 24 : Normal Walk
+        //        4 * 8 = 32 : Jog
+        //        5 * 8 = 40 : Normal Run
+        //        6 * 8 = 48 : Faster Run
+        //        7 * 8 = 56 : Even Faster Run
+        //        8 * 8 = 64 : Fastest Yet Run (Bard Song Speed?)
+        //        9 * 8 = 72 : Faster Fastest Yet Run
+        //        10 * 8 = 80 : .... you get the idea, this is pretty fast
+        //        11 * 8 = 88 : .... warp speed anyone?
+        //        12 * 8 = 96 : .... transwarp drive was invented by gnomes in Norrath
+        //        13 * 8 = 104 : ... who needs warp drives when you can just displace through time and space?
+        //
+        //
+        //        You get the idea here with these... These seem to be "benchmark values" of animation movement and how fast
+        //        the client thinks the Mob is moving so it can make it all look seemless between updates from the server.
+        //        This chart is scalable by the client so you can pass an animation rate of 50 and get a "faster run" but not quite a "even faster run"
+
+        // Convert the Bot movement rate to a value the client understands based on the chart above
+        // Use this block if using 2.5625 as the ratio.
+        // speed *= clientMovementRateTypeMultiple;
+
+
+        // This sets the movement animation rate with the client
+        // Use this block if using 2.5625 as the ratio.
+        // pRunAnimSpeed = speed;
+        pRunAnimSpeed = ((serverOverClientRatio * 10.0f) * speed) * 10.0f;
+
+        // Now convert our "speed" from the value necessary for the client to animate the correct movement type rate to the server side speed
+        // Use this block if using 2.5625 as the ratio.
+        // speed *= serverOverClientRatio;
+        speed = pRunAnimSpeed / serverOverClientRatio;
+
+        return MakeNewBotPositionAndSendUpdate(x, y, z, speed, checkZ);
 }
 
 void Bot::BotGroupOrderFollow(Group* group, Client* client) {
diff --git a/zone/mob.cpp b/zone/mob.cpp
index 24f17a5..5251bbd 100644
--- a/zone/mob.cpp
+++ b/zone/mob.cpp
@@ -559,6 +555,66 @@ bool Mob::IsInvisible(Mob* other) const
        return(false);
 }
 
+/* rencro -- bots with haynar need to walk through this part of code and remove non bot stuff*/
+float Mob::_GetMovementSpeed(int mod) const
+{
+        /*
+        if (mod >= 0) {
+                return 0.6f;
+        }
+        else {
+                return 0.4f;
+        } */
+        if (IsRooted())
+                return 0.0f;
+        else if (IsPseudoRooted())
+                return 0.00001f;
+
+        float speed_mod = 0.6f; //seems to work ok so far
+
+        int aa_mod = 0;
+        int spell_mod = 0;
+        int runspeedcap = RuleI(Character, BaseRunSpeedCap);
+        int movemod = 0;
+        float frunspeedcap = 0.0f;
+
+        runspeedcap += itembonuses.IncreaseRunSpeedCap + spellbonuses.IncreaseRunSpeedCap + aabonuses.IncreaseRunSpeedCap;
+        aa_mod += itembonuses.BaseMovementSpeed + spellbonuses.BaseMovementSpeed + aabonuses.BaseMovementSpeed;
+        spell_mod += spellbonuses.movementspeed + itembonuses.movementspeed;
+
+        //hard cap
+        if (runspeedcap > 225)
+                runspeedcap = 225;
+
+        if (spell_mod < 0)
+                movemod += spell_mod;
+        else if (spell_mod > aa_mod)
+                movemod = spell_mod;
+        else
+                movemod = aa_mod;
+
+        // cap negative movemods from snares mostly
+        if (movemod < -85)
+                movemod = -85;
+
+        if (movemod != 0)
+                speed_mod += speed_mod * static_cast<float>(movemod) / 100.0f;
+
+        //runspeed caps
+        frunspeedcap = static_cast<float>(runspeedcap) / 100.0f;
+
+        //apply final mod such as the -47 for walking
+        // use runspeed since it should stack with snares
+        // blah blah blah
+        if (mod != 0)
+                speed_mod += runspeed * static_cast<float>(mod) / 100.0f;
+
+        if (speed_mod <= 0.0f)
+                speed_mod = 0.0f;
+
+        return speed_mod;
+}
+
 int Mob::_GetWalkSpeed() const {
 
        if (IsRooted() || IsStunned() || IsMezzed())
@@ -1384,6 +1440,8 @@ void Mob::SendPosition()
        PlayerPositionUpdateServer_Struct* spu = (PlayerPositionUpdateServer_Struct*)app->pBuffer;
        MakeSpawnUpdateNoDelta(spu);
        move_tic_count = 0;
+        if (IsBot())
+                tar_ndx = 20; //rencro -- bots with haynar
        entity_list.QueueClients(this, app, true);
        safe_delete(app);
 }
diff --git a/zone/mob.h b/zone/mob.h
index 6510652..d134022 100644
--- a/zone/mob.h
+++ b/zone/mob.h
@@ -464,6 +464,11 @@ public:
        virtual void SetMoving(bool move) { moving = move; m_Delta = glm::vec4(); }
        virtual void GoToBind(uint8 bindnum = 0) { }
        virtual void Gate();
+        /* rencro -- add bots around haynar */       
+        float GetBotWalkspeed() const { return(_GetMovementSpeed(-47)); }
+        float GetBotRunspeed() const { return(_GetMovementSpeed(0)); }
+        float GetBotBaseRunspeed() const { return runspeed; }
+        /* rencro -- add bots around haynar */
        int GetWalkspeed() const { return(_GetWalkSpeed()); }
        int GetRunspeed() const { return(_GetRunSpeed()); }
        void SetCurrentSpeed(int in);
@@ -998,6 +1003,7 @@ protected:
        int _GetRunSpeed() const;
        int _GetFearSpeed() const;
        virtual bool MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, bool checkZ);
+        virtual bool MakeNewBotPositionAndSendUpdate(float x, float y, float z, float speed, bool checkZ); //rencro -- add bots around haynar code
 
        virtual bool AI_EngagedCastCheck() { return(false); }
        virtual bool AI_PursueCastCheck() { return(false); }
diff --git a/zone/waypoints.cpp b/zone/waypoints.cpp
index e900c68..cf04ecf 100644
--- a/zone/waypoints.cpp
+++ b/zone/waypoints.cpp
@@ -708,6 +708,212 @@ bool Mob::MakeNewPositionAndSendUpdate(float x, float y, float z, int speed, boo
        pLastChange = Timer::GetCurrentTime();
        return true;
 }
+/* rencro add bots around haynar */
+bool Mob::MakeNewBotPositionAndSendUpdate(float x, float y, float z, float speed, bool checkZ) {
+        if(GetID()==0)
+                return true;
+
+        if ((m_Position.x-x == 0) && (m_Position.y-y == 0)) {//spawn is at target coords
+                if(m_Position.z-z != 0) {
+                        m_Position.z = z;
+                        Log.Out(Logs::Detail, Logs::AI, "Calc Position2 (%.3f, %.3f, %.3f): Jumping pure Z.", x, y, z);
+                        return true;
+                }
+                Log.Out(Logs::Detail, Logs::AI, "Calc Position2 (%.3f, %.3f, %.3f) inWater=%d: We are there.", x, y, z, inWater);
+                return false;
+        } else if ((std::abs(m_Position.x - x) < 0.1) && (std::abs(m_Position.y - y) < 0.1)) {
+                Log.Out(Logs::Detail, Logs::AI, "Calc Position2 (%.3f, %.3f, %.3f): X/Y difference <0.1, Jumping to target.", x, y, z);
+
+                m_Position.x = x;
+                m_Position.y = y;
+                m_Position.z = z;
+                return true;
+        }
+
+        bool send_update = false;
+        int compare_steps = 20;
+        if(tar_ndx < compare_steps && m_TargetLocation.x==x && m_TargetLocation.y==y) {
+
+                float new_x = m_Position.x + m_TargetV.x*tar_vector;
+                float new_y = m_Position.y + m_TargetV.y*tar_vector;
+                float new_z = m_Position.z + m_TargetV.z*tar_vector;
+                if(IsNPC()) {
+                        entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z);
+                }
+
+                m_Position.x = new_x;
+                m_Position.y = new_y;
+                m_Position.z = new_z;
+
+                Log.Out(Logs::Detail, Logs::AI, "Calculating new position2 to (%.3f, %.3f, %.3f), old vector (%.3f, %.3f, %.3f)", x, y, z, m_TargetV.x, m_TargetV.y, m_TargetV.z);
+
+                //fix up pathing Z
+                if(checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving))
+                {
+                        if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() ||
+                          (zone->HasWaterMap() && !zone->watermap->InWater(glm::vec3(m_Position))))
+                        {
+                                glm::vec3 dest(m_Position.x, m_Position.y, m_Position.z);
+
+                                float newz = zone->zonemap->FindBestZ(dest, nullptr) + 2.0f;
+
+                                Log.Out(Logs::Detail, Logs::AI, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,m_Position.x,m_Position.y,m_Position.z);
+
+                                if ((newz > -2000) &&
+                                    std::abs(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check.
+                                {
+                                        if ((std::abs(x - m_Position.x) < 0.5) &&
+                                            (std::abs(y - m_Position.y) < 0.5)) {
+                                                if (std::abs(z - m_Position.z) <=
+                                                    RuleR(Map, FixPathingZMaxDeltaMoving))
+                                                        m_Position.z = z;
+                                                else
+                                                        m_Position.z = newz + 1;
+                                        }
+                                        else
+                                                m_Position.z = newz + 1;
+                                }
+                        }
+                }
+
+                tar_ndx++;
+                return true;
+        }
+
+
+        if (tar_ndx>50) {
+                tar_ndx--;
+        } else {
+                tar_ndx=0;
+        }
+        m_TargetLocation = glm::vec3(x, y, z);
+
+        float nx = this->m_Position.x;
+        float ny = this->m_Position.y;
+        float nz = this->m_Position.z;
+//        float nh = this->heading;
+
+        m_TargetV.x = x - nx;
+        m_TargetV.y = y - ny;
+        m_TargetV.z = z - nz;
+        //pRunAnimSpeed = (int8)(speed*NPC_RUNANIM_RATIO);
+        //speed *= NPC_SPEED_MULTIPLIER;
+
+        Log.Out(Logs::Detail, Logs::AI, "Calculating new position2 to (%.3f, %.3f, %.3f), new vector (%.3f, %.3f, %.3f) rate %.3f, RAS %d", x, y, z, m_TargetV.x, m_TargetV.y, m_TargetV.z, speed, pRunAnimSpeed);
+
+        // --------------------------------------------------------------------------
+        // 2: get unit vector
+        // --------------------------------------------------------------------------
+        float mag = sqrtf (m_TargetV.x*m_TargetV.x + m_TargetV.y*m_TargetV.y + m_TargetV.z*m_TargetV.z);
+        tar_vector = speed / mag;
+
+// mob move fix
+        int numsteps = (int) ( mag * 16.0f / (float)speed + 0.5f);
+
+// mob move fix
+
+        if (numsteps<20)
+        {
+                if (numsteps>1)
+                {
+                        tar_vector=1.0f        ;
+                        m_TargetV.x = m_TargetV.x / numsteps;
+                        m_TargetV.y = m_TargetV.y / numsteps;
+                        m_TargetV.z = m_TargetV.z / numsteps;
+
+                        float new_x = m_Position.x + m_TargetV.x;
+                        float new_y = m_Position.y + m_TargetV.y;
+                        float new_z = m_Position.z + m_TargetV.z;
+                        if(IsNPC()) {
+                                entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z);
+                        }
+
+                        m_Position.x = new_x;
+                        m_Position.y = new_y;
+                        m_Position.z = new_z;
+                        m_Position.w = CalculateHeadingToTarget(x, y);
+                        tar_ndx = 20 - numsteps;
+                        Log.Out(Logs::Detail, Logs::AI, "Next position2 (%.3f, %.3f, %.3f) (%d steps)", m_Position.x, m_Position.y, m_Position.z, numsteps);
+                }
+                else
+                {
+                        m_Position.x = x;
+                        m_Position.y = y;
+                        m_Position.z = z;
+
+                        tar_ndx = 20;
+                        Log.Out(Logs::Detail, Logs::AI, "Only a single step to get there... jumping.");
+                }
+        }
+
+        else {
+                tar_vector /= 20.0f;
+                float dur = Timer::GetCurrentTime() - pLastChange;
+                if(dur < 1.0f) {
+                        dur = 1.0f;
+                }
+                tar_vector = (tar_vector * AImovement_duration) / 100.0f;
+
+                float new_x = m_Position.x + m_TargetV.x*tar_vector;
+                float new_y = m_Position.y + m_TargetV.y*tar_vector;
+                float new_z = m_Position.z + m_TargetV.z*tar_vector;
+                if(IsNPC()) {
+                        entity_list.ProcessMove(CastToNPC(), new_x, new_y, new_z);
+                }
+
+                m_Position.x = new_x;
+                m_Position.y = new_y;
+                m_Position.z = new_z;
+                m_Position.w = CalculateHeadingToTarget(x, y);
+                Log.Out(Logs::Detail, Logs::AI, "Next position2 (%.3f, %.3f, %.3f) (%d steps)", m_Position.x, m_Position.y, m_Position.z, numsteps);
+        }
+
+        //fix up pathing Z
+        if(checkZ && zone->HasMap() && RuleB(Map, FixPathingZWhenMoving)) {
+
+                if(!RuleB(Watermap, CheckForWaterWhenMoving) || !zone->HasWaterMap() ||
+                  (zone->HasWaterMap() && !zone->watermap->InWater(glm::vec3(m_Position))))
+                {
+                        glm::vec3 dest(m_Position.x, m_Position.y, m_Position.z);
+
+                        float newz = zone->zonemap->FindBestZ(dest, nullptr);
+
+                        Log.Out(Logs::Detail, Logs::AI, "BestZ returned %4.3f at %4.3f, %4.3f, %4.3f", newz,m_Position.x, m_Position.y, m_Position.z);
+
+                        if ((newz > -2000) &&
+                            std::abs(newz - dest.z) < RuleR(Map, FixPathingZMaxDeltaMoving)) // Sanity check.
+                        {
+                                if (std::abs(x - m_Position.x) < 0.5 && std::abs(y - m_Position.y) < 0.5) {
+                                        if (std::abs(z - m_Position.z) <= RuleR(Map, FixPathingZMaxDeltaMoving))
+                                                m_Position.z = z;
+                                        else
+                                                m_Position.z = newz + 1;
+                                }
+                                else
+                                        m_Position.z = newz+1;
+                                }
+                }
+        }
+
+        SetMoving(true);
+        moved=true;
+
+        m_Delta = glm::vec4(m_Position.x - nx, m_Position.y - ny, m_Position.z - nz, 0.0f);
+
+        if (IsClient())
+        {
+                SendPosUpdate(1);
+                CastToClient()->ResetPositionTimer();
+        }
+        else
+        {
+                move_tic_count = RuleI(Zone, NPCPositonUpdateTicCount); //wtf is Positon??
+                SendPosUpdate();
+                SetAppearance(eaStanding, false);
+        }
+        pLastChange = Timer::GetCurrentTime();
+        return true;
+}
 
 bool Mob::CalculateNewPosition2(float x, float y, float z, int speed, bool checkZ, bool calcHeading) {
        return MakeNewPositionAndSendUpdate(x, y, z, speed, checkZ);



All times are GMT -4. The time now is 07:22 AM.

Powered by vBulletin®, Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.