• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Help with Custom Hotkey Functions

Status
Not open for further replies.
Level 8
Joined
Jun 26, 2019
Messages
318
Hello all. This is for the custom hotkeys on items of inventory system. I need help with "UnitItemUseTarget" or "BlzFrameClick" functions for to use them on the "point" target items like "Healing Slave" or "Flare" items. Anyone out there know how to build functions with those codes? Or is there any other way to build function like this to be working on the "point" target items? Like the selected unit trigger? Selected unit is fine with me.

I need this "UnitItemUse" function shown below that is a instant target to be turns into "UnitItemUseTarget" or "BlzFrameClick" function that would be a point target. Or I need the other function to be added to this trigger system that works on the "point" items. Because of this "UnitItemUse" function only works on "instant" items.

I want the "UnitItemUseTarget" or "BlzFrameClick" function to be like Flame Strike or Rain of Fire ability, or anything that is the "point" target. But, I also need it to be working on all "point" items that are used in one of Blizzard maps called "Market Squares."

The custom hotkeys for inventory items has to be look like this in the picture below.
upload_2020-9-7_18-27-0.png



JASS:
function KeyPressActions takes nothing returns nothing
    local integer pid = GetPlayerId(GetTriggerPlayer())
    local oskeytype pressedkey = BlzGetTriggerPlayerKey()
    local item useitem
    if (pressedkey == OSKEY_E) then
        set useitem = UnitItemInSlot(udg_tempUnitVar[pid],0)
        call UnitUseItem(udg_tempUnitVar[pid],useitem)
    elseif (pressedkey == OSKEY_R) then
        set useitem = UnitItemInSlot(udg_tempUnitVar[pid],1)
        call UnitUseItem(udg_tempUnitVar[pid],useitem)
    elseif (pressedkey == OSKEY_D) then
        set useitem = UnitItemInSlot(udg_tempUnitVar[pid],2)
        call UnitUseItem(udg_tempUnitVar[pid],useitem)
    elseif (pressedkey == OSKEY_F) then
        set useitem = UnitItemInSlot(udg_tempUnitVar[pid],3)
        call UnitUseItem(udg_tempUnitVar[pid],useitem)
    elseif (pressedkey == OSKEY_C) then
        set useitem = UnitItemInSlot(udg_tempUnitVar[pid],4)
        call UnitUseItem(udg_tempUnitVar[pid],useitem)
    elseif (pressedkey == OSKEY_V) then
        set useitem = UnitItemInSlot(udg_tempUnitVar[pid],5)
        call UnitUseItem(udg_tempUnitVar[pid],useitem)
    endif
endfunction

// @pInt = player number
function InitializeHotkey takes integer pInt returns nothing
    local integer pid = GetPlayerId(GetTriggerPlayer())

    local trigger keytrig = CreateTrigger()

    call BlzTriggerRegisterPlayerKeyEvent(keytrig, Player(pInt-1), OSKEY_E, 0, false)
    call BlzTriggerRegisterPlayerKeyEvent(keytrig, Player(pInt-1), OSKEY_R, 0, false)
    call BlzTriggerRegisterPlayerKeyEvent(keytrig, Player(pInt-1), OSKEY_D, 0, false)
    call BlzTriggerRegisterPlayerKeyEvent(keytrig, Player(pInt-1), OSKEY_F, 0, false)
    call BlzTriggerRegisterPlayerKeyEvent(keytrig, Player(pInt-1), OSKEY_C, 0, false)
    call BlzTriggerRegisterPlayerKeyEvent(keytrig, Player(pInt-1), OSKEY_V, 0, false)

    //call TriggerAddCondition(keytrig, null)
    call TriggerAddAction(keytrig, function KeyPressActions)

endfunction

  • UnitSelection
    • Events
      • Player - Player 1 (Red) Selects a unit
      • Player - Player 2 (Blue) Selects a unit
      • Player - Player 3 (Teal) Selects a unit
      • Player - Player 4 (Purple) Selects a unit
      • Player - Player 5 (Yellow) Selects a unit
      • Player - Player 6 (Orange) Selects a unit
      • Player - Player 7 (Green) Selects a unit
    • Conditions
      • ((Triggering unit) is A Hero) Equal to True
      • (Owner of (Triggering unit)) Equal to (Triggering player)
    • Actions
      • Set VariableSet tempUnitVar[((Player number of (Triggering player)) - 1)] = (Triggering unit)
      • Custom script: call InitializeHotkey(1)
      • Custom script: call InitializeHotkey(2)
      • Custom script: call InitializeHotkey(3)
      • Custom script: call InitializeHotkey(4)
      • Custom script: call InitializeHotkey(5)
      • Custom script: call InitializeHotkey(6)
      • Custom script: call InitializeHotkey(7)
 
Last edited:
Status
Not open for further replies.
Top