Results 1 to 4 of 4

Thread: DOTA_UNIT_TARGET_CUSTOM

  1. #1
    Basic Member
    Join Date
    Dec 2016
    Posts
    627

    Question DOTA_UNIT_TARGET_CUSTOM

    What does
    Code:
    AbilityUnitTargetType	"DOTA_UNIT_TARGET_CUSTOM"
    Map against in?
    Code:
    ABILITY_TARGET_TYPE_NONE
    ABILITY_TARGET_TYPE_HERO
    ABILITY_TARGET_TYPE_CREEP
    ABILITY_TARGET_TYPE_BUILDING
    ABILITY_TARGET_TYPE_COURIER
    ABILITY_TARGET_TYPE_OTHER
    ABILITY_TARGET_TYPE_TREE
    ABILITY_TARGET_TYPE_BASIC
    ABILITY_TARGET_TYPE_ALL
    Writing code for PA to retreat by using phantom strike on friendly "heroes" or "creeps"

  2. #2
    Basic Member
    Join Date
    Mar 2012
    Posts
    1,754
    Snipet of my ability manager

    Code:
    	local behavior = Ability:GetBehavior();
    	local targetTeam = Ability:GetTargetTeam();
    	local targetType = Ability:GetTargetType();
    	
    	bCanTargetUnit 		= (IsFlagSet(behavior, AbilityBehaviors.ABILITY_BEHAVIOR_UNIT_TARGET) == true);
    	bCanTargetLocation 	= (IsFlagSet(behavior, AbilityBehaviors.ABILITY_BEHAVIOR_POINT) == true);
    	bCanTargetAllies 	= ((IsFlagSet(targetTeam, AbilityTargetTeam.ABILITY_TARGET_TEAM_FRIENDLY) == true) or (IsFlagSet(targetTeam, AbilityTargetTeam.ABILITY_TARGET_TEAM_BOTH) == true));
    	bCanTargetEnemies 	= ((IsFlagSet(targetTeam, AbilityTargetTeam.ABILITY_TARGET_TEAM_ENEMY) == true) or (IsFlagSet(targetTeam, AbilityTargetTeam.ABILITY_TARGET_TEAM_BOTH) == true));
    	bCannotTargetSelf 	= ((IsFlagSet(targetType, AbilityTargetType.ABILITY_TARGET_TYPE_CUSTOM) == true) and (bCanTargetUnit == true) and ((bCanTargetAllies == true) or (IsFlagSet(targetTeam, AbilityTargetTeam.ABILITY_TARGET_TEAM_CUSTOM) == true)));
    	bCanTargetTrees 	= (IsFlagSet(targetType, AbilityTargetType.ABILITY_TARGET_TYPE_TREE) == true);
    	bCanTargetHeroes 	= (IsFlagSet(targetType, AbilityTargetType.ABILITY_TARGET_TYPE_HERO) == true);
    	bCanTargetCreeps 	= (IsFlagSet(targetType, AbilityTargetType.ABILITY_TARGET_TYPE_CREEP) == true);
    
    	bIsToggle			= Ability:IsToggle();
    	bIsPassive			= Ability:IsPassive();
    	bIsUltimate			= Ability:IsUltimate();
    Normally, for simple flags you have the generic ABILITY_TARGET_TYPE_TREE, ABILITY_TARGET_TYPE_CREEP, ABILITY_TARGET_TYPE_BUILDING etc.
    This has generic C++ code that just has boolean checks depending on AbilityTargetType flags or AbilityTargetTeam enum flags. This, however, doesn't work for special targeting (such as abilities targeting the caster). Therefore, the custom flag is set, meaning it calls a special c++ functions used specifically in that case. With some clever bit checks (such as the ones I used), you should be able to determine that the ability can target the caster.

    So far I didn't get around to test it, but it should be correct. Or at least it sounds about right in my head
    I used npc_abilities.txt to track it and according to the above logic, it should be correct.

    Here are the enums:

    Code:
    AbilityBehaviors =
    {
    	ABILITY_BEHAVIOR_NONE					= 0x00000000,
    	ABILITY_BEHAVIOR_HIDDEN 				= 0x00000001,
    	ABILITY_BEHAVIOR_PASSIVE 				= 0x00000002,
    	ABILITY_BEHAVIOR_NO_TARGET 				= 0x00000004,
    	ABILITY_BEHAVIOR_UNIT_TARGET	 		= 0x00000008,
    	ABILITY_BEHAVIOR_POINT 					= 0x00000010,
    	ABILITY_BEHAVIOR_AOE		 			= 0x00000020,
    	ABILITY_BEHAVIOR_NOT_LEARNABLE 			= 0x00000040,
    	ABILITY_BEHAVIOR_CHANNELLED 			= 0x00000080,
    	ABILITY_BEHAVIOR_ITEM	 				= 0x00000100,
    	ABILITY_BEHAVIOR_TOGGLE 				= 0x00000200,
    	ABILITY_BEHAVIOR_DIRECTIONAL 			= 0x00000400,
    	ABILITY_BEHAVIOR_IMMEDIATE 				= 0x00000800,
    	ABILITY_BEHAVIOR_AUTOCAST 				= 0x00001000,
    	ABILITY_BEHAVIOR_OPTIONAL_UNIT_TARGET 	= 0x00002000,
    	ABILITY_BEHAVIOR_OPTIONAL_POINT 		= 0x00004000,
    	ABILITY_BEHAVIOR_OPTIONAL_NO_TARGET 	= 0x00008000,
    	ABILITY_BEHAVIOR_AURA 					= 0x00010000,
    	ABILITY_BEHAVIOR_ATTACK 				= 0x00020000,
    	ABILITY_BEHAVIOR_DONT_RESUME_MOVEMENT 	= 0x00040000,
    	ABILITY_BEHAVIOR_ROOT_DISABLES 			= 0x00080000,
    	ABILITY_BEHAVIOR_UNRESTRICTED 			= 0x00100000,
    	ABILITY_BEHAVIOR_IGNORE_PSEUDO_QUEUE 	= 0x00200000,
    	ABILITY_BEHAVIOR_IGNORE_CHANNEL 		= 0x00400000,
    	ABILITY_BEHAVIOR_DONT_CANCEL_MOVEMENT 	= 0x00800000,
    	ABILITY_BEHAVIOR_DONT_ALERT_TARGET 		= 0x01000000,
    	ABILITY_BEHAVIOR_DONT_RESUME_ATTACK 	= 0x02000000,
    	ABILITY_BEHAVIOR_NORMAL_WHEN_STOLEN 	= 0x04000000,
    	ABILITY_BEHAVIOR_IGNORE_BACKSWING 		= 0x08000000,
    	ABILITY_BEHAVIOR_RUNE_TARGET 			= 0x10000000,
    	ABILITY_BEHAVIOR_DONT_CANCEL_CHANNEL	= 0x20000000,
    	ABILITY_BEHAVIOR_VECTOR_TARGETING		= 0x40000000,
    	ABILITY_BEHAVIOR_LAST_RESORT_POINT 		= 0x80000000
    }
    
    AbilityTargetFlags = 
    {
    	ABILITY_TARGET_FLAG_NONE						= 0x000000,
    	ABILITY_TARGET_FLAG_RANGED_ONLY					= 0x000002,
    	ABILITY_TARGET_FLAG_MELEE_ONLY					= 0x000004,
    	ABILITY_TARGET_FLAG_DEAD						= 0x000008,
    	ABILITY_TARGET_FLAG_MAGIC_IMMUNE_ENEMIES		= 0x000010,
    	ABILITY_TARGET_FLAG_NOT_MAGIC_IMMUNE_ALLIES		= 0x000020,
    	ABILITY_TARGET_FLAG_INVULNERABLE				= 0x000040,
    	ABILITY_TARGET_FLAG_FOW_VISIBLE					= 0x000080,
    	ABILITY_TARGET_FLAG_NO_INVIS					= 0x000100,
    	ABILITY_TARGET_FLAG_NOT_ANCIENTS				= 0x000200,
    	ABILITY_TARGET_FLAG_PLAYER_CONTROLLED			= 0x000400,
    	ABILITY_TARGET_FLAG_NOT_DOMINATED 				= 0x000800,
    	ABILITY_TARGET_FLAG_NOT_SUMMONED				= 0x001000,
    	ABILITY_TARGET_FLAG_NOT_ILLUSIONS				= 0x002000,
    	ABILITY_TARGET_FLAG_NOT_ATTACK_IMMUNE			= 0x004000,
    	ABILITY_TARGET_FLAG_MANA_ONLY					= 0x008000,
    	ABILITY_TARGET_FLAG_CHECK_DISABLE_HELP 			= 0x010000,
    	ABILITY_TARGET_FLAG_NOT_CREEP_HERO				= 0x020000,
    	ABILITY_TARGET_FLAG_OUT_OF_WORLD				= 0x040000,
    	ABILITY_TARGET_FLAG_NOT_NIGHTMARED				= 0x080000,
    	ABILITY_TARGET_FLAG_PREFER_ENEMIES				= 0x100000
    }
    
    AbilityTargetTeam = 
    {
    	ABILITY_TARGET_NONE				= 0x0000,
    	ABILITY_TARGET_TEAM_FRIENDLY	= 0x0001,
    	ABILITY_TARGET_TEAM_ENEMY		= 0x0010,
    	ABILITY_TARGET_TEAM_BOTH		= 0x0011,
    	ABILITY_TARGET_TEAM_CUSTOM		= 0x0100
    }
    
    AbilityTargetType = 
    {
    	ABILITY_TARGET_TYPE_NONE		= 0x00,
    	ABILITY_TARGET_TYPE_HERO		= 0x01,
    	ABILITY_TARGET_TYPE_CREEP		= 0x02,
    	ABILITY_TARGET_TYPE_BUILDING	= 0x04,
    	ABILITY_TARGET_TYPE_COURIER		= 0x10,
    	ABILITY_TARGET_TYPE_BASIC		= 0x12,	-- creep or courier
    	ABILITY_TARGET_TYPE_OTHER		= 0x20,	-- wards etc.
    	ABILITY_TARGET_TYPE_ALL			= 0x37,	-- but not trees or custom
    	ABILITY_TARGET_TYPE_TREE		= 0x40,
    	ABILITY_TARGET_TYPE_CUSTOM		= 0x80
    }
    Unfortunately VBull doesn't format it properly, but it looks really nice in my N++
    Last edited by The Nomad; 03-17-2017 at 12:15 PM.
    Explanations on the normal, high and very high brackets in replays: here, here & here
    Why maphacks won't work in D2: here

  3. #3
    Basic Member
    Join Date
    Dec 2016
    Posts
    627
    Thanks, didn't realize Target Type was a flag... would have expected GetTargetTypeFlag() instead of GetTargetType()

  4. #4
    Basic Member
    Join Date
    Mar 2012
    Posts
    1,754
    They are all flags, as you can see
    Each target property is a bitfield since you can hit more than one at a given time, depending on the context.

    Just checked the file again. There might be a few issues. You should double check this with Pugna (esp. Decrepify). I think the logic is fine for most cases, but there might be some where I might be wrong (like Pugna, as I said, I didn't get around to test it)
    Last edited by The Nomad; 03-17-2017 at 05:57 PM.
    Explanations on the normal, high and very high brackets in replays: here, here & here
    Why maphacks won't work in D2: here

Posting Permissions

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