TrinityCore icon indicating copy to clipboard operation
TrinityCore copied to clipboard

[Core / Pet] Pets following fall behind and despawn

Open MrSmite opened this issue 13 years ago • 9 comments

Rev: All

Bug:

Pets following their owner will eventually fall too far behind and despawn

Details:

This isn't a lag issue but a pet speed issue. As the player runs forward, the distance between the player and pet increases to the point the pet despawns. Note: this is a pet with no debuffs.

This indicates that the pet needs its speed slightly increased if it falls too far behind (obviously only if there are no speed debuffs). I'm testing a bit of code in Unit::UpdateSpeed() but any suggestions are welcome.

MrSmite avatar Dec 22 '12 04:12 MrSmite

as know the pet speed is the same as the players one; was fixed weeks ago btw how the happen with vmaps ? o.O

ghost avatar Dec 22 '12 10:12 ghost

Some ideas were already discussed in this PR: https://github.com/TrinityCore/TrinityCore/pull/8011

Pitcrawler avatar Dec 22 '12 11:12 Pitcrawler

@Pitcrawler

Yeah, but that got closed as "its a hack". Posting in closed bug reports is kinda useless since nobody really pays attention to them after they're closed.

The problem is that in UpdateSpeed() the pet is using the value from creature_template.speed_run but this is not correct. Once tamed, the pet should be bumped up to match the player's speed, not use the "in the wild" speed.

What happens is that GetSpeed() for pet = 5.0000 (rounded) and GetSpeed() for player = 7.0000 (rounded) so the pet will lag behind over time and eventually despawn due to distance.

While I agree that a flat value of 1.2f isn't correct, the pets do need to either have the multiplier changed so it brings the pet up to owner speed or have the base speed changed so it isn't using it's "in the wild" speed from creature_template

MrSmite avatar Dec 22 '12 16:12 MrSmite

its not possible to synch the speed of the pet by using the update ai of the pet and getting the player speed per function ?

ghost avatar Dec 22 '12 17:12 ghost

@NorthStrider

The problem is that calls to UpdateSpeed() overwrites anything you do if you call SetSpeed() directly. Because the underlying system is broken (ie: it uses the creature_template value) it might be more problematic.

I suppose it is worth a look, I'll be playig around with it over the next day or so.

MrSmite avatar Dec 22 '12 17:12 MrSmite

Please don't close this saying "hack".

If there's an issue with it, let's discuss it. Pets have been lagging and despawning for a long time (very annoying) and this is the only real adaptive solution that's been presented that doesn't interfere with normal mobs.

Thanks.

MrSmite avatar Dec 23 '12 05:12 MrSmite

I believe http://www.trinitycore.org/f/topic/7342-a-new-speed-concept-for-creatures/ might catch your eye for this. It would be greatly useful in scripting

Ric101 avatar Dec 23 '12 07:12 Ric101

For those interested, here's some background as to how I arrived at this solution:

I was looking for an official number and all I found was a discussion on Petopia where they said a flat 114%. I tried that at first and not only did it seem too fast but the pet movement was very jerky.

I played around with different formulas and finally came up with:

base_rate + ((dist - 5) * 0.01f)

This allows a very subtle change which grows if the pet continues to lag and shrinks when the pet is close but never goes below base_rate (which is 1).

Here are some examples:

base_rate = 1

dist = 5 mult = 1 + ((5 - 5) * 0.01) = 1 + (0 * 0.01) = 1 + 0 = 1.00

dist = 8 mult = 1 + ((8 - 5) * 0.01) = 1 + (3 * 0.01) = 1 + .03 = 1.03

dist = 10 mult = 1 + ((10 - 5) * 0.01) = 1 + (5 * 0.01) = 1 + .05 = 1.05

As you can see, if the pet is at 5 yards then it uses a multiplier of 1 (or 100% normal speed) and as it falls further behind the speed increases slightly without the harsh jerky motion of going from 1.00 to 1.14 instantly.

Keep in mind this eventually gets applied to the pet as a speed rate which is essentially a multiplier of the pet's speed. Since standard run speed is 7, multiplying it by a small number over time gives a better result than just bouncing between normal (1.00) and fast (1.14).

Also note that this rate is effected by slows and also only applied when out of combat so it shouldn't give pets any noticeable advantage.

MrSmite avatar Dec 24 '12 02:12 MrSmite

Patch updated, fixed crash on "Tame Beast" due to no owner being assigned when UpdateSpeed() gets called for the first time.

Please update your core if you're testing, thanks!

MrSmite avatar Dec 24 '12 08:12 MrSmite