How to check if a unit is in line of sight menu

User Tag List

Results 1 to 7 of 7
  1. #1
    klee946's Avatar Member
    Reputation
    1
    Join Date
    May 2017
    Posts
    6
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to check if a unit is in line of sight

    Does anybody know how to tell if a unit is within the player's line of sight? I can't find any client functions. Potentially recast/detour could be used for raycasting? But I'd rather do something else if it's available.

    How to check if a unit is in line of sight
  2. #2
    Jadd's Avatar 🐸 Premium Seller
    Reputation
    1511
    Join Date
    May 2008
    Posts
    2,432
    Thanks G/R
    81/333
    Trade Feedback
    1 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by klee946 View Post
    Does anybody know how to tell if a unit is within the player's line of sight? I can't find any client functions. Potentially recast/detour could be used for raycasting? But I'd rather do something else if it's available.
    You can do a raycast in-game. Use World::Intersect, it accommodates all in-game geometry rather than using a recast mesh (most likely not entirely accurate.)

    Code:
    public enum IntersectFlags {
        None,
        DoodadCollision     = 0x00000001,
        DoodadRender        = 0x00000002,
        WmoCollision        = 0x00000010,
        WmoRender           = 0x00000020,
        WmoNoCamCollision   = 0x00000040,
        Terrain             = 0x00000100,
        IgnoreWmoDoodad     = 0x00002000,
        LiquidWaterWalkable = 0x00010000,
        LiquidAll           = 0x00020000,
        Cull                = 0x00080000,
        EntityCollision     = 0x00100000,
        EntityRender        = 0x00200000,
    
        Collision           = DoodadCollision | WmoCollision | Terrain | EntityCollision,
        LineOfSight         = WmoCollision | EntityCollision
    }
    
    ...
    
    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    [return: MarshalAs(UnmanagedType.I1)]
    private delegate bool World__Intersect_t(ref Vector3 start, ref Vector3 end, ref Vector3 hitPosition, ref float hitDistance, IntersectFlags flags);
    
    ...
    
    public static bool TestCollide(Vector3 start, Vector3 end, IntersectFlags flags) {
        var hitPosition = Vector3.Zero;
        var hitDistance = 1f; // Must be initialized to 1.
    
        return World__Intersect(ref start, ref end, ref hitPosition, ref hitDistance, flags);
    }
    Last edited by Jadd; 06-28-2017 at 07:57 PM.

  3. Thanks Willy, Parog, Torpedoes, no1dachi (4 members gave Thanks to Jadd for this useful post)
  4. #3
    klee946's Avatar Member
    Reputation
    1
    Join Date
    May 2017
    Posts
    6
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Sweet, I should have enough info to solve this. Thanks!

  5. #4
    blamani's Avatar Active Member
    Reputation
    19
    Join Date
    Jul 2008
    Posts
    80
    Thanks G/R
    1/2
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    From which points does the game check line of sight?
    Base, middle or top of the bounding boxes?
    I have seen issues with some dungeon bosses that seem to float in the air when players fight them.
    Ultraxion in Dragon Soul, Helya and her Tentacles in maw of souls, Naraxus in Neltharions Lair.
    The one in ulduar i think had the same problem.
    Krosus in Nighthold on the other hand seems to be the same, standing on a ledge, partially visible, but has no issues.
    In which way are these mobs special in terms of los?

  6. #5
    Jadd's Avatar 🐸 Premium Seller
    Reputation
    1511
    Join Date
    May 2008
    Posts
    2,432
    Thanks G/R
    81/333
    Trade Feedback
    1 (100%)
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by blamani View Post
    From which points does the game check line of sight?
    Base, middle or top of the bounding boxes?
    I have seen issues with some dungeon bosses that seem to float in the air when players fight them.
    Ultraxion in Dragon Soul, Helya and her Tentacles in maw of souls, Naraxus in Neltharions Lair.
    The one in ulduar i think had the same problem.
    Krosus in Nighthold on the other hand seems to be the same, standing on a ledge, partially visible, but has no issues.
    In which way are these mobs special in terms of los?
    The calculation is done on the server, so impossible to say without just testing what works. I use CGObject_C::GetObjectDisplayHeight from each unit as an offset for both the source and target traceline test. I'm not sure if it works 100%, but it works good enough for me to not bother testing different scenarios by hand.

  7. #6
    klee946's Avatar Member
    Reputation
    1
    Join Date
    May 2017
    Posts
    6
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What address are you using for World__Intersect?

    Edit:
    I think I got it working at address 0x69BFF0.
    Last edited by klee946; 07-09-2017 at 07:40 PM.

  8. #7
    MaiN's Avatar Elite User
    Reputation
    335
    Join Date
    Sep 2006
    Posts
    1,047
    Thanks G/R
    0/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Jadd View Post
    You can do a raycast in-game. Use World::Intersect, it accommodates all in-game geometry rather than using a recast mesh (most likely not entirely accurate.)

    Code:
    public enum IntersectFlags {
        None,
        DoodadCollision     = 0x00000001,
        DoodadRender        = 0x00000002,
        WmoCollision        = 0x00000010,
        WmoRender           = 0x00000020,
        WmoNoCamCollision   = 0x00000040,
        Terrain             = 0x00000100,
        IgnoreWmoDoodad     = 0x00002000,
        LiquidWaterWalkable = 0x00010000,
        LiquidAll           = 0x00020000,
        Cull                = 0x00080000,
        EntityCollision     = 0x00100000,
        EntityRender        = 0x00200000,
    
        Collision           = DoodadCollision | WmoCollision | Terrain | EntityCollision,
        LineOfSight         = WmoCollision | EntityCollision
    }
    
    ...
    
    [UnmanagedFunctionPointer(CallingConvention.Cdecl)]
    [return: MarshalAs(UnmanagedType.I1)]
    private delegate bool World__Intersect_t(ref Vector3 start, ref Vector3 end, ref Vector3 hitPosition, ref float hitDistance, IntersectFlags flags);
    
    ...
    
    public static bool TestCollide(Vector3 start, Vector3 end, IntersectFlags flags) {
        var hitPosition = Vector3.Zero;
        var hitDistance = 1f; // Must be initialized to 1.
    
        return World__Intersect(ref start, ref end, ref hitPosition, ref hitDistance, flags);
    }
    I wonder where those flags are from
    [16:15:41] Cypher: caus the CPU is a dick
    [16:16:07] kynox: CPU is mad
    [16:16:15] Cypher: CPU is all like
    [16:16:16] Cypher: whatever, i do what i want

Similar Threads

  1. How to check if your ports are open!
    By berrz in forum WoW EMU Guides & Tutorials
    Replies: 0
    Last Post: 01-19-2009, 05:07 PM
  2. How to check total Play Time
    By NeoMarine in forum WoW EMU Questions & Requests
    Replies: 2
    Last Post: 01-04-2009, 12:33 PM
  3. how to check last name of the account
    By karach in forum WoW Scams Help
    Replies: 8
    Last Post: 10-06-2008, 07:37 PM
  4. How to check if a thread is copypasta.
    By XinuX in forum Community Chat
    Replies: 8
    Last Post: 08-13-2008, 10:35 AM
  5. Replies: 10
    Last Post: 05-20-2008, 09:45 AM
All times are GMT -5. The time now is 10:03 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search