Problem with UnitDynamicFlags.Dead menu

Shout-Out

User Tag List

Results 1 to 15 of 15
  1. #1
    miceiken's Avatar Contributor Authenticator enabled
    Reputation
    209
    Join Date
    Dec 2007
    Posts
    401
    Thanks G/R
    7/9
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Problem with UnitDynamicFlags.Dead

    Okay everyone, so I just realized that my WoWUnit.Dead function doesn't work to well, in fact it always returns false! The weird thing is that for instance WoWUnit.Lootable that also is an UnitDynamicFlag returns true when a corpse is lootable. Here's some code:

    Code:
    UNIT_DYNAMIC_FLAGS = 0x4E // 0x4E * 4 = 0x138
    UnitDynamicFlags.Dead = 0x20,
    Code:
    public bool HasDynamicFlag(Enums.UnitDynamicFlags flag)
    {
        return ((Memory.Read<int>(UnitDescriptor + (uint)Descriptors.eUnitFields.UNIT_DYNAMIC_FLAGS * 4)) & (int)flag) != 0;
    }
    Code:
    public bool Dead
    {
        get
        {
            return HasDynamicFlag(Enums.UnitDynamicFlags.Dead);
        }
    }
    
    public bool Lootable
    {
        get
        {
            return HasDynamicFlag(Enums.UnitDynamicFlags.Lootable);
        }
    }
    Code:
     21:21:43  Target Info: Bristleback Thornweaver
     21:21:43    Combat: False
     21:21:43    Casting: False
     21:21:43    Dead: False
     21:21:43    Facing: 1,093227
     21:21:43    Faction: 111
     21:21:43    GUID: 17379391016734158679
     21:21:43    Level: 18
     21:21:43    Lootable: True
     21:21:43    Skinnable: False
     21:21:43    Tagged: True
     21:21:43  ------------------------------------
    Notice how the Lootable = true, yet the Dead = false!

    Problem with UnitDynamicFlags.Dead
  2. #2
    TOM_RUS's Avatar Legendary
    Reputation
    914
    Join Date
    May 2008
    Posts
    699
    Thanks G/R
    0/52
    Trade Feedback
    0 (0%)
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Checking dynamic flags to ensure that unit is dead isn't correct.
    Better check health or something else.

  3. #3
    miceiken's Avatar Contributor Authenticator enabled
    Reputation
    209
    Join Date
    Dec 2007
    Posts
    401
    Thanks G/R
    7/9
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I see, just thought that this was the safest way to do it...

  4. #4
    XTZGZoReX's Avatar Active Member
    Reputation
    32
    Join Date
    Apr 2008
    Posts
    173
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Health should be your best bet, indeed.

  5. #5
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    The 'Dead' flag doesn't ensure the unit is dead. It just ensures it has a gray name.

    WoW uses if (unit.Health <= 0) to check for dead.

  6. #6
    miceiken's Avatar Contributor Authenticator enabled
    Reputation
    209
    Join Date
    Dec 2007
    Posts
    401
    Thanks G/R
    7/9
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, thanks

  7. #7
    XTZGZoReX's Avatar Active Member
    Reputation
    32
    Join Date
    Apr 2008
    Posts
    173
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Just for the record: dynamicflags are only for visuals. Keep in mind that a unit can appear dead without actually being dead.

  8. #8
    Nesox's Avatar ★ Elder ★
    Reputation
    1280
    Join Date
    Mar 2007
    Posts
    1,238
    Thanks G/R
    0/3
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Apoc View Post
    The 'Dead' flag doesn't ensure the unit is dead. It just ensures it has a gray name.

    WoW uses if (unit.Health <= 0) to check for dead.
    Wouldn't that make the 'Dead' flag same as the Tagged? o.O

  9. #9
    kolis764's Avatar Member
    Reputation
    -5
    Join Date
    Feb 2007
    Posts
    18
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    i think hes saying that the unit would be under level has their name would show in gray. I think you got your flag & wrong.

    Code:
    public bool HostileToPlayer {
        get { return ((Faction & HostileToPlayerFlag) != HostileToPlayerFlag); }
    }
    if you do and operator on a field it will return the checked flag if it is correct, so not, not 0 has stated above.
    Last edited by kolis764; 03-17-2010 at 08:06 AM.

  10. #10
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by kolis764 View Post
    i think hes saying that the unit would be under level has their name would show in gray. I think you got your flag & wrong.

    Code:
    public bool HostileToPlayer {
        get { return ((Faction & HostileToPlayerFlag) != HostileToPlayerFlag); }
    }
    if you do and operator on a field it will return the checked flag if it is correct, so not, not 0 has stated above.
    Uhhh... right...

    if ((flags & flag) != 0)

    ^ That's all you need to check flags. It's a full bitwise AND, so anything other than 0 means it's 'on'.

  11. #11
    kolis764's Avatar Member
    Reputation
    -5
    Join Date
    Feb 2007
    Posts
    18
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    what if your flag IS 0

  12. #12
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Then it still works?

    Please read up on how the AND operation works.

  13. #13
    kolis764's Avatar Member
    Reputation
    -5
    Join Date
    Feb 2007
    Posts
    18
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    1101
    0000
    ____
    0000

    Is equal to zero so no it doesnt work. The result of a AND should be the flag you are looking for period.


    L2BINARY

    second point
    Last edited by kolis764; 03-18-2010 at 07:55 AM.

  14. #14
    adaephon's Avatar Active Member
    Reputation
    76
    Join Date
    May 2009
    Posts
    167
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Except that zero would indicate the absence of all flags, and thus is an illogical situation.

    Edit:
    Code:
    public bool HostileToPlayer {
        get { return ((Faction & HostileToPlayerFlag) != HostileToPlayerFlag); }
    }
    Faction = 1111
    HostileToPlayerFlag = 1010
    Result = 1010
    return result != HostileToPlayerFlag
    1010 != 1010 -> false -> HostileToPlayer is incorrectly false.
    Last edited by adaephon; 03-18-2010 at 10:08 AM.

  15. #15
    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 kolis764 View Post
    1101
    0000
    ____
    0000

    Is equal to zero so no it doesnt work. The result of a AND should be the flag you are looking for period.


    L2BINARY

    second point

    It all comes down on how you like it to work.
    If you use != 0, it will return true if you have any of the flags in the value you AND with set.
    That means (with != 0):
    1001
    & 1010
    will return 1000, hence != 0 will be true. If you however want to check for all of the flags, you should use '== flag'. In that case:
    1001
    & 1010
    still returns 1000, hence == 1010 will be false.

    TL;DR;
    Use != 0 if you want to check for one of more flags in a single operation. Usually you will only check on a single flag where != 0 and == flag will be the same.
    [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. Problems With Instance Switching
    By SandLOL in forum WoW ME Questions and Requests
    Replies: 2
    Last Post: 08-30-2006, 09:22 PM
  2. Problem with WPE
    By weedlord in forum World of Warcraft General
    Replies: 0
    Last Post: 08-14-2006, 03:35 AM
  3. Problem with BWH 1.11.2
    By gwl15 in forum World of Warcraft General
    Replies: 3
    Last Post: 08-11-2006, 05:37 PM
  4. Problem with CE.
    By Eldretch in forum World of Warcraft General
    Replies: 1
    Last Post: 08-08-2006, 06:49 PM
  5. I have problem with BHW 3.0
    By sunrize1 in forum World of Warcraft General
    Replies: 1
    Last Post: 07-17-2006, 08:49 AM
All times are GMT -5. The time now is 01:01 PM. 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