Page 2 of 9 FirstFirst 1 2 3 4 ... LastLast
Results 11 to 20 of 89

Thread: Newbie has problems.

  1. #11
    Basic Member
    Join Date
    Oct 2016
    Posts
    247
    Thanks Nomad, you murdered my brain, but i will read over this until i understand it.

    ive had a little c++ style experience before (done scripting that was based on c++, not actually done c++) so i kind of get some, some goes way over my head.
    one of the things that gets me is the fact names change everywhere, once you said "classes" i could understand a tiny bit more.
    but then for me, in maths a teacher would talk me through a problem, change the numbers for me to do it and i would be back to square one and i find programming the same, i can read the script, i can mostly understand what it wants to do, but when i write it, even copying someone elses..... its like being back at square one.
    Last edited by Yavimaya; 02-05-2017 at 05:37 PM.

  2. #12
    Basic Member
    Join Date
    Dec 2016
    Posts
    731
    Quote Originally Posted by Yavimaya View Post
    sorry back with another problem i dont understand already.
    im trying to change laguna blade to get decrepify working (and probably life drain since i cant access death prophets scripts and no one else has channeling out of the new guys), howver i remove this section:

    npcTarget:GetActualIncomingDamage( nDamage, eDamageType ) < npcTarget:GetHealth() and

    from:

    Code:
    	-- If a mode has set a target, and we can kill them, do it
    	local npcTarget = npcBot:GetTarget();
    	if ( npcTarget ~= nil and CanCastDecrepifyOnTarget( npcTarget ) )
    	then
    		if ( npcTarget:GetActualIncomingDamage( nDamage, eDamageType ) < npcTarget:GetHealth() and UnitToUnitDistance( npcTarget, npcBot ) < ( nCastRange + 200 ) )   -- i changed actualdamage to incoming.
    		then
    			return BOT_ACTION_DESIRE_HIGH, npcTarget;
    		end
    	end
    so it becomes:

    Code:
    	-- If a mode has set a target, and we can kill them, do it
    	local npcTarget = npcBot:GetTarget();
    	if ( npcTarget ~= nil and CanCastDecrepifyOnTarget( npcTarget ) )
    	then
    		if ( UnitToUnitDistance( npcTarget, npcBot ) < ( nCastRange + 200 ) )
    		then
    			return BOT_ACTION_DESIRE_HIGH, npcTarget;
    		end
    	end
    i get

    as the error.

    what i dont get is why does unittounitdistance work just fine for lina / valve, but when i try to use the exact same script it doesnt work?
    i have literally got everything the same, but changed the names out and get the call global error.
    Shouldn't work for Lina since it is GetUnitToUnitDistance(). Only way it works for Lina is if author created his own wrapper function named that. Chances are it doesn't work for Lina and you don't see the error thrown because in Lina's case the first condition fails so the second doesn't get evaluated so the code simply never gets that far. Lua has short-circuiting of logic. That means for statements like "if A and B then" "B" only gets evaluated if "A" is true.
    Last edited by nostrademous; 02-05-2017 at 05:39 PM.

  3. #13
    Basic Member
    Join Date
    Oct 2016
    Posts
    247
    edit:
    ok i see now, they have changed it in the wiki since they released the example scripts obviously and the example script i used is now broken too.
    i never tested it as i thought a script valve released would just work.


    ok working now, Thanks Nost, sorry again for my idiocy guys.
    Last edited by Yavimaya; 02-05-2017 at 05:52 PM.

  4. #14
    Basic Member
    Join Date
    Mar 2012
    Posts
    2,017
    Quote Originally Posted by Yavimaya View Post
    what i dont get is why does unittounitdistance work just fine for lina / valve, but when i try to use the exact same script it doesnt work?
    i have literally got everything the same, but changed the names out and get the call global error.

    Well prolly cos it should be GetUnitToUnitDistance

    EDIT: I see nostrademous beat me to it.
    Last edited by The Nomad; 02-05-2017 at 05:53 PM.
    Explanations on the normal, high and very high brackets in replays: here, here & here
    Why maphacks won't work in D2: here

  5. #15

  6. #16
    Basic Member
    Join Date
    Oct 2016
    Posts
    247
    thank you, i find reading code and testing how it works is the quickest way i learn.

    or more like, the quickest way i can steal code and use it.

  7. #17
    Basic Member
    Join Date
    Dec 2016
    Posts
    731
    Quote Originally Posted by Yavimaya View Post
    thank you, i find reading code and testing how it works is the quickest way i learn.

    or more like, the quickest way i can steal code and use it.
    I gladly welcome contributors to the above code base. It is a joint learning process. Just realize I am doing a complete bot over-write.

  8. #18
    Basic Member
    Join Date
    Oct 2016
    Posts
    247
    i wouldnt even presume to add anything to anything anyone here is doing as it would have to be reviewed and reworked heavily.

    i do want to add in bots though and am not going to take credit for any of it since it is all stolen anyway.
    if people dont hate me, i might one day when all bots are in, upload my combination of scripts (draft bots +exp bots + some from shutnik / pack custom +my few) to the workshop so others can have all the bots in captains mode, then others can improve them from there.

  9. #19
    Basic Member
    Join Date
    Dec 2016
    Posts
    731
    Quote Originally Posted by Yavimaya View Post
    i wouldnt even presume to add anything to anything anyone here is doing as it would have to be reviewed and reworked heavily.

    i do want to add in bots though and am not going to take credit for any of it since it is all stolen anyway.
    if people dont hate me, i might one day when all bots are in, upload my combination of scripts (draft bots +exp bots + some from shutnik / pack custom +my few) to the workshop so others can have all the bots in captains mode, then others can improve them from there.
    In a way that's perfect. A lot of my time is consumed by fixing bot framework due to patches and to complete overall team based bot behavior. I can definitely use help with implementing specific bots.

  10. #20
    Basic Member
    Join Date
    Oct 2016
    Posts
    247
    ok well any bot i make anyone can use without asking permission.
    ill post my veno script if you want a better working version than i had posted.
    Arz has also worked veno after i posted it, but my version seemed better than his latest. i guess check his from the 570 folder and mine and add which ever.


    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
    
    
    ----------------------------------------------------------------------------------------------------------------------------------
    
    castPNDesire = 0;
    castPWDesire = 0;
    castVGDesire = 0;
    
    function AbilityUsageThink()
    
    	local npcBot = GetBot();
    
    	-- Check if we're already using an ability
    	if ( npcBot:IsUsingAbility() ) then return end;
    
    	abilityPW = npcBot:GetAbilityByName( "venomancer_plague_ward" );
    	abilityVG = npcBot:GetAbilityByName( "venomancer_venomous_gale" );
    	abilityPN = npcBot:GetAbilityByName( "venomancer_poison_nova" );
    
    	-- Consider using each ability
    	castPNDesire = ConsiderPoisonNova();
    	castPWDesire, castPWLocation = ConsiderPlagueWard();
    	castVGDesire, castVGLocation = ConsiderVenomGale();
    
    	if ( castPNDesire > castPWDesire and castPNDesire > castVGDesire ) 
    	then
    		npcBot:Action_UseAbility( abilityPN );
    		return;
    	end
    
    	if ( castPWDesire > 0 ) 
    	then
    		npcBot:Action_UseAbilityOnLocation( abilityPW, castPWLocation );
    		return;
    	end
    
    	if ( castVGDesire > 0 ) 
    	then
    		npcBot:Action_UseAbilityOnLocation( abilityVG, castVGLocation:GetLocation());
    		return;
    	end
    
    end
    
    ----------------------------------------------------------------------------------------------------------------------------------
    
    function CanCastPlagueWardOnTarget( npcTarget )
    	return npcTarget:CanBeSeen() and not npcTarget:IsMagicImmune() and not npcTarget:IsInvulnerable();
    end
    
    
    function CanCastVenomGaleOnTarget( npcTarget )
    	return npcTarget:CanBeSeen() and not npcTarget:IsMagicImmune() and not npcTarget:IsInvulnerable();
    end
    
    
    function CanCastPoisonNovaOnTarget( npcTarget )
    	return npcTarget:CanBeSeen() and npcTarget:IsHero() and ( GetBot():HasScepter() or not npcTarget:IsMagicImmune() ) and not npcTarget:IsInvulnerable();
    end
    
    ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    
    function ConsiderPlagueWard()
    
    	local npcBot = GetBot();
    
    	-- Make sure it's castable
    	if ( not abilityPW:IsFullyCastable() ) 
    	then 
    		return BOT_ACTION_DESIRE_NONE, 0;
    	end;
    
    	-- If we want to cast Poison Nova at all, bail
    	if ( castPNDesire > 0 ) 
    	then
    		return BOT_ACTION_DESIRE_NONE, 0;
    	end
    	
    	-- Get some of its values
    	local nCastRange = abilityPW:GetCastRange();
    
    
    
    -----	---------------------------------------------
    	-- Mode based usage
    --------------------------------------------------
    
    	if ( npcBot:GetActiveMode() == BOT_MODE_LANING and 
    			npcBot:GetMana()/npcBot:GetMaxMana() >= 0.1  ) 
    		then
    			local tableNearbyEnemyCreeps = npcBot:GetNearbyCreeps( 800, true);
    			if(tableNearbyEnemyCreeps[1] ~= nil) then
    				return BOT_ACTION_DESIRE_LOW, tableNearbyEnemyCreeps[1]:GetLocation();
    		end
    	end
    
    ---------- FARMING -------------------------------
    
    	if ( npcBot:GetActiveMode() == BOT_MODE_FARM and 
    		npcBot:GetMana()/npcBot:GetMaxMana() >= 0.8  ) 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( 800, true);
    			if(tableNearbyTowers[1] ~= nil and not tableNearbyTowers[1]:IsInvulnerable( )) then
    				return BOT_ACTION_DESIRE_LOW, tableNearbyTowers[1]:GetLocation();
    
    		end
    	end
    
    
    
    ----------- DEFEND TOWER -----------------------
    
    	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 tableNearbyTowers = npcBot:GetNearbyTowers( 800, false);
    			if(tableNearbyTowers[1] ~= nil and not tableNearbyTowers[1]:IsInvulnerable( )) then
    				return BOT_ACTION_DESIRE_MODERATE, tableNearbyTowers[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 ( CanCastPlagueWardOnTarget( 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 ConsiderVenomGale()
    	local npcBot = GetBot();
    
    	-- Make sure it's castable
    	if ( not abilityVG:IsFullyCastable() ) then 
    		return BOT_ACTION_DESIRE_NONE, 0;
    	end;
    	
    	
    	-- Get some of its values
    	local nCastRange = abilityVG:GetCastRange();
    	local nRadius = 125;
    
    
    ---------- FARMING -------------------------------
    
    	if ( npcBot:GetActiveMode() == BOT_MODE_FARM and 
    		npcBot:GetMana()/npcBot:GetMaxMana() >= 0.6  ) then
    
    		local tableNearbyEnemyCreeps = npcBot:GetNearbyNeutralCreeps(800);
    		if(tableNearbyEnemyCreeps[1] ~= nil) then
    			return BOT_ACTION_DESIRE_LOW, tableNearbyEnemyCreeps[1];
    		end
    	end
    ----------- LANING -------------------------------
    
    if ( npcBot:GetActiveMode() == BOT_MODE_LANING and 
    		npcBot:GetMana()/npcBot:GetMaxMana() >= 0.8  ) 
    	then
    		local tableNearbyEnemyCreeps = npcBot:GetNearbyCreeps( 800, true);
    		if(tableNearbyEnemyCreeps[1] ~= nil) then
    			return BOT_ACTION_DESIRE_LOW, tableNearbyEnemyCreeps[1];
    	end
    end
    
    
    --------- RETREATING ----------------------------	
    
    if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT ) then
    	--then
    		local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( nCastRange - 100, true, BOT_MODE_NONE );
    		for _,npcEnemy in pairs( tableNearbyEnemyHeroes )
    		do
    			if ( (npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) or GetUnitToUnitDistance( npcEnemy, npcBot ) < nCastRange - 100) and CanCastVenomGaleOnTarget( npcEnemy ) ) 
    			then
    				return BOT_ACTION_DESIRE_HIGH, npcEnemy;
    			end
    		end
    	end
    	
    	-- If a mode has set a target, and we can kill them, do it
    	local npcTargetToKill = npcBot:GetTarget();
    	if ( npcTargetToKill ~= nil and CanCastVenomGaleOnTarget( npcTargetToKill ) )
    	then
    		if ( (npcTargetToKill:GetHealth() / npcTargetToKill:GetMaxHealth()) < 0.25 and GetUnitToUnitDistance( npcTargetToKill, npcBot ) < ( nCastRange ) )
    		then
    			return BOT_ACTION_DESIRE_HIGH, npcTargetToKill;
    		end
    	end
    	
    ---------- CHASING --------------------------------
    
    	if ( npcBot:GetActiveMode() == BOT_MODE_ROAM or
    		 npcBot:GetActiveMode() == BOT_MODE_TEAM_ROAM or
    		 npcBot:GetActiveMode() == BOT_MODE_GANK or
    		 npcBot:GetActiveMode() == BOT_MODE_ATTACK or
    		 npcBot:GetActiveMode() == BOT_MODE_DEFEND_ALLY ) 
    	then
    		local npcTarget = npcBot:GetTarget();
    
    		if ( npcTarget ~= nil and CanCastVenomGaleOnTarget( npcTarget ) ) 
    		then
    			if ( GetUnitToUnitDistance( npcTarget, npcBot ) < ( nCastRange ) ) 
    			then
    				return BOT_ACTION_DESIRE_HIGH, npcTarget;
    			end
    		end
    	end
    
    	return BOT_ACTION_DESIRE_NONE, 0;
    end
    
    
    ----------------------------------------------------------------------------------------------------------------------------------
    -----------------------------------------------------------------
    
    function ConsiderPoisonNova()
    
    	local npcBot = GetBot();
    
    	-- Make sure it's castable
    	if ( not abilityPN:IsFullyCastable() ) then 
    		return BOT_ACTION_DESIRE_NONE;
    	end;
    
    
    	-- Get some of its values
    	local nRadius = abilityPN:GetSpecialValueInt( "radius" );
    	local nCastRange = 0;
    	local nDamage = abilityPN:GetAbilityDamage();
    
    --------------------------------------------------------
    	-- Mode based usage
    -------------------------------------------------------
    
    
    ------- RETREATING -----------------------------------
    
    	if ( npcBot:GetActiveMode() == BOT_MODE_RETREAT and npcBot:GetActiveModeDesire() >= BOT_MODE_DESIRE_HIGH ) 
    	then
    		local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( nCastRange + nRadius, true, BOT_MODE_NONE );
    		for _,npcEnemy in pairs( tableNearbyEnemyHeroes )
    		do
    			if ( npcBot:WasRecentlyDamagedByHero( npcEnemy, 2.0 ) ) 
    			then
    				if ( CanCastPoisonNovaOnTarget( npcEnemy ) ) 
    				then
    					return BOT_ACTION_DESIRE_MODERATE;
    				end
    			end
    		end
    	end
    
    ------ CHASING -------------------------------
    	if ( 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 ) 
    		then
    			if ( CanCastPoisonNovaOnTarget( npcTarget ) and GetUnitToUnitDistance( npcBot, npcTarget ) < nRadius)
    			then
    				return BOT_ACTION_DESIRE_HIGH;
    			end
    		end
    	end
    
    -------- if we're in creep wave and in range of enemy hero -----
    
    	if ( npcBot:GetActiveMode() == BOT_MODE_LANING) 
    	then
    		local tableNearbyEnemyHeroes = npcBot:GetNearbyHeroes( 1300, true, BOT_MODE_NONE );
    		local npcTarget = tableNearbyEnemyHeroes[1];
    
    		if ( npcTarget ~= nil ) 
    		then
    			if ( CanCastPoisonNovaOnTarget( npcTarget ) and GetUnitToUnitDistance( npcBot, npcTarget ) < nRadius)
    			then
    				local locationAoE = npcBot:FindAoELocation( true, false, npcBot:GetLocation(), 0, nRadius, 0.0, 100000 );
    				if ( locationAoE.count >= 3 ) then
    					return BOT_ACTION_DESIRE_MODERATE;
    				end
    			end
    		end
    	end
    
    	return BOT_ACTION_DESIRE_NONE;
    
    end

    is still only a basic script and could use a whole lot more conditions for skill use.
    --venomous gale is broken when it comes to creeps / farming. (hashed out)

    Edit: Venom Gale works properly now.
    Last edited by Yavimaya; 02-07-2017 at 05:09 AM.

Posting Permissions

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