[QUESTION] isDead() or unit dead menu

User Tag List

Results 1 to 12 of 12
  1. #1
    mordok's Avatar Member
    Reputation
    11
    Join Date
    Oct 2007
    Posts
    103
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [QUESTION] isDead() or unit dead

    Im having a hard time at creating a good way too check if a unit is dead (The flag way).

    I tried UNIT_DYNAMIC_FLAGS and 0x20 to find out if the unit im targeting is dead but, it always returns false.

    I guess I could always determine if a unit is dead by checking if its lootable, but I wouldnt like to do this knowing that there´s a flag for that single purpose.

    Any Ideas??? Would it be the same for unit than for my player?
    Last edited by mordok; 12-05-2009 at 11:51 PM.
    "I'm not going to expose my methods for time bending, as i don't want to do get nerfed!"-Kynox

    [QUESTION] isDead() or unit dead
  2. #2
    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)
    Lol. GJ cleaning up after yourself. I moved the thread for ya.

    public bool Dead { get { return CurrentHealth == 0; } }

  3. #3
    mordok's Avatar Member
    Reputation
    11
    Join Date
    Oct 2007
    Posts
    103
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks APOC, but Im searching for the flag way. Checking if the unit health is 0 sometimes worked bad for me in the past.

    BTW, epic thread movment XD.
    "I'm not going to expose my methods for time bending, as i don't want to do get nerfed!"-Kynox

  4. #4
    Oowafas's Avatar Member
    Reputation
    14
    Join Date
    Jan 2009
    Posts
    31
    Thanks G/R
    0/0
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Health is zero always seemed to work for me as long as the unit didn't despawn. I think on despawns you can just check to see if it isn't in the object list though (not 100% on that).

  5. #5
    flo8464's Avatar Active Member
    Reputation
    30
    Join Date
    Apr 2009
    Posts
    434
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    UnitIsDead 0x594370

    Code:
    signed int __cdecl wowlua_UnitIsDead(int luastate)
    {
      int ST2C_4_0; // ST2C_4@0
      int luastate_c; // esi@1
      int object; // eax@3
      int v5; // ecx@4
      int v6; // eax@8
      char *unitkeyword; // eax@3
      double v8; // ST24_8@7
      __int64 guid; // [sp+14h] [bp-8h]@3
      __int64 guid_c; // [sp+Ch] [bp-10h]@3
    
      luastate_c = luastate;
      if ( !lua_isString(luastate, 1) )
      {
        lua_reportError(luastate_c, "Usage: UnitIsDead(\"unit\")", ST2C_4_0);
        return 0;
      }
      unitkeyword = (char *)lua_toString(luastate_c, 1, 0);
      guid = 0i64;
      getGuidByKeyword(unitkeyword, &guid, 0);
      guid_c = guid;
      object = getObjectByGuidFiltered(guid, 8);
      if ( object )
      {
        v5 = *(_DWORD *)(object + 0xD0);
        if ( *(_DWORD *)(v5 + 0x44) <= 0
          || (*(_DWORD *)(v5 + 0x120) >> 5) & 1 && (guid = **(_QWORD **)(object + 8), !sub_4B2B40(&guid)) )
        {
    LABEL_7:
          __asm
          {
            fld1
            fstp    [esp+1Ch+var_1C]
          }
          lua_pushNumber(luastate_c, v8);
          return 1;
        }
      }
      else
      {
        v6 = sub_4B3A10(&guid_c);
        if ( v6 && *(_BYTE *)(v6 + 8) & 4 )
          goto LABEL_7;
      }
      lua_pushNil(luastate_c);
      return 1;
    }
    Hey, it compiles! Ship it!

  6. #6
    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)
    Code:
    signed int __cdecl lua_UnitIsDead(int *pL)
    {
      int *v1; // esi@1
      WoWUnit *v3; // eax@3
      UnitDescriptors *v4; // ecx@4
      int v5; // eax@8
      char *v6; // eax@3
      double v7; // ST24_8@7
      WGUID guid; // [sp+14h] [bp-8h]@3
      WGUID v9; // [sp+Ch] [bp-10h]@3
    
      v1 = pL;
      if ( !FrameScript__IsString(pL, 1) )
      {
        FrameScript_DisplayError(v1, "Usage: UnitIsDead(\"unit\")");
        return 0;
      }
      v6 = FrameScript_ToLString(v1, 1, 0);
      guid = 0i64;
      GetGUIDByKeyword(v6, &guid, 0);
      v9 = guid;
      v3 = (WoWUnit *)ClntObjMgrObjectPtr(guid, OT_UNIT);
      if ( v3 )
      {
        v4 = v3->UnitInfo;
        if ( v4->UNIT_FIELD_HEALTH <= 0
          || (v4->UNIT_DYNAMIC_FLAGS >> 5) & 1
          && (*(_QWORD *)&guid = *(_QWORD *)v3->Object.ObjInfo, !sub_4B2B40((int)&guid)) )
        {
    LABEL_7:
          __asm
          {
            fld1                    ; 
            fstp    [esp+1Ch+var_1C]; 
          }
          FrameScript_PushNumber(v1, v7);
          return 1;
        }
      }
      else
      {
        v5 = sub_4B3A10(&v9);
        if ( v5 && *(_BYTE *)(v5 + 8) & 4 )
          goto LABEL_7;
      }
      FrameScript_pushnil(v1);
      return 1;
    }

  7. #7
    mordok's Avatar Member
    Reputation
    11
    Join Date
    Oct 2007
    Posts
    103
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    if ( v4->UNIT_FIELD_HEALTH <= 0 || (v4->UNIT_DYNAMIC_FLAGS >> 5)

    So you check if its health is <= 0 or (dynamiflag inputed to 5) & 1

    Im trying to do it without injection, btw(not that im scared of it, its just a mater of personal taste XD)

    Im not sure whats the >> equivalent in C# ill try to find that first.

    Many thanks for your efforts helping me.
    "I'm not going to expose my methods for time bending, as i don't want to do get nerfed!"-Kynox

  8. #8
    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 mordok View Post
    if ( v4->UNIT_FIELD_HEALTH <= 0 || (v4->UNIT_DYNAMIC_FLAGS >> 5)

    So you check if its health is <= 0 or (dynamiflag inputed to 5) & 1

    Im trying to do it without injection, btw(not that im scared of it, its just a mater of personal taste XD)

    Im not sure whats the >> equivalent in C# ill try to find that first.

    Many thanks for your efforts helping me.
    1 << 5 == 0x20

    Anyhow; just check if health <= 0. It will always work if the unit is valid. (The other check is a sanity check, which hardly ever gets used anyway)

  9. #9
    mordok's Avatar Member
    Reputation
    11
    Join Date
    Oct 2007
    Posts
    103
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks apoc and flo8464. That would do the trick ^^.
    "I'm not going to expose my methods for time bending, as i don't want to do get nerfed!"-Kynox

  10. #10
    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)
    Originally Posted by mordok View Post
    Im not sure whats the >> equivalent in C# ill try to find that first.

    Many thanks for your efforts helping me.
    Not sure if you found it, but in that context '<<' and '>>' are binary or bit shift operators and they are the same in C# and C++

  11. #11
    arthanos2's Avatar Member
    Reputation
    8
    Join Date
    Jan 2009
    Posts
    27
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Any idea why UNIT_FIELD_HEALTH reads 0 immediately after dismounting and performing mining? After remounting it reads the correct value again.


    Tested with JUST the single memoryread to verify nothing else was rotten in my code, same results, dismount - mine -> UNIT_FIELD_HEALTH == 0.
    This seems to make absolutely no sense to me.

  12. #12
    lanman92's Avatar Active Member
    Reputation
    50
    Join Date
    Mar 2007
    Posts
    1,033
    Thanks G/R
    0/1
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You're obviously doing something wrong. Try re-grabbing pointers to your player object when you need it. It's not really a performance issue. Don't cache shit. This is my best guess.

Similar Threads

  1. Replies: 2
    Last Post: 02-03-2010, 08:12 PM
  2. Question: Target Unit By GUID in Addons, Possible?
    By zys924 in forum WoW Memory Editing
    Replies: 14
    Last Post: 12-30-2009, 12:57 PM
  3. Unit Event Lua Question (Gossip Talk)
    By moongo in forum World of Warcraft Emulator Servers
    Replies: 4
    Last Post: 05-22-2008, 07:49 PM
  4. [QUESTION]: How to make dead mob?
    By kevinno in forum World of Warcraft Emulator Servers
    Replies: 7
    Last Post: 05-12-2008, 01:25 AM
All times are GMT -5. The time now is 03:09 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