Target Prediction menu

Shout-Out

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 18
  1. #1
    aeo's Avatar Contributor
    Reputation
    135
    Join Date
    Apr 2007
    Posts
    286
    Thanks G/R
    97/68
    Trade Feedback
    7 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)

    Target Prediction

    I'm working on a LUA extension for wow and I have most of it working. Id like to make some smarter hunter traps but am having some issues calculating the position to cast the trap based on target position and speed.

    function predictPosition(x,y,z,vel,target)
    local px = x
    local py = y
    local pz = z
    local dist = GetUnitDistance(target);
    if vel == 0 then
    return px,py,pz
    else
    px = x + (vel * ( dist / 25)) --25 yards/sec is the trap travel time( roughly)
    px = y + (vel * ( dist / 25)) --velocity is the Units speed usually 7.7 unmounted
    px = z + (vel * ( dist / 25))
    return px,py,pz
    end

    I've searched here and Google. Without much luck, maybe I'm using the wrong search terms. Hoping some expert can help me out

    Thanks,
    Ace

    Target Prediction
  2. #2
    Jadd's Avatar 🐸 Premium Seller
    Reputation
    1515
    Join Date
    May 2008
    Posts
    2,433
    Thanks G/R
    81/336
    Trade Feedback
    1 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    You need the rotation vectors, to account for the direction they are running in, whether they are strafing left or right, or running forward or backwards. Doing "<x or y> + (vel * (dist / 25))" will only work assuming they are running directly east or south. In fact, that will be wrong too when the velocity is applied to both axes.

    Code:
    function PredictTrapPosition(x, y, z, rotation, velocity, distance, direction)
        local trapSpeed = distance / 25
        local trapDistance = trapSpeed * velocity
        local forward = 1
        local right = 0
    
        if (direction == 1) -- Running forward
            forward = 1
        elseif (direction == 2) -- Running backward
            forward = -1
        elseif (direction == 3) -- Strafing right
            right = 1
        elseif (direction == 4) -- Strafing left
            right = -1
        end
    
        x = x + ((trapDistance * cos(rotation + ((math.pi / 2) * right))) * forward)
        y = y + ((trapDistance * sin(rotation + ((math.pi / 2) * right))) * forward)
        
        return x, y, z
    end
    Last edited by Jadd; 01-26-2015 at 10:53 PM.

  3. #3
    aeo's Avatar Contributor
    Reputation
    135
    Join Date
    Apr 2007
    Posts
    286
    Thanks G/R
    97/68
    Trade Feedback
    7 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Amazing thanks, should be able to get it working from here. Thanks JADD,

    I can get the rotation vectors, However, is the only way to retrieve the movement direction via the Unit movement flags?

    Thanks,
    Last edited by aeo; 01-26-2015 at 03:10 PM.

  4. #4
    Jadd's Avatar 🐸 Premium Seller
    Reputation
    1515
    Join Date
    May 2008
    Posts
    2,433
    Thanks G/R
    81/336
    Trade Feedback
    1 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by aeo View Post
    However, is the only way to retrieve the movement direction via the Unit movement flags?
    Certainly not the only way, but the easiest. This information is not exposed to the WoW Lua API, if that's what you are looking for.

  5. #5
    aeo's Avatar Contributor
    Reputation
    135
    Join Date
    Apr 2007
    Posts
    286
    Thanks G/R
    97/68
    Trade Feedback
    7 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Yep i found an old post by you and have the movement struct and data working. I expose this information to LUA myself via newly registered functions. One last stupid question, CGObject_C::GetRotation and CGObject_C::GetFacing they seem to be all mixed up when people talk about them on the board facing is a float in radians and rotation is another vector or C4Quaternion acording to TOM_RUS vTable examples?

    So i have it all working i get the correct values for direction 1,2,4,8 seems I only get them for my self and my pet. Others log as 2147483649
    Last edited by aeo; 01-26-2015 at 08:13 PM.

  6. #6
    Jadd's Avatar 🐸 Premium Seller
    Reputation
    1515
    Join Date
    May 2008
    Posts
    2,433
    Thanks G/R
    81/336
    Trade Feedback
    1 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Are you trying to find the object rotation, or whether they are moving forward/backward/strafing?

    For object rotation use GetRotation. To find their movement direction, check their movement state flags in the CMovementData struct (forward = 1, backward = 2, strafe left = 4, strafe right = 8.)

  7. #7
    aeo's Avatar Contributor
    Reputation
    135
    Join Date
    Apr 2007
    Posts
    286
    Thanks G/R
    97/68
    Trade Feedback
    7 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    II have the movement flags working at least for myself and my pet it seems othernunits don't get proper values. I have to look into get rotation I was using the facing float value.

    Edit. I tried get rotation as a float but no luck. I can't find much info on the return type of getrotation . I'll try int64 tomorrow but clearly still have some learning to do.
    Last edited by aeo; 01-26-2015 at 10:45 PM.

  8. #8
    aeo's Avatar Contributor
    Reputation
    135
    Join Date
    Apr 2007
    Posts
    286
    Thanks G/R
    97/68
    Trade Feedback
    7 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I have yet to get consistent values for the movement flags. Doing research looking through old IDBs im pretty sure i have the right offsets.Yet I seem to get the wrong values. Originally I was using 0xA38 as the dataOffset but that seemed to only return valid numbers for my LocalPlayer and Pet. This is quickly starting to become quite the project. I was going to just PM you but I figured others can learn as well.

    Below is some code that you wrote in another post. The offsets are for Live 19342

    Code:
            DWORD UnitMovementData = 0x124;
        DWORD UnitMovementFlags = 0x40;
    
    
            
        /// <summary>
        /// Gets the unit's movement structure pointer.
        /// </summary>
        DWORD_PTR GetMovementData() const
        {
            Log("getData");
            Log("Data 0x%x", *(DWORD_PTR*)(this + UnitMovementData));
                return *(DWORD_PTR*)( this +
                    UnitMovementData);
        }
    
    
        /// <summary>
        /// Gets the unit's movement flags.
        /// </summary>
        DWORD GetMovementFlags() const
        {
            Log("GetFlag");
            Log("Flag 0x%x", *(DWORD*)(this + UnitMovementFlags));
            return *(DWORD*)(GetMovementData() + UnitMovementFlags);
        }
    Also as you can see the Script_IsFalling shows these offsets should be correct.

    Code:
    signed int __cdecl Script_IsFalling(int a1)
    {
      int v1; // eax@2
      int v2; // eax@2
      int v3; // eax@5
      int v4; // eax@7
    
    
      if ( klua_isstring(a1, 1) )
      {
        v1 = klua_tolstring(a1, 1, 0);
        v2 = GetUnitFromName(v1);
      }
      else
      {
        v2 = ClntObjMgrGetActivePlayerObj();
      }
      v4 = 0;
      if ( v2 )
      {
        v3 = *(_DWORD *)(*(_DWORD *)(v2 + 0x124) + 0x40);
        if ( v3 & 0x800 )
        {
          if ( !(v3 & 0x400) )
            v4 = 1;
        }
      }
      klua_pushboolean(a1, v4);
      return 1;
    }
    Last edited by aeo; 01-27-2015 at 02:06 PM.

  9. #9
    Jadd's Avatar 🐸 Premium Seller
    Reputation
    1515
    Join Date
    May 2008
    Posts
    2,433
    Thanks G/R
    81/336
    Trade Feedback
    1 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Take another look at your GetMovementFlags function. The return value should be right, but the logging...

  10. #10
    aeo's Avatar Contributor
    Reputation
    135
    Join Date
    Apr 2007
    Posts
    286
    Thanks G/R
    97/68
    Trade Feedback
    7 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Fail didn't get it properly output it to LUA either. Its working now. ! more question good sir.Rotation is that the actual Yaw pitch roll of the unit or the facing angle in radians? Everywhere i look for getRotation on this site its people referring to the Facing angle or the Float that is in the movement struct right after the Z value. Not that actual Yaw/Pitch/Roll values.

    Also IDA defines it like this

    int __userpurge CGObject_C::GetRotation@<eax>(int a1@<ecx>, double a2@<st0>, int a3)
    Do you know what the last 2 args are?

    Thanks for all your help, I really appreciate your patience.

    Edit:

    OK making a little progress. I switched from doing to computation on the LUA side to the C++ side. Seems to be working but hitting traps at the wrong side running forward it shots a bit left. I think my velocityVector is incorrect.
    Code:
    			int32 direction = (WoWMovementFlag)(unit->GetMovementFlags() & 0xFF);
    			C3Vector velVec;
    			if (direction == 1) // Running forward6
    			{
    				velVec = C3Vector(0, 7, 0);
    			}
    			else if (direction == 2)  // Running backward
    			{
    				velVec = C3Vector(0, -7, 0);
    			}
    			else if (direction == 4)  // Strafing right
    			{
    				velVec = C3Vector(7, 0, 0);
    			}
    			else if (direction == 8) // Strafing left
    			{
    				velVec = C3Vector(-7, 0, 0);
    			}
    			C3Vector me;
    			ObjectMgr::getlocalPlayer()->GetPosition(me);
    			aimPos = FindInterceptVector(me, 25, pos, velVec);
    Code:
    C3Vector FindInterceptVector(C3Vector shotOrigin, float shotSpeed,
    	C3Vector targetOrigin, C3Vector targetVel) {
    
    
    	C3Vector dirToTarget = targetOrigin - shotOrigin;
    	dirToTarget.normaliZeVector3D();
    
    
    	// Decompose the target's velocity into the part parallel to the
    	// direction to the cannon and the part tangential to it.
    	// The part towards the cannon is found by projecting the target's
    	// velocity on dirToTarget using a dot product.
    	C3Vector targetVelOrth = targetVel.dotVector3D(dirToTarget) * dirToTarget;
    
    
    	// The tangential part is then found by subtracting the
    	// result from the target velocity.
    	C3Vector targetVelTang = targetVel - targetVelOrth;
    
    
    	/*
    	* targetVelOrth
    	* |
    	* |
    	*
    	* ^...7  <-targetVel
    	* |  /.
    	* | / .
    	* |/ .
    	* t--->  <-targetVelTang
    	*
    	*
    	* s--->  <-shotVelTang
    	*
    	*/
    
    
    	// The tangential component of the velocities should be the same
    	// (or there is no chance to hit)
    	// THIS IS THE MAIN INSIGHT!
    	C3Vector shotVelTang = targetVelTang;
    
    
    	// Now all we have to find is the orthogonal velocity of the shot
    
    
    	float shotVelSpeed = shotVelTang.GetMagnitude();
    	if (shotVelSpeed > shotSpeed) {
    		// Shot is too slow to intercept target, it will never catch up.
    		// Do our best by aiming in the direction of the targets velocity.
    		targetVel.normaliZeVector3D();
    		return  targetVel * shotSpeed;
    	}
    	else {
    		// We know the shot speed, and the tangential velocity.
    		// Using pythagoras we can find the orthogonal velocity.
    		float shotSpeedOrth =
    			sqrt(shotSpeed * shotSpeed - shotVelSpeed * shotVelSpeed);
    		C3Vector shotVelOrth = dirToTarget * shotSpeedOrth;
    
    
    		// Finally, add the tangential and orthogonal velocities.
    		// Find the time of collision (distance / relative velocity)
    		float timeToCollision = ((shotOrigin - targetOrigin).GetMagnitude())
    			/ (shotVelOrth.GetMagnitude() - targetVelOrth.GetMagnitude());
    
    
    		// Calculate where the shot will be at the time of collision
    		C3Vector shotVel = shotVelOrth + shotVelTang;
    		C3Vector shotCollisionPoint = shotOrigin + shotVel * timeToCollision;
    		return shotCollisionPoint;
    
    
    	}
    }
    Last edited by aeo; 01-27-2015 at 08:59 PM. Reason: Progress

  11. #11
    Jadd's Avatar 🐸 Premium Seller
    Reputation
    1515
    Join Date
    May 2008
    Posts
    2,433
    Thanks G/R
    81/336
    Trade Feedback
    1 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by aeo View Post
    Everywhere i look for getRotation on this site its people referring to the Facing angle or the Float that is in the movement struct right after the Z value. Not that actual Yaw/Pitch/Roll values.
    The value you refer to is yaw (rotation on the X and Y axes.) Pitch is only used when flying or swimming. Roll is not used for obvious reasons.

    Originally Posted by aeo View Post
    int __userpurge CGObject_C::GetRotation@<eax>(int a1@<ecx>, double a2@<st0>, int a3)
    Do you know what the last 2 args are?
    This is a small error on the behalf of IDA - it has no reference calls to base the parameter interpretation from, as it is a virtual method. It's a __thiscall and takes a float as the first and only parameter. No idea what this float does. You might want to see what it is via. breakpoint.

    I'll check your code out a bit later tonight.

  12. #12
    Wildbreath's Avatar Contributor
    Reputation
    162
    Join Date
    Feb 2012
    Posts
    121
    Thanks G/R
    2/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can do it using lua. just use timer and get first + second vector of target and calculate result using trap speed and velocity player and target. but you should use intersect function with ground flag to calculate Z, else your traps will fly
    i was used it, but players (atleast in pvp) moving randomly, and calculated pos sometimes wrong. it works for mobs

  13. #13
    aeo's Avatar Contributor
    Reputation
    135
    Join Date
    Apr 2007
    Posts
    286
    Thanks G/R
    97/68
    Trade Feedback
    7 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    I thought about grabbing a 1 frame difference and going that way but this is a challenge and its fun. Both will probably have similar results. I maybe give your method a try though see how it works. Get the position 1 and 2 subtract 1 from 2 resulting in a velocity vector and multiply by trap speed? If you don't mind could you post some of your code, just a snippet don't want any c&p

  14. #14
    Wildbreath's Avatar Contributor
    Reputation
    162
    Join Date
    Feb 2012
    Posts
    121
    Thanks G/R
    2/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
    function PredictTrapPosition(unit)
        
    unit unit or 'target'
        
    local x1y1UnitPosition(unit)
        
    C_Timer.After(.1, function()
            
    local x2y2UnitPosition(unit)
            
    local pxpyUnitPosition('player')
            
    local distance math.sqrt((x2 px)^+ (y2 py)^2)
            
    local trapSpeed distance 25
            local angle 
    atan2(x2-x1y2-y1)
            
    local x x2 cos(angle) * trapSpeed
            local y 
    y2 sin(angle) * trapSpeed
            WorldClick
    (xyz)
        
    end)
    end 
    for example, untested. without intersect with ground (api from offspring)
    upd. added distance

    also check for GetUnitSpeed(unit), forgot
    Last edited by Wildbreath; 01-28-2015 at 09:37 AM.

  15. #15
    aeo's Avatar Contributor
    Reputation
    135
    Join Date
    Apr 2007
    Posts
    286
    Thanks G/R
    97/68
    Trade Feedback
    7 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Crazy, I Didnt know you could use this C_Timer I thought you were just going to do some GetTime subtraction. to count time passed and get updated position

Page 1 of 2 12 LastLast

Similar Threads

  1. target -> hunter mark
    By windfire in forum WoW ME Questions and Requests
    Replies: 1
    Last Post: 03-18-2007, 12:13 PM
  2. Using tab targeting to your advantage
    By Enfeebleness in forum World of Warcraft Guides
    Replies: 4
    Last Post: 03-05-2007, 06:04 PM
  3. Increase your TAB Targetting Range
    By Toldorn in forum World of Warcraft Exploits
    Replies: 40
    Last Post: 01-16-2007, 09:48 PM
  4. Targeting --> Dragos
    By Orlox in forum World of Warcraft Exploits
    Replies: 11
    Last Post: 12-01-2006, 01:34 PM
All times are GMT -5. The time now is 11:13 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search