1. Head to the 33rd Modeling Contest Poll and drink to your heart's desire.
    Dismiss Notice
  2. Choose your means of doom in the 17th Mini Mapping Contest Poll.
    Dismiss Notice
  3. A slave to two rhythms, the 22nd Terraining Contest is here.
    Dismiss Notice
  4. The heavens smile on the old faithful. The 16th Techtree Contest has begun.
    Dismiss Notice
  5. The die is cast - the 6th Melee Mapping Contest results have been announced. Onward to the Hive Cup!
    Dismiss Notice
  6. The glory of the 20th Icon Contest is yours for the taking!
    Dismiss Notice
  7. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

[Lua] Hidden lua functions

Discussion in 'The Lab' started by Drake53, Jan 15, 2020.

Tags:
  1. Drake53

    Drake53

    Joined:
    Jan 1, 2018
    Messages:
    420
    Resources:
    0
    Resources:
    0
    Using attached testmap, I found 50+ functions that aren't listed in common.j, Blizzard.j, or common.ai, and that aren't part of lua's standard library either:
    functions:
    DzAPI_Map_SaveServerValue
    DzAPI_Map_IsRedVIP
    DzAPI_Map_GetServerArchiveDrop
    DzAPI_Map_GetLadderRank
    DzAPI_Map_GetServerArchiveEquip
    DzAPI_Map_ChangeStoreItemCoolDown
    DzAPI_Map_GetActivityData
    DzAPI_Map_GetServerValue
    DzAPI_Map_HasMallItem
    DzAPI_Map_GetMapLevel
    DzAPI_Map_UpdatePlayerHero
    DzAPI_Map_SavePublicArchive
    DzAPI_Map_IsRPGLadder
    DzAPI_Map_OrpgTrigger
    DzAPI_Map_ChangeStoreItemCount
    DzAPI_Map_GetMatchType
    DzAPI_Map_IsBlueVIP
    DzAPI_Map_UseConsumablesItem
    DzAPI_Map_GetServerValueErrorCode
    DzAPI_Map_GetPublicArchive
    DzAPI_Map_ToggleStore
    DzAPI_Map_MissionComplete
    DzAPI_Map_GetMapConfig
    DzAPI_Map_GetUserID
    DzAPI_Map_Ladder_SetStat
    DzAPI_Map_GetGuildRole
    DzAPI_Map_GetMapLevelRank
    DzAPI_Map_GetLadderLevel
    DzAPI_Map_IsRPGLobby
    DzAPI_Map_GetGuildName
    DzAPI_Map_GetGameStartTime
    DzAPI_Map_GetPlatformVIP
    DzAPI_Map_Ladder_SetPlayerStat
    DzAPI_Map_Statistics
    DzAPI_Map_Stat_SetStat

    __jarray
    BlzDeleteHeroAbility
    BlzGetHeroStat
    BlzSetHeroStatEx
    BlzGetUnitMovementType
    BlzSetUnitMovementType
    BlzGetUnitArmorType
    BlzGetHeroPrimaryStatById
    BlzGetHeroPrimaryStat
    BlzSetHeroPrimaryStat
    DebugBreak
    DialogSetAsync
    FourCC
    SetStackedSound
    SetStackedSoundRect
    ClearStackedSound
    ClearStackedSoundRect
    TypeDefine

    fields:
    _DEBUG (boolean)
    _GV (userdata)
    globals (userdata)
     

    Attached Files:

    Last edited: Jan 15, 2020
  2. mori

    mori

    Joined:
    Jun 13, 2016
    Messages:
    445
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Should probably be mentioned that the DzAPI ones are just stubs for backwards-compatibility with the NetEase APIs (or whatever), or something along those lines. At least this is what was corroborated to us back when the Lua update just landed.

    The rest are probably not listed for a reason, either unfinished or instability.

    I do wonder though if any of these actually carry any useful functionality, or if we're going to get any Lua-exclusive APIs in the future.
     
  3. Drake53

    Drake53

    Joined:
    Jan 1, 2018
    Messages:
    420
    Resources:
    0
    Resources:
    0
    Right, thanks for mentioning that. I found the documentation on these here. For some reason only the first 34 out of 52 were found, and DzAPI_Map_UpdatePlayerHero is not listed on that page.

    I only knew of __jarray and FourCC before, which are used for GUI triggers when the map's script language is set to lua, so at least these two are useful. Like you said though, the others are probably not usable, considering even some of the new natives we can find in common.j are still buggy.
     
  4. Tasyen

    Tasyen

    Joined:
    Jul 18, 2010
    Messages:
    1,656
    Resources:
    36
    Tools:
    2
    Maps:
    3
    Spells:
    11
    Tutorials:
    19
    JASS:
    1
    Resources:
    36
    globals is used in GUI for Real variable's value becomes x events, such variables are created/written in the globals.
     
  5. Drake53

    Drake53

    Joined:
    Jan 1, 2018
    Messages:
    420
    Resources:
    0
    Resources:
    0
    Did some quick testing for the Blz functions, since their arguments aren't that hard to guess, and found most them them seem to work just fine. They may even be usable in JASS if you declare them similar to how you would use common.ai functions. Note that for some I did not check the return value, but they are probably nothing or boolean. Anyways here's what I found:
    Code (vJASS):
    // Stat indices are same as type heroattribute: 1=str, 2=int, 3=agi
    // MoveType indices are same as type movetype: 0=unknown, 1=foot, 2=fly, 4=horse, 8=hover, 16=float, 32=amphibious, 64=unbuildable
    // ArmorType indices 'should be' same as type armortype: 0=unknown, 1=flesh, 2=metal, 3=wood, 4=ethereal, 5=stone (forgot to test this since they all returned 1)
    BlzDeleteHeroAbility takes unit whichUnit, integer rawcode returns ? // Sets level back to 0, does not refund skillpoints.
    BlzGetHeroStat takes unit whichUnit, integer stat returns integer
    BlzSetHeroStatEx takes unit whichUnit, integer stat, integer value returns ?
    BlzGetUnitMovementType takes unit whichUnit returns integer // Get unit's Movement - Type ('umvt')
    BlzSetUnitMovementType takes unit whichUnit, integer movementType returns ?
    BlzGetUnitArmorType takes unit whichUnit returns integer // Get unit's Combat - Armor Type ('uarm')
    BlzGetHeroPrimaryStat takes unit whichUnit returns integer // Returns 0 if unit is not a hero
    BlzSetHeroPrimaryStat takes unit whichUnit, integer value returns ?


    Cool, didn't know that.
     
    Last edited: Jan 15, 2020
  6. mori

    mori

    Joined:
    Jun 13, 2016
    Messages:
    445
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    Does move type actually update when called via that function? I.e. does it turn a walking unit into a flying one? Would be awesome if it did.
     
  7. Drake53

    Drake53

    Joined:
    Jan 1, 2018
    Messages:
    420
    Resources:
    0
    Resources:
    0
    I only tried turning flying into foot, which set the flying height to 0, but other than that it didn't seem to change much. The unit was still able to 'fly over' ground units, and was targeted as air. My testmap did not have cliffs/water, so I couldn't test its interactions with those.

    EDIT: can confirm: after changing it to foot, the unit still interacts with cliffs and water as if its movement type were still flying.
     
    Last edited: Jan 15, 2020
  8. mori

    mori

    Joined:
    Jun 13, 2016
    Messages:
    445
    Resources:
    2
    Tools:
    1
    Tutorials:
    1
    Resources:
    2
    That's a bummer.
     
  9. JC Helas

    JC Helas

    Joined:
    Oct 19, 2014
    Messages:
    126
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    WTF,, the changing primary stat shock me at all XD fuuuq nice one bro