Implementing "melee push" with doknockback?
I am trying to code in the old school melee push from melee hits on my server but I am stuck.
In the attack code for npc attacks, i added this in: Code:
if (!(other->IsRooted())) { And I realize that DoKnockback() is a mob method but it has a IfClient() check in the beginning so I'm not sure if this would even be able to work on npcs until i attempt to remove the client restriction. There has to be an easier way to do this. Can anyone point me in the right direction? |
Vector math, yay.
I'm not sure if the server codebase has a complete vector implementation, and vector math always confuses me, but I believe you'd want something like this pseudocode: Code:
Vector a(pusher->GetX(), pusher->GetY(), 0); I leave it to you to look up the vector operations if needed cuz I hate em. Maybe we already have functions for that stuff though, too lazy to look right now. |
Luckily, there is a function where this is taken care of:
Code:
void Mob::DoKnockback(Mob *caster, float pushback, uint32 pushup) |
Well I'm not 100% sure, but it looks like that is dependent on the player's heading. So it doesn't push in the right angle, unless the player is facing exactly the right direction (i.e., square centered on the thing pushing them.) It just sends them backwards from whichever way they are currently facing, I assume. Which isn't what you want at all, really.
You might be able to get that packet to do what you want by changing the "spu->heading" to be the inverse of the caster's heading (or this->CalculateHeadingToTarget(caster->GetX(), caster->GetY()) I should say), rather than the player's current heading. Or maybe play with the "spu->delta_heading" field? dunno what that's for... actually, nevermind, that would probably just spin the client around. You wouldn't be able to rely on that packet (at least not alone) for NPCs though since it doesn't actually change their serverside position. (Vectors and trig are equivalent in this case I guess, but I hate trig even more ;p) |
I didnt realize that the knockback method was working like that. Anyway the code I actually am using that is still reproducing these results is the following:
Code:
void Mob::PushClient(Mob *pusher) This seems to work just fine at least when I use that calculation with players hitting mobs. I am still getting the results with clients however. I didnt write the formula I took it from elsewhere. |
All times are GMT -4. The time now is 05:04 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.