[Source] Get value of jass variable on set

This is a discussion on [Source] Get value of jass variable on set within the Warcraft 3 Hacks, bots and tools board part of the Warcraft 3 forum category; here is something i made some months ago for a battleships hack to detect where is the hidden dodo it ...

Page 1 of 3 123 LastLast
Results 1 to 10 of 23
  1. #1
    NosFTW is offline Wannabe Member
    Array
    Join Date
    Dec 2009
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rep Power
    8
    Reputation
    11

    [Source] Get value of jass variable on set

    here is something i made some months ago for a battleships hack to detect where is the hidden dodo



    it simply gets the value of a variable at set time in this case i provide a little example CE was the name of variable that was holding the dodo at the time that its set it pings the minimap for 30 seconds at unit location and changes the color of it just in case there were many around

    Code:
    void OnSetVariable(char *variable_name, DWORD handle)
    {
        if(strcmp(variable_name, "CE") == 0 && handle != 0)
        {
            float duration = 30;
            CJass::PingMinimapEx(&CJass::GetUnitX(handle).fl, &CJass::GetUnitY(handle).fl, &duration, 0x00, 0x00, 0xFF, false);
            CJass::SetUnitVertexColor(handle, 0xFF, 0x00, 0x00, 0xFF);
        }
    }
    
    void _declspec(naked) OnSetVariableWrapper()
    {
        _asm
        {
            PUSHAD
            MOV EDX, [ESI+ECX*8+0x70]
            PUSH edx
            PUSH EBP
            CALL OnSetVariable
            ADD ESP, 0x08
            POPAD
            CMP EAX, 2
            MOV EDX, [ESI+ECX*8+0x70]
            RETN
        }
    }
    hook with
    Code:
        DWORD dwOldProtect;
        VirtualProtect((void*)(g_GameDllAddress + 0x45ECEE), 7, PAGE_EXECUTE_READWRITE, &dwOldProtect);
        *(unsigned char*)(g_GameDllAddress + 0x45ECEE) = 0xE8;
        *(unsigned int*) (g_GameDllAddress + 0x45ECEE + 0x1)  = (unsigned int)OnSetVariableWrapper - (g_GameDllAddress + 0x45ECEE + 0x5);
        *(unsigned char*)(g_GameDllAddress + 0x45ECEE + 0x5) = 0x90;
        *(unsigned char*)(g_GameDllAddress + 0x45ECEE + 0x6) = 0x90;
        VirtualProtect((void*)(g_GameDllAddress + 0x45ECEE), 7, dwOldProtect, NULL);
    PS:its for the latest version 1.26
    Last edited by NosFTW; 05-05-2012 at 04:28 AM.

  2. #2
    nemo0305 is offline Addict
    Array
    Join Date
    Sep 2011
    Location
    VietNam
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rep Power
    7
    Reputation
    3
    Please help me, why i can't get Unit Postision X and Y ??? This is my code:
    typedef void __cdecl pPingMinimapEx (float *X, float *Y, float *Duration, int Red, int Green, int Blue, bool ExtraEffects); pPingMinimapEx *PingMinimapEx;
    typedef float __fastcall pGetUnitX (int hUnit); pGetUnitX *GetUnitX;//
    typedef float __fastcall pGetUnitY (int hUnit); pGetUnitY *GetUnitY;//
    GetUnitX = (pGetUnitX*)(0x6F3C5510);//
    GetUnitY = (pGetUnitY*)(0x6F3C5550);//

    float HeroX, HeroY, HeroDur = 5.00;
    int hHero_Handle;
    HeroX = GetUnitX(hHero_Handle);
    HeroY = GetUnitY(hHero_Handle);
    PingMinimapEx(&HeroX, &HeroY, &HeroDur, 0x00, 0x00, 0xFF, false);

  3. #3
    NosFTW is offline Wannabe Member
    Array
    Join Date
    Dec 2009
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rep Power
    8
    Reputation
    11
    Quote Originally Posted by nemo0305 View Post
    Please help me, why i can't get Unit Postision X and Y ??? This is my code:
    take a look at my post: Click Me

    you must use a union as return value like:
    Code:
    union DWFP
    {
        DWORD dw;
        float fl;
    };
    if you notice in the example im accessing GetUnitX(...).fl <--- the fl part its a trick to access the eax register using a union because jass natives return floats in eax and defining normal float return funcs get floats from stack

  4. #4
    nemo0305 is offline Addict
    Array
    Join Date
    Sep 2011
    Location
    VietNam
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rep Power
    7
    Reputation
    3
    one question Do you know how to read hp/hpmax mp/mpmax by unit handle ???

  5. #5
    NosFTW is offline Wannabe Member
    Array
    Join Date
    Dec 2009
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rep Power
    8
    Reputation
    11
    Quote Originally Posted by nemo0305 View Post
    one question Do you know how to read hp/hpmax mp/mpmax by unit handle ???
    try
    GetUnitState(HUNIT, HUNITSTATE) as unit state get the value of the variable called UNIT_STATE_LIFE first it should be set while game is still in lobby

    for the others you can do the same with:
    Code:
    UNIT_STATE_MAX_LIFE
    UNIT_STATE_MANA
    UNIT_STATE_MAX_MANA
    Last edited by NosFTW; 05-05-2012 at 03:31 PM.

  6. #6
    nemo0305 is offline Addict
    Array
    Join Date
    Sep 2011
    Location
    VietNam
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rep Power
    7
    Reputation
    3
    where can i get UNIT_STATE_MAX_LIFE ??? I look in your source code but don't see anything like that
    P/s: Do you know how to convert this color string FF00FF92 to 0x for use in PingMiniMapEx ??? Convert it to 0x... then replace it with int Red, Green, Blue ????
    Last edited by nemo0305; 05-05-2012 at 07:29 PM.

  7. #7
    DarkSupremo is offline Premium Member
    Array
    Join Date
    Feb 2008
    Posts
    790
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Rep Power
    13
    Reputation
    606
    just declare it:

    enum UNIT_STATE
    {
    UNIT_STATE_LIFE,
    UNIT_STATE_MAX_LIFE,
    UNIT_STATE_MANA ,
    UNIT_STATE_MAX_MANA
    };

  8. #8
    NosFTW is offline Wannabe Member
    Array
    Join Date
    Dec 2009
    Posts
    14
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rep Power
    8
    Reputation
    11
    Quote Originally Posted by DarkSupremo View Post
    just declare it:

    enum UNIT_STATE
    {
    UNIT_STATE_LIFE,
    UNIT_STATE_MAX_LIFE,
    UNIT_STATE_MANA ,
    UNIT_STATE_MAX_MANA
    };
    thoose are global handles defined in common.j it wont work that way just with the code i shared get their value and save them in a variable they get set at lobby

  9. #9
    DarkSupremo is offline Premium Member
    Array
    Join Date
    Feb 2008
    Posts
    790
    Mentioned
    2 Post(s)
    Tagged
    0 Thread(s)
    Rep Power
    13
    Reputation
    606
    it works... just need use that way:

    declare the states:

    enum UNIT_STATE
    {
    UNIT_STATE_LIFE,
    UNIT_STATE_MAX_LIFE,
    UNIT_STATE_MANA ,
    UNIT_STATE_MAX_MANA
    };

    to get current life:
    CJass::GetUnitState(unitId, CJass::ConvertUnitState(UNIT_STATE_LIFE));

    to get max life:
    CJass::GetUnitState(unitId, CJass::ConvertUnitState(UNIT_STATE_MAX_LIFE));

    to get
    current mana:
    CJass::GetUnitState(unitId, CJass::ConvertUnitState(UNIT_STATE_MANA ));

    to get max mana:
    CJass::GetUnitState(unitId, CJass::ConvertUnitState(UNIT_STATE_MAX_MANA));


    the unit states is just that:
    UNIT_STATE_LIFE = 0
    UNIT_STATE_MAX_LIFE = 1
    UNIT_STATE_MANA = 2
    UNIT_STATE_MAX_MANA = 3
    Last edited by DarkSupremo; 05-06-2012 at 01:23 AM.

  10. #10
    nemo0305 is offline Addict
    Array
    Join Date
    Sep 2011
    Location
    VietNam
    Posts
    71
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Rep Power
    7
    Reputation
    3
    CJassString ??? Where can i get it, i don't see it declare in your source NosFTW ?
    If i use jass: GetUnitName or GetItemName or GetPlayerName something like that but use with parament CJassString than i will use which one will return data name

Page 1 of 3 123 LastLast

Similar Threads

  1. [Source] Jass natives class
    By NosFTW in forum Warcraft 3 Hacks, bots and tools
    Replies: 10
    Last Post: 03-12-2014, 05:43 AM
  2. [Tut] Calling JASS Natives - RCString (how to pass JASS Strings to functions)
    By Jan Ra in forum Warcraft 3 Hacks, bots and tools
    Replies: 10
    Last Post: 06-14-2013, 11:04 AM
  3. [Release+Source=C++] Generate FULL JASS Natives List (Work to all war3 versions)
    By DarkSupremo in forum Warcraft 3 Hacks, bots and tools
    Replies: 37
    Last Post: 05-31-2012, 08:30 PM
  4. [Tut] JASS
    By risker in forum Warcraft 3 Custom Maps
    Replies: 1
    Last Post: 11-29-2008, 05:51 PM
  5. Jass???
    By Megmaconqueror in forum Warcraft 3 forum
    Replies: 2
    Last Post: 03-10-2008, 05:54 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •