Check if ability target type is "Point Target"?

Hi, using GetAbilityTargetType() on a point target ability returns the integer 0, which points to a no target ability. There is no entry for "point target" in the target type table. How do I check if any arbitrary ability is a no target vs a point target? Thank you :)

Here is my code: https://i.gyazo.com/67822e8fceb7495efb7ee2412c5dac98.png

Here is the ability target table: https://i.gyazo.com/833fd0abed6f5db35ef9eb82146b37b1.png

Comments

  • Posts: 4

    I accidently mixed up the table and code, sorry :D

  • I'm using following code to get ability type and ability target/point: local ability = params.ability local ability_type local ability_target if ability:GetCursorTarget() then ability_target = ability:GetCursorTarget() ability_type = DOTA_ABILITY_BEHAVIOR_UNIT_TARGET if ability_target:IsNull() or not ability_target:IsAlive() then return end elseif ability:GetCursorTargetingNothing() then ability_target = ability:GetCursorTargetingNothing() ability_type = DOTA_ABILITY_BEHAVIOR_NO_TARGET elseif ability:GetCursorPosition() then ability_target = ability:GetCursorPosition() ability_type = DOTA_ABILITY_BEHAVIOR_POINT end And after i do all magic i want with gained data, just by compairing ability_type with variable(name from enum) or represented number. Hope this will help!

  • Oh, sorry for that mess, forgot that code blocks here are started with another symbols. Here you go:

        local ability = params.ability
        local ability_type
        local ability_target
        if ability:GetCursorTarget() then
            ability_target = ability:GetCursorTarget()
            ability_type = DOTA_ABILITY_BEHAVIOR_UNIT_TARGET
            if ability_target:IsNull() or not ability_target:IsAlive() then return end
        elseif ability:GetCursorTargetingNothing() then
            ability_target = ability:GetCursorTargetingNothing()
            ability_type = DOTA_ABILITY_BEHAVIOR_NO_TARGET
        elseif ability:GetCursorPosition() then
            ability_target = ability:GetCursorPosition()
            ability_type = DOTA_ABILITY_BEHAVIOR_POINT
        end
    
  • Posts: 11

    GetAbilityTargetType() returns the type of units the ability targets, if it were a unit target. To check what kind of behavior it has (because that's what you want), you can use the following:

    ```lua if bit.band(ability:GetBehavior(), DOTA_ABILITY_BEHAVIOR_UNIT_TARGET) ~= 0 then -- Unit target! end

    if (bit.band(ability:GetBehavior(), DOTA_ABILITY_BEHAVIOR_POINT) ~= 0 then -- Point target! end ```

    Ofcourse if your ability has both behaviors at the same time, you just check if either target unit (ability:GetCursrotTarget()) or target position (ability:GetCursorPosition()) is not nil

  • Posts: 4

    Thank you guys :D Indeed, the difference between behavior and target type :D THank you very much! It's working to my needs now :)!!