Page 3 of 9 FirstFirst 1 2 3 4 5 ... LastLast
Results 21 to 30 of 89

Thread: Newbie has problems.

  1. #21
    Basic Member
    Join Date
    Oct 2016
    Posts
    247
    Basic Pugna script:

    Code:
    require(GetScriptDirectory() ..  "/ability_item_usage_generic")
    local utils = require(GetScriptDirectory() ..  "/util")
    local inspect = require(GetScriptDirectory() ..  "/inspect")
    local enemyStatus = require(GetScriptDirectory() .. "/enemy_status" )
    
    function AbilityLevelUpThink()  
    	ability_item_usage_generic.AbilityLevelUpThink(); 
    end
    
    
    ----------------------------------------------------------------------------------------------------------------------------------
    
    castLDDesire = 0;
    castNWDesire = 0;
    castNBDesire = 0;
    castDDesire = 0;
    
    function AbilityUsageThink()
    
    	local npcBot = GetBot();
    
    
    		if npcBot:IsChanneling() then
    		return;
    	end
    
    	-- Check if we're already using an ability
    	if ( npcBot:IsUsingAbility() ) then return end;
    
    
    abilityNB = npcBot:GetAbilityByName( "pugna_nether_blast" );
    
    abilityD = npcBot:GetAbilityByName( "pugna_decrepify" );
    
    abilityNW = npcBot:GetAbilityByName( "pugna_nether_ward" );
    
    abilityLD = npcBot:GetAbilityByName( "pugna_life_drain" );
    
    	-- Consider using each ability
    	castNBDesire, castNBLocation = ConsiderNetherBlast();
    	castDDesire, castDTarget = ConsiderDecrepify();   
    	castNWDesire, castNWLocation = ConsiderNetherWard();
    	castLDDesire, castLDTarget = ConsiderLifeDrain();    
    
    	if ( castLDDesire > castNWDesire and castLDDesire > castNBDesire and castLDDesire > castDDesire ) 
    	then
    		npcBot:Action_UseAbilityOnEntity( abilityLD, castLDTarget );
    		return;
    	end
    
    	if ( castNBDesire > 0 ) 
    	then
    		npcBot:Action_UseAbilityOnLocation( abilityNB, castNBLocation );
    		return;
    	end
    	
    	
    	if ( castNWDesire > 0 ) 
    	then
    		npcBot:Action_UseAbilityOnLocation( abilityNW, castNWLocation);
    		return;
    	end
    
    
    		if ( castDDesire > 0 ) 
    	then
    		npcBot:Action_UseAbilityOnEntity( abilityD, castDTarget);
    		return;
    	end
    
    
    	
    end
    
    ----------------------------------------------------------------------------------------------------------------------------------
    
    function CanCastNetherBlastOnTarget( npcTarget )
    	return npcTarget:CanBeSeen() and not npcTarget:IsMagicImmune() and not npcTarget:IsInvulnerable();
    end
    
    
    function CanCastDecrepifyOnTarget( npcTarget )
    	return npcTarget:CanBeSeen() and not npcTarget:IsMagicImmune() and not npcTarget:IsInvulnerable();
    end
    
    
    function CanCastLifeDrainOnTarget( npcTarget )
    	return npcTarget:CanBeSeen() and npcTarget:IsHero() and ( GetBot():HasScepter() or not npcTarget:IsMagicImmune() ) and not npcTarget:IsInvulnerable();
    end
    
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    
    
    
    
    
    
    
    
    
    
    function ConsiderNetherBlast()
    
    	local npcBot = GetBot();
    
    	-- Make sure it's castable
    	if ( not abilityNB:IsFullyCastable() ) 
    	then 
    		return BOT_ACTION_DESIRE_NONE, 0;
    	end;
    
    	-- If we want to cast Poison Nova at all, bail
    	if ( castLDDesire > 0 ) 
    	then
    		return BOT_ACTION_DESIRE_NONE, 0;
    	end
    	
    	-- Get some of its values
    	local nCastRange = abilityNB:GetCastRange();
    	local nRadius = 400;
    
    
    -----	---------------------------------------------
    	-- Mode based usage
    --------------------------------------------------
    
    ------------ LANING ------------- 
    
    	if ( npcBot:GetActiveMode() == BOT_MODE_LANING and 
    		npcBot:GetMana()/npcBot:GetMaxMana() >= 0.3  ) 
    		then
    			local tableNearbyEnemyCreeps = npcBot:GetNearbyCreeps( 1000, true);
    			local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( 1000, true, BOT_MODE_NONE);
    			if ((tableNearbyEnemyHeroes[1] ~= nil) and (tableNearbyEnemyCreeps[1] ~= nil)) then
    				return BOT_ACTION_DESIRE_LOW, tableNearbyEnemyHeroes[1]:GetLocation();
    		end
    	end
    
    ---------- FARMING ------------------------------- 
    
    	if ( npcBot:GetActiveMode() == BOT_MODE_FARM and 
    		npcBot:GetMana()/npcBot:GetMaxMana() >= 0.7  ) then
    
    		local tableNearbyEnemyCreeps = npcBot:GetNearbyCreeps( 1000, true);
    		if(tableNearbyEnemyCreeps[1] ~= nil) then
    			return BOT_ACTION_DESIRE_LOW, tableNearbyEnemyCreeps[1]:GetLocation();
    		end
    	end
    
    ----------- PUSH TOWER ----------------------- 
    
    	if ( npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_TOP or
    		 npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_MID or
    		 npcBot:GetActiveMode() == BOT_MODE_PUSH_TOWER_BOT ) 
    	then
    		local tableNearbyTowers = npcBot:GetNearbyTowers( 1000, true);
    			if(tableNearbyTowers[1] ~= nil and not tableNearbyTowers[1]:IsInvulnerable( )) then
    				return BOT_ACTION_DESIRE_LOW, tableNearbyTowers[1]:GetLocation();
    
    		end
    	end
    
    
    
    ----------- DEFEND TOWER - from heroes ----------------------- 
    
    	if ( 	 npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or
    		 npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or
    		 npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) 
    	then
    		local tableNearbyHeroes = npcBot:GetNearbyHeroes( 800, true, BOT_MODE_NONE );
    			if(tableNearbyHeroes[1] ~= nil ) then
    				return BOT_ACTION_DESIRE_MODERATE, tableNearbyHeroes[1]:GetLocation();
    
    		end
    	end
    ----------- DEFEND TOWER - from creeps ----------------------- 
    
    if ( 	 npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or
    		 npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or
    		 npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) 
    	then
    		local tableNearbyCreeps = npcBot:GetNearbyCreeps( 800, true );
    			if(tableNearbyCreeps[1] ~= nil ) then
    				return BOT_ACTION_DESIRE_MODERATE, tableNearbyCreeps[1]:GetLocation();
    
    		end
    	end
    
    ---------- RETREATING ----------------------- 
    
    if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) 
    	then
    		local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( nCastRange + 200, true, BOT_MODE_NONE );
    		for _,npcEnemy in pairs( tableNearbyEnemyHeroes )
    		do
    			if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) 
    			then
    				if ( CanCastNetherBlastOnTarget( npcEnemy ) ) 
    				then
    					return BOT_ACTION_DESIRE_MODERATE, npcEnemy:GetLocation();
    				end
    			end
    		end
    	end
    
    ---------- CHASING ------------------------------ 
    
    	if ( npcBot:GetActiveMode() == BOT_MODE_ATTACK or
    	     npcBot:GetActiveMode() == BOT_MODE_ROAM or
    		 npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or
    		 npcBot:GetActiveMode() == BOT_MODE_GANK or
    		 npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY ) 
    	then
    		local npcTarget = npcBot:GetTarget();
    
    		if ( npcTarget ~= nil and GetUnitToUnitDistance(npcTarget, npcBot) < nCastRange  ) 
    		then
    			return BOT_ACTION_DESIRE_HIGH, npcTarget:GetLocation();
    		end
    	end
    
    	return BOT_ACTION_DESIRE_NONE, 0;
    end
    
    
    
    
    
    
    
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    
    
    function ConsiderNetherWard()
    
    	local npcBot = GetBot();
    
    	-- Make sure it's castable
    	if ( not abilityNW:IsFullyCastable() ) 
    	then 
    		return BOT_ACTION_DESIRE_NONE, 0;
    	end;
    
    	--If we want to cast Poison Nova at all, bail
    	if ( castLDDesire > 0 ) 
    	then
    		return BOT_ACTION_DESIRE_NONE, 0;
    	end
    	
    	-- Get some of its values
    	local nCastRange = abilityNW:GetCastRange();
    	local nRadius = 150;
    
    
    -----	---------------------------------------------
    	-- Mode based usage
    --------------------------------------------------
    
    
    
    ------------ LANING ------------- 
    
    	if ( npcBot:GetActiveMode() == BOT_MODE_LANING and 
    			npcBot:GetMana()/npcBot:GetMaxMana() >= 0.8  ) 
    		then
    		local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( 500, true, BOT_MODE_NONE);
    			if(tableNearbyEnemyHeroes[1] ~= nil) then
    			local tableNearbyTrees = npcBot:GetNearbyTrees( 400);
    		if(tableNearbyTrees[1] ~= nil) then
    		return BOT_ACTION_DESIRE_LOW, GetTreeLocation(tableNearbyTrees[1]);
    			end
    		end
    	end
    
    
    
    
    ----------- DEFEND TOWER - from heroes ----------------------- 
    
    	if ( 	 npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or
    		 npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or
    		 npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) 
    	then
    		local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( 1000, true, BOT_MODE_NONE);
    			if(tableNearbyEnemyHeroes[1] ~= nil) then
    			local tableNearbyTrees = npcBot:GetNearbyTrees( 400);
    		if(tableNearbyTrees[1] ~= nil) then
    		return BOT_ACTION_DESIRE_LOW, GetTreeLocation(tableNearbyTrees[1]);
    			end
    		end
    	end
    
    
    ---------- RETREATING -----------------------  
    
    if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) 
    	then
    		local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( nCastRange + 200, true, BOT_MODE_NONE );
    		for _,npcEnemy in pairs( tableNearbyEnemyHeroes )
    		do
    			if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) 
    			then
    				if ( CanCastNetherBlastOnTarget( npcEnemy ) ) 
    				then
    					return BOT_ACTION_DESIRE_MODERATE, npcEnemy:GetLocation();
    				end
    			end
    		end
    	end
    
    
    
    
    
    
    
    ------------- TEAM FIGHT -------------------------------------
    
    
    	local tableNearbyAttackingAlliedHeroes = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK );
    	if ( #tableNearbyAttackingAlliedHeroes >= 2 ) 
    	then
    	local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( 1000, true, BOT_MODE_NONE);
    	
    		if ((tableNearbyEnemyHeroes[1] ~= nil)) then
    		local tableNearbyTrees = npcBot:GetNearbyTrees( 400);
    			if(tableNearbyTrees[1] ~= nil) then
    			return BOT_ACTION_DESIRE_LOW, GetTreeLocation(tableNearbyTrees[1]);
    			end
    		end
    	end
    
    
    
    
    
    
    
    
    	return BOT_ACTION_DESIRE_NONE, 0;
    
    end
    
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    function ConsiderDecrepify()
    
    	local npcBot = GetBot();
    
    	-- Make sure it's castable
    	if ( not abilityD:IsFullyCastable() ) then 
    		return BOT_ACTION_DESIRE_NONE, 0;
    	end
    
    	-- Get some of its values
    	local nCastRange = abilityD:GetCastRange();
    	local nDamage = abilityNB:GetSpecialValueInt( "damage" );
    	local eDamageType = npcBot:HasScepter() and DAMAGE_TYPE_PURE or DAMAGE_TYPE_MAGICAL;
    
    
    
    
    ---------- Decrepify before enemy cast test -----------------
    
    
    
    	local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( 1000, true, BOT_MODE_NONE );
    	for _,npcTarget in pairs( tableNearbyEnemyHeroes )
    	do
    		if ( npcTarget:IsUsingAbility() and CanDecrepifyOnTarget( npcTarget ) and not enemyDisabled( npcTarget ) ) 
    		then
    			return BOT_ACTION_DESIRE_MODERATE, npcTarget;
    		end
    	end
    
    
    
    
    ----------- If a mode has set a target, do it------------
    
    	local npcTarget = npcBot:GetTarget();
    	if ( npcTarget ~= nil and CanCastDecrepifyOnTarget( npcTarget ) )
    	then
    		if ( GetUnitToUnitDistance( npcTarget, npcBot ) < ( nCastRange + 200 ) )
    		then
    			return BOT_ACTION_DESIRE_HIGH, npcTarget;
    		end
    	end
    
    -------- If we're in a teamfight, use it on the scariest enemy---------
    
    	local tableNearbyAttackingAlliedHeroes = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK );
    	if ( #tableNearbyAttackingAlliedHeroes >= 2 ) 
    	then
    
    		local npcMostDangerousEnemy = nil;
    		local nMostDangerousDamage = 0;
    
    		local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( nCastRange, true, BOT_MODE_NONE );
    		for _,npcEnemy in pairs( tableNearbyEnemyHeroes )
    		do
    			if ( CanCastDecrepifyOnTarget( npcEnemy ) )
    			then
    				local nDamage = npcEnemy:GetEstimatedDamageToTarget( false, npcBot, 3.0, DAMAGE_TYPE_ALL );
    				if ( nDamage > nMostDangerousDamage )
    				then
    					nMostDangerousDamage = nDamage;
    					npcMostDangerousEnemy = npcEnemy;
    				end
    			end
    		end
    
    		if ( npcMostDangerousEnemy ~= nil )
    		then
    			return BOT_ACTION_DESIRE_HIGH, npcMostDangerousEnemy;
    		end
    	end
    
    
    	
    
    ---------- RETREATING -----------------------  
    
    if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) 
    	then
    		local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( nCastRange + 200, true, BOT_MODE_NONE );
    		for _,npcEnemy in pairs( tableNearbyEnemyHeroes )
    		do
    			if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) 
    			then
    				if ( CanCastNetherBlastOnTarget( npcEnemy ) ) 
    				then
    					return BOT_ACTION_DESIRE_HIGH, npcTarget; 
    				end
    			end
    		end
    	end
    
    
    
    
    
    ----------- DEFEND TOWER - from heroes ----------------------- 
    
    	if ( 	 npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or
    		 npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or
    		 npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) 
    	then
    		local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( 1000, true, BOT_MODE_NONE);
    			if(tableNearbyEnemyHeroes[1] ~= nil) then
    			return BOT_ACTION_DESIRE_LOW, npcTarget; 
    			end
    		end
    	
    
    
    	return BOT_ACTION_DESIRE_NONE, 0;
    
    end
    
    
    
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    
    
    
    function ConsiderLifeDrain()
    
    	local npcBot = GetBot();
    
    	-- Make sure it's castable
    	if ( not abilityLD:IsFullyCastable() ) then 
    		return BOT_ACTION_DESIRE_NONE, 0;
    	end
    
    	-- Get some of its values
    	local nCastRange = abilityLD:GetCastRange();
    	--local nDamage = abilityNB:GetSpecialValueInt( "damage" );
    	--local eDamageType = npcBot:HasScepter() and DAMAGE_TYPE_PURE or DAMAGE_TYPE_MAGICAL;
    
    	local npcTarget = npcBot:GetTarget();
    
    
    ------------ LANING -------------  
    
    	if ( npcBot:GetActiveMode() == BOT_MODE_LANING and 
    		npcBot:GetMana()/npcBot:GetMaxMana() >= 0.8  ) 
    		then
    
    	local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( 1000, true, BOT_MODE_NONE);
    		if ((tableNearbyEnemyHeroes[1] ~= nil) and ( GetUnitToUnitDistance( npcTarget, npcBot ) <  nCastRange ))
    			then
    			return BOT_ACTION_DESIRE_LOW, npcTarget;
    			end
    		end
    	
    
    ----------- DEFEND TOWER - from heroes ----------------------- 
    
    	if ( 	 npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_TOP or
    		 npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_MID or
    		 npcBot:GetActiveMode() == BOT_MODE_DEFEND_TOWER_BOT ) 
    	then
    		local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( 1200, true, BOT_MODE_NONE);
    			if ((tableNearbyEnemyHeroes[1] ~= nil) and ( GetUnitToUnitDistance( npcTarget, npcBot ) <  nCastRange )) then
    
    			return BOT_ACTION_DESIRE_LOW, npcTarget; 
    			end
    		
    	end
    
    
    
    ---------- CHASING ------------------------------ 
    
    	if ( npcBot:GetActiveMode() == BOT_MODE_ATTACK or
    	     npcBot:GetActiveMode() == BOT_MODE_ROAM or
    		 npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or
    		 npcBot:GetActiveMode() == BOT_MODE_GANK or
    		 npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY ) 
    	then
    		local npcTarget = npcBot:GetTarget();
    
    		if ( npcTarget ~= nil and GetUnitToUnitDistance(npcTarget, npcBot) < nCastRange -600 ) 
    		then
    			return BOT_ACTION_DESIRE_HIGH, npcTarget;
    		end
    	end
    
    
    
    
    	-- If a mode has set a target, and we can kill them, do it
    
    	if ( npcTarget ~= nil and CanCastLifeDrainOnTarget( npcTarget ) )
    	then
    		if ( GetUnitToUnitDistance( npcTarget, npcBot ) < ( nCastRange ) )
    		then
    			return BOT_ACTION_DESIRE_HIGH, npcTarget;
    		end
    	end
    
    	-- If we're in a teamfight, use it on the scariest enemy
    	local tableNearbyAttackingAlliedHeroes = npcBot:GetNearbyHeroes( 1000, false, BOT_MODE_ATTACK );
    	if ( #tableNearbyAttackingAlliedHeroes >= 2 ) 
    	then
    
    		local npcMostDangerousEnemy = nil;
    		local nMostDangerousDamage = 0;
    
    		local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( nCastRange, true, BOT_MODE_NONE );
    		for _,npcEnemy in pairs( tableNearbyEnemyHeroes )
    		do
    			if ( CanCastLifeDrainOnTarget( npcEnemy ) )
    			then
    				local nDamage = npcEnemy:GetEstimatedDamageToTarget( false, npcBot, 3.0, DAMAGE_TYPE_ALL );
    				if ( nDamage > nMostDangerousDamage )
    				then
    					nMostDangerousDamage = nDamage;
    					npcMostDangerousEnemy = npcEnemy;
    				end
    			end
    		end
    
    		if ( npcMostDangerousEnemy ~= nil )
    		then
    			return BOT_ACTION_DESIRE_HIGH, npcMostDangerousEnemy;
    		end
    	end
    
    	return BOT_ACTION_DESIRE_NONE, 0;
    
    end
    Please review before use, gives no errors and i think all works, but hard to tell watching him.
    Last edited by Yavimaya; 02-08-2017 at 06:34 AM. Reason: Found error in LifeDrain, should all be fixed.

  2. #22
    Basic Member
    Join Date
    Oct 2016
    Posts
    247
    Any chance anyone knows what to put into the skill builds to have troll warlord put skills onto whirling axe?
    ive tried all options i can find - whirling_axes_ranged, whirling_axes_melee, whirling_axes.
    none seem to work.

  3. #23
    Basic Member
    Join Date
    Dec 2016
    Posts
    731
    Quote Originally Posted by Yavimaya View Post
    Any chance anyone knows what to put into the skill builds to have troll warlord put skills onto whirling axe?
    ive tried all options i can find - whirling_axes_ranged, whirling_axes_melee, whirling_axes.
    none seem to work.
    npc/npc_heroes.txt is your friend (2 directors higher than your bots/)

    On cell phone, otherwise I would just answer.

    EDIT: Answer is you use:
    "troll_warlord_whirling_axes_ranged" OR "troll_warlord_whirling_axes_melee" depending on which one is currently visible versus hidden. Use ability-scoped IsHidden() to check.

    If that doesn't work I don't know what to tell you... I guess you could try "GetAbilityInSlot( 2 )" and level that up.
    Last edited by nostrademous; 02-08-2017 at 06:06 AM.

  4. #24
    Basic Member
    Join Date
    Oct 2016
    Posts
    247
    Thanks, i ran a test where he finally leveled his ranged skill.
    i already had the skill names.
    ill have a look at adding that to the skill upgrade script somewhere, sucks it has to be added just for that one hero to work since all heroes use it and the one im using is so wide spread - if someone else uses the troll i add, they will need to use my version of the skill upgrade script too.
    Last edited by Yavimaya; 02-08-2017 at 06:32 AM.

  5. #25
    there is a similar issue with upgrading timber's ult while the bot is using it.

  6. #26
    Basic Member
    Join Date
    Oct 2016
    Posts
    247
    did you overcome it in the fashion that Nost suggested?

  7. #27
    Basic Member
    Join Date
    Oct 2016
    Posts
    247
    Code:
    function ConsiderBeserkRage()
    
    	local npcBot = GetBot();
    
    	-- Make sure it's castable
    	if ( not abilityBR:IsFullyCastable() ) 
    	then 
    		return BOT_ACTION_DESIRE_NONE, 0;
    	end;
    
    
    
    --------- toggle to melee if enemy too close ----------------------
    local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( 600, true, BOT_MODE_NONE);
    
    if GetUnitToUnitDistance( tableNearbyEnemyHeroes[1], npcBot ) < 175  and  abilityBR:GetToggleState() == false then
    
    	return BOT_ACTION_DESIRE_LOW, 0;
    	end
    
    
    
    ---------- toggle ranged / stay ranged ----------------------
    local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( 600, true, BOT_MODE_NONE);
    
    if ( tableNearbyEnemyHeroes[1] == nil) and ( abilityBR:GetToggleState() == false ) then
    	return BOT_ACTION_DESIRE_NONE, 0;
    	else
    	if GetUnitToUnitDistance( tableNearbyEnemyHeroes[1], npcBot ) > 175 and  abilityBR:GetToggleState() == true then
    	return BOT_ACTION_DESIRE_LOW, 0;
    	end
    end
    as far as i read it, top one should be if units are closer than 175 and beserk is not toggled (making him ranged) then toggle
    2nd one - if no enemy heroes and toggle is ranged, then do nothing... else if units are further than 175 and beserk is toggled (melee) than toggle to ranged.

    but somehow i have broken it, i had it all working nicely at one point until i added the nil check for heroes, things have gone backwards from there.

    am i reading the script wrong? have i totally stuffed up a check / call again?

    i have tried it as "and ( not abilityBR:GetToggleState()) then" etc as well.
    Last edited by Yavimaya; 02-08-2017 at 07:01 PM.

  8. #28
    Basic Member
    Join Date
    Dec 2016
    Posts
    731
    You need a check like this "if #tableNearbyEnemyHeroes > 0 then" after the GetNearby before you ever check any index of the table.

    GetNearby*() can return a blank table if no enemies around. In those cases [1] won't work and will break code.
    Last edited by nostrademous; 02-08-2017 at 08:07 PM.

  9. #29
    Basic Member
    Join Date
    Oct 2016
    Posts
    247
    ok thanks, thats a shame it cant all be wrapped up and called by another function without other checks.

    im still confused though TBH, because its simply a slight change on:

    local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( 1000, true, BOT_MODE_NONE);
    if(tableNearbyEnemyHeroes[1] ~= nil) then
    return BOT_ACTION_DESIRE_LOW, npcTarget;
    end
    which seems to work fine in every other situation.

    let me stick the check into the first part to see if its nil, that might fix it.

    its odd, he does use his stuff, but its kind of reversed, yet i reverse the > in the script and it doesnt fix it.
    Last edited by Yavimaya; 02-08-2017 at 08:31 PM.

  10. #30
    Quote Originally Posted by Yavimaya View Post
    did you overcome it in the fashion that Nost suggested?
    No, my solution was more stupid! It was long time ago and I didn't know this function call exists. It is also not likely to happen (leveling up while using it), so I made timber to prioritize leveling up his ult whenever he can (so if he skilled something else he is probably going to get it next level!).

Posting Permissions

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