Trace-line (World::Intersect) in Wildstar menu

User Tag List

Results 1 to 1 of 1
  1. #1
    Master674's Avatar Elite User Authenticator enabled
    Reputation
    480
    Join Date
    May 2008
    Posts
    576
    Thanks G/R
    2/23
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Trace-line (World::Intersect) in Wildstar

    Hey, decided to write a small guide as well (inspired by Jadd's post today) on how to use the games CWorld::GetIntersection function.

    Type declarations and structs first:

    Code:
    typedef bool (__stdcall* CWorld__GetIntersection_t) (const Game::CWorld *pInstance, const Math::Vector4& start, const Math::Vector4& end,
    	const Math::Vector4& up, Game::WorldIntersectionResult** intersectionResult, const Game::WorldIntersectionParams& params);
    Code:
    namespace Game {
    	enum class WorldIntersectionFlags : uint32 {
    		None = 0,
    		All = ~None,
    		Terrain = 0x1,
    		Structure = 0x10
    	};
    
    #pragma pack(push, 1)
    	struct WorldIntersectionParams {
    		typedef int (__stdcall *callback_t) (void*, int);
    
    		uint32       flags;    // @0
    		uint32       unk1;     // @4 - 0
    		uint32       unk2;     // @8 - 0 (bool?)
    		callback_t   callback; // @C - function
    		void        *classPtr; // @10 - gameMgr
    		uint32       unk4;     // @14 - 0
    		uint32       unk5;     // @18 - 0 (used if unk2 is set)
    	};
    
    	struct WorldIntersectionResult {
    		struct {
    			void(__stdcall* unk)(void*);
    			void(__stdcall* destruct)(void*);
    			void(__stdcall* initialize)(void*);
    		}           *vftbl;    // @0 - vftable
    		uint32       unk2;     // @4 - 1
    		float        distance; // @8 - lerp from start
    	};
    #pragma pack(pop)
    }
    The game offsets you need (VTable shouldn't change much, should be easy to update).
    Code:
    class OffsetsX86 {
    public:
    	struct SGameManager {
    		uint32 Ptr                     = 0x00872098; // 6745.10
    		uint32 WorldPtr                = 0x00005FDC; // 6745.10
    	} GameManager;
    
    	struct SWorld {
    		struct SVMT {
    			uint32 GetIntersection = 51; // 6745.10
    		} VMT;
    	} World;
    }
    Usage (result will contain the hitpoint, if any):
    Code:
    bool CWorld::getIntersection(const Math::Vector3& start,
    			     const Math::Vector3& end,
    			     uint32 intersectionFlags,
    			     Math::Vector3* result) const
    {
    	__declspec(align(16))
    	Math::Vector4 startPt(start, 1.0f); // needs to be 16-byte aligned because of SIMD (they use aligned vectors for this)
    
    	__declspec(align(16))
    	Math::Vector4 endPt(end, 1.0f); // needs to be 16-byte aligned because of SIMD (they use aligned vectors for this)
    
    	__declspec(align(16))
    	Math::Vector4 unkVec(0, 1, 1, 0); // needs to be 16-byte aligned because of SIMD (they use aligned vectors for this)
    
    	WorldIntersectionParams intersectParams = { 0 };
    	WorldIntersectionResult *intersectResult = nullptr;
    	intersectParams.flags = intersectionFlags;
    
    	Delegates::CWorld__GetIntersection_t pGetIntersection = sMemory.getVFunc<Delegates::
    		CWorld__GetIntersection_t>(getPointer(), sOffsets.GameData.World.VMT.GetIntersection);
    	bool hasHit = pGetIntersection(this, startPt, endPt, unkVec, &intersectResult, intersectParams);
    
    	if (intersectResult != nullptr) {
    		intersectResult->vftbl->initialize(intersectResult);
    		if (result != nullptr)
    			*result = start + (end - start) * intersectResult->distance;
    		intersectResult->vftbl->destruct(intersectResult); // need to do this or you will leak memory and crash the game at some point
    	}
    
    	return hasHit;
    }
    To get a pointer to the current CWorld instance, just use the GameMgr Ptr and add the WorldPtr.
    Greets!
    Last edited by Master674; 06-28-2014 at 03:24 PM.

    These ads disappear when you log in.

Similar Threads

  1. [Trading] Wildstar stress key for World of Warcraft Battle Chest gift (5.00 EUR right now)
    By losmy123 in forum WildStar Buy Sell Trade
    Replies: 3
    Last Post: 12-05-2013, 08:15 AM
  2. Spoon feed me copy-pasta! DirectX line drawing in-world
    By amadmonk in forum WoW Memory Editing
    Replies: 20
    Last Post: 04-01-2011, 05:44 AM
  3. [Client] World of Warcraft not tracing correctly!
    By Amaroth in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 09-23-2010, 03:27 AM
  4. World of Warcraft Pick-Up Lines
    By Stans Dad in forum World of Warcraft General
    Replies: 7
    Last Post: 08-05-2008, 07:18 AM
  5. Burning World Of Death [Funserver] Now on 100mbit line
    By pepsi1x1 in forum WoW Emulator Server Listings
    Replies: 0
    Last Post: 07-30-2008, 12:53 AM
All times are GMT -5. The time now is 11:30 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2020 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2020 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search