Results 1 to 7 of 7

Thread: Get Ability By Bot Ability Slot

  1. #1
    Basic Member
    Join Date
    May 2014
    Posts
    270

    Get Ability By Bot Ability Slot

    Can I get bot abiility by bot ability slot ?

  2. #2
    Basic Member
    Join Date
    Dec 2016
    Posts
    733
    Not that I know of. Would be handy for Invoker.

  3. #3
    Basic Member
    Join Date
    May 2014
    Posts
    270
    Quote Originally Posted by nostrademous View Post
    Not that I know of. Would be handy for Invoker.
    And other heroes that can cast spells with D and F key. How can I actually make a general casting spells function for all spells based on how it used e.g Target Entity Based spells, Target Tree Based Spells, Location Based Spells, and Zero Cast Range Based Spells (like slardar crush)? I find a lot of similarities about how does a spell cast e.g. Slardar W, Naga Siren E, Brewmaster Q, Centaur Q. Slardar R, Naga Siren W, Brewmaster W. Legion Q, Underlord Q and W, Magnus Q, etc. So I don't have to write the same condition again and again for each spells that have similarities on how to use it.
    My purpose here is, I want to implement rubick so with me being able to get what spell on that ability slot is I can get what spells that he have stolen then I can find on general spells usage on how to use the spells instead of calculate all possible spells that can be stolen. And bot can use all the spells that I have coded in Ability Draft Game.
    I tried to do this in ability_item_usage.lua just for Q Location Based Spells on Void and Beastmaster
    Code:
    local PASSIVE = 0
    local SELF_BASED = 1
    local TARGET_BASED = 2
    local LOCATION_BASED = 3
    local TREE_BASED = 4
    
    
    local ListAbilities = {};
    
    function testAbility( botsAbilities )
    	abilityQ = nil;
    abilityW = nil;
    abilityE = nil;
    abilityD = nil;
    abilityF = nil;
    abilityR = nil;
    
    castQDesire = 0;
    castWDesire = 0;
    castEDesire = 0;
    castDDesire = 0;
    castFDesire = 0;
    castRDesire = 0;
    	
    	
    	local npcBot = GetBot();
    	ListAbilities = botsAbilities;
    	
    	-- Check if we're already using an ability
    	if ( npcBot:IsUsingAbility() ) then return end;
    	
        if  abilityQ == nil and
    		abilityW == nil and
    		abilityE == nil and
    		abilityD == nil and
    		abilityF == nil and
    		abilityR == nil 
    	then	
        
    		local index = 0;
    		for _,ability in pairs(botsAbilities) 
    		do
    			if index == 0 then
    				abilityQ = npcBot:GetAbilityByName( ability );
    			end
    			
    			if index == 1 then
    				abilityW = npcBot:GetAbilityByName( ability );
    			end
    			
    			if index == 2 then
    				abilityE = npcBot:GetAbilityByName( ability );
    			end
    			
    			if index == 3 then
    				if ability ~= "-1" then
    					abilityD = npcBot:GetAbilityByName( ability );
    				else
    					abilityD = "-1";
    				end
    			end
    			
    			if index == 4 then
    				if ability ~= "-1" then
    					abilityF = npcBot:GetAbilityByName( ability );
    				else
    					abilityF = "-1";
    				end
    			end
    			
    			if index == 5 then
    				abilityR = npcBot:GetAbilityByName( ability );
    			end
    			
    			index = index + 1;
    		end
    	
    	end
    	
    	ConsiderCastSpells();
    	index = 0;
    	
    end
    
    
    
    function ResetDesire()	
    	 castQDesire = 0;
    	 castWDesire = 0;
    	 castEDesire = 0;
    	 castDDesire = 0;
    	 castFDesire = 0;
    	 castRDesire = 0;
    end
    
    function ConsiderCastSpells()
    	
    	CastQ();
    	
    	ResetDesire();
    	
    end
    
    function CastQ()
    
    	local npcBot = GetBot();
    	if SpellBased.Based[ListAbilities[1]] == PASSIVE then
    		castQDesire = 0;
    	end
    	
    	if SpellBased.Based[ListAbilities[1]] == SELF_BASED then
    		castQDesire = ConsiderSelfBasedQ();
    	end
    	
    	if SpellBased.Based[ListAbilities[1]] == TARGET_BASED then
    		castQDesire, castQEntity = ConsiderTargetBasedQ();
    	end
    	
    	if SpellBased.Based[ListAbilities[1]] == LOCATION_BASED then
    		castQDesire, castQLocation = ConsiderLocationBasedQ();
    	end
    	
    	if SpellBased.Based[ListAbilities[1]] == TREE_BASED then
    		castQDesire, castQTree = ConsiderTreeBasedQ();
    	end
    	
    	if castQDesire > 0 then
    		if SpellBased.Based[ListAbilities[1]] == SELF_BASED then
    			npcBot:Action_UseAbility(abilityQ);
    			return;
    		end
    		
    		if SpellBased.Based[ListAbilities[1]] == TARGET_BASED then
    			npcBot:Action_UseAbilityOnEntity( abilityQ, castQEntity );
    			return;
    		end
    		
    		if SpellBased.Based[ListAbilities[1]] == LOCATION_BASED then
    			npcBot:Action_UseAbilityOnLocation( abilityQ, castQLocation );
    			return;
    		end
    		
    		if SpellBased.Based[ListAbilities[1]] == TREE_BASED then
    			npcBot:Action_UseAbilityOnTree( abilityQ, castQTree );
    			return;
    		end
    	end
    
    end
    
    
    
    function ConsiderLocationBasedQ() 
    	local npcBot = GetBot();
    	if ( not abilityQ:IsFullyCastable() ) 
    	then 
    		return BOT_ACTION_DESIRE_NONE, 0;
    	end;
    	
    	if npcBot:DistanceFromFountain() > 1000 then
    		return BOT_ACTION_DESIRE_LOW, npcBot:GetExtrapolatedLocation(3);
    	end
    		
    	return BOT_ACTION_DESIRE_NONE, 0;
    end
    And call it in ability_item_usage_beastmaster.lua and ability_item_usage_faceless_void.lua like this
    Code:
    function AbilityUsageThink()
    
    	local Abilities = {"beastmaster_wild_axes", 
    				   "beastmaster_call_of_the_wild_hawk", 
    				   "beastmaster_call_of_the_wild_boar",
    				   "beastmaster_inner_beast",
    				   "-1",
    				   "beastmaster_primal_roar"
    				   }
    	ability_item_usage_generic.testAbility(Abilities);
    	
    	
    
    end
    Code:
    function AbilityUsageThink()
    
    	local Abilities = {"faceless_void_time_walk", 
    				   "faceless_void_time_dilation", 
    				   "faceless_void_time_lock",
    				   "-1",
    				   "-1",
    				   "faceless_void_chronosphere"
    				   }
    	ability_item_usage_generic.testAbility(Abilities);
    end
    And it works., but I don't know that the execution time will be fast enough because I need to check the spell behavior here an there.
    Last edited by arz_on4dt; 02-01-2017 at 11:36 AM.

  4. #4
    Basic Member
    Join Date
    Dec 2016
    Posts
    733
    As of January 26th you can do this:

    ability:GetTargetType()

    and the result will be one of these global constants:
    Code:
    Added ability target type constants:
    ABILITY_TARGET_TYPE_NONE
    ABILITY_TARGET_TYPE_HERO
    ABILITY_TARGET_TYPE_CREEP
    ABILITY_TARGET_TYPE_BUILDING
    ABILITY_TARGET_TYPE_COURIER
    ABILITY_TARGET_TYPE_OTHER (wards, etc)
    ABILITY_TARGET_TYPE_TREE
    ABILITY_TARGET_TYPE_BASIC (creep or courier)
    ABILITY_TARGET_TYPE_ALL (but not trees)
    Also:
    ability:GetTargetTeam() (to know if offensive or defensive - think Treant Heal)
    Code:
    Added ability target team constants:
    ABILITY_TARGET_TEAM_NONE
    ABILITY_TARGET_TEAM_FRIENDLY
    ABILITY_TARGET_TEAM_ENEMY

  5. #5
    Basic Member
    Join Date
    May 2014
    Posts
    270
    @nostrademouse
    Yes, I knew that, but first I want to differentiate them based on 4 Action_UseAbility...() functions. I'll use GetTargetFlags( ), GetTargetType(), GetTargetTeam(), to decide the target and location in ConsiderCast() function. I have to differentiate it too to whether or not that ability can be used to escape, damaging the enemy, offensive, defensive, have travel projectile or instant damaging enemy, etc. It's a lot of condition to go through.

    Is it better to use only if statement or if else if statement? I tried to use if elseif statement but I never made it through.
    Code:
    if condition then 
       statement
    elseif condition then
       statement
    elseif condition then
       statement
    end
    Is that the correct if elseif statement for lua? ( I started to learn lua since 7.00 update ). I'm a bit confusing about ability target flag. What is it actually?

  6. #6
    Basic Member
    Join Date
    Dec 2016
    Posts
    46
    Quote Originally Posted by arz_on4dt View Post
    @nostrademouse
    Is it better to use only if statement or if else if statement? I tried to use if elseif statement but I never made it through.
    Code:
    if condition then 
       statement
    elseif condition then
       statement
    elseif condition then
       statement
    end
    Is that the correct if elseif statement for lua? ( I started to learn lua since 7.00 update ). I'm a bit confusing about ability target flag. What is it actually?
    Yes,the code is right.

    Today's update allow us to use GetAbilityInSlot() function.

  7. #7
    Basic Member
    Join Date
    Dec 2016
    Posts
    733
    This new API functions will be amazing for Ability Draft Bot matches.

Posting Permissions

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