Results 1 to 4 of 4

Thread: How to use ToggleAutoCast( )?

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

    How to use ToggleAutoCast( )?

    It's an ability scope function so I assume is abilityQ:ToggleAutoCast( )?

    Since IsUsingAbility() not apply to this one, how do you prevent this be called too often?

  2. #2
    Basic Member
    Join Date
    Mar 2012
    Posts
    2,022
    Warning!! ERRROR!!! Alert !! Not tested !!!

    Code:
    function ConsiderTogglingAbility (Ability, bToggleValue)
    	local bShouldToggle;
    
    	if (bToggleValue == true) the
    		-- if I should toggle it on, f.e. RoB after the laning phase ended
    		bShouldToggle = true;
    	elseif (bToggleValue == false) the
    		-- f.e. RoB should be disabled during laning phases to nto push the lane
    		-- but you can have some logic to turn it on/off f.e. when dominating neutrals
    		-- or whateber even in the laning phase or if you want to push just a little
    		-- so you can do a double\triple pull on the lane for extra xp
    		
    		-- since local logic is here, the return value should not always be equal 
    		-- to the bToggleValue value; there may be some exceptions as stated earlier
    		bShouldToggle = false; 
    	end
    
    	return bShouldToggle;
    end
    
    local toggleSpell = RoB -- "spell" means "ability or item", but we'll use RoB for this example
    	-- for abilities you can use GetAbilityByName() and for items you can use GetItemInSlot()
    	-- i'll use the dummy value RoB which you'd most likely get over a function that iterates
    	-- each slot in the backpack and check if item:GetName() = "item_ring_of_basilius" whose
    	-- handle you get with GetItemInSlot() please be careful to check that it's in the inventory
    	-- and not the backpack or stash !!!! you use GetItemSlotType() for that
    
    function TestThink ()
    	-- here we check if the RoB is on and if we need it off - our example is that we're in the laning phase and we don't want to push the lane
    	if (toggleSpell:IsToggle() == true) then								-- best practice: check if you can toggle; you can also hardcode RoB as a toggleable item in a
    																			-- table, I guess so you won't need this check and it will look simpler but I'm not a fan
    		
    		if (((toggleSpell:GetToggleState() == true)							-- ok so our RoB is active - that means it can f.e. push the lane
    		and (ConsiderTogglingAbility(toggleSpell, false) == true))			-- and we want to disable it
    		or ((toggleSpell:GetToggleState() == false)
    		and (ConsiderTogglingAbility(toggleSpell, true) == true))) then		-- and vice-versa
    			ownerBot:ActionPush_UseAbility(toggleSpell);
    		end
    	end
    
    	-- careful since there is a lot of room for throttling there so you need to be careful in your ConsiderTogglingAbility() logic
    end
    As I said, it is not tested and the design might need some more work, this was just something from the top of my head, no real code yet as I am at the item purchase development stage now
    This is just a starting point to get you ... well, started.

    Feel free to use it as much or little as you want. And do let me know if you get it working as expected
    Throttling is the danger there since you can end up toggling it on/off non-stop. And remember to check that the item is in the inventory, not in other slots !!!

    Good luck!
    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
    123
    Quote Originally Posted by The Nomad View Post
    Warning!! ERRROR!!! Alert !! Not tested !!!

    Code:
    function ConsiderTogglingAbility (Ability, bToggleValue)
    	local bShouldToggle;
    
    	if (bToggleValue == true) the
    		-- if I should toggle it on, f.e. RoB after the laning phase ended
    		bShouldToggle = true;
    	elseif (bToggleValue == false) the
    		-- f.e. RoB should be disabled during laning phases to nto push the lane
    		-- but you can have some logic to turn it on/off f.e. when dominating neutrals
    		-- or whateber even in the laning phase or if you want to push just a little
    		-- so you can do a double\triple pull on the lane for extra xp
    		
    		-- since local logic is here, the return value should not always be equal 
    		-- to the bToggleValue value; there may be some exceptions as stated earlier
    		bShouldToggle = false; 
    	end
    
    	return bShouldToggle;
    end
    
    local toggleSpell = RoB -- "spell" means "ability or item", but we'll use RoB for this example
    	-- for abilities you can use GetAbilityByName() and for items you can use GetItemInSlot()
    	-- i'll use the dummy value RoB which you'd most likely get over a function that iterates
    	-- each slot in the backpack and check if item:GetName() = "item_ring_of_basilius" whose
    	-- handle you get with GetItemInSlot() please be careful to check that it's in the inventory
    	-- and not the backpack or stash !!!! you use GetItemSlotType() for that
    
    function TestThink ()
    	-- here we check if the RoB is on and if we need it off - our example is that we're in the laning phase and we don't want to push the lane
    	if (toggleSpell:IsToggle() == true) then								-- best practice: check if you can toggle; you can also hardcode RoB as a toggleable item in a
    																			-- table, I guess so you won't need this check and it will look simpler but I'm not a fan
    		
    		if (((toggleSpell:GetToggleState() == true)							-- ok so our RoB is active - that means it can f.e. push the lane
    		and (ConsiderTogglingAbility(toggleSpell, false) == true))			-- and we want to disable it
    		or ((toggleSpell:GetToggleState() == false)
    		and (ConsiderTogglingAbility(toggleSpell, true) == true))) then		-- and vice-versa
    			ownerBot:ActionPush_UseAbility(toggleSpell);
    		end
    	end
    
    	-- careful since there is a lot of room for throttling there so you need to be careful in your ConsiderTogglingAbility() logic
    end
    As I said, it is not tested and the design might need some more work, this was just something from the top of my head, no real code yet as I am at the item purchase development stage now
    This is just a starting point to get you ... well, started.

    Feel free to use it as much or little as you want. And do let me know if you get it working as expected
    Throttling is the danger there since you can end up toggling it on/off non-stop. And remember to check that the item is in the inventory, not in other slots !!!

    Good luck!
    I already have fuction like what you metioned as ConsiderTogglingAbility, it's based on my armlet code which worked very well. What I'm asking here is the function ToggleAutoCast( ) itself. Should I use it like abilityQ:ToggleAutoCast( ) or npcBot:ToggleAutoCast(abilityQ ) something like that

  4. #4
    Basic Member
    Join Date
    Mar 2012
    Posts
    2,022
    oops, misread. It's abilityQ:ToggleAutoCast()
    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
  •