Nostrademous / Dota2-FullOverwrite

Work in progress for a full-overwrite Dota 2 bot framework

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

NOT AN ISSUE FOR THIS PROJECT BUT:

ByBurton opened this issue · comments

@Nostrademous @eteran @reidzeibel @RabidCicada @dralois I really need some help. I tried to do some coding again, so I can or maybe will be of help for this project some day, but I am too stupid for lua.
CONSOLE OUTPUT:
VScript] Script Runtime Error: ...ts\vscripts\bots\ability_item_usage_phantom_assassin.lua:68: attempt to index global 'utilityFunctions' (a boolean value) stack traceback: ...ts\vscripts\bots\ability_item_usage_phantom_assassin.lua:68: in function 'ConsiderStiflingDagger' ...ts\vscripts\bots\ability_item_usage_phantom_assassin.lua:22: in function <...ts\vscripts\bots\ability_item_usage_phantom_assassin.lua:8>

my script: "http://collabedit.com/ej2py"

utility = require(GetScriptDirectory() .. "/utilityFunctions"); <-- LINE #4

seem like that file doesn't exist for you

actually, seems it exists, but probably doesn't have a return (b/c "utility" is being treated as a boolean, not a module)

@Nostrademous already fixed that
[VScript] Script Runtime Error: ...ts\vscripts\bots\ability_item_usage_phantom_assassin.lua:41: attempt to index local 'npcTarget' (a nil value)
stack traceback:
...ts\vscripts\bots\ability_item_usage_phantom_assassin.lua:41: in function 'CanCastStiflingDaggerOnTarget'
...ts\vscripts\bots\ability_item_usage_phantom_assassin.lua:80: in function 'ConsiderStiflingDagger'
...ts\vscripts\bots\ability_item_usage_phantom_assassin.lua:22: in function <...ts\vscripts\bots\ability_item_usage_phantom_assassin.lua:8>

edit: the link to the other script: http://collabedit.com/ryu9a

utils.GetWeakestUnit() can return "nil". You don't check before passing it on line #80 in ability_item_usage_phantom_assassin.lua

Yes, thank you @Nostrademous , that was the problem.
the pa ability usage script works fine now, and no more errors are shown in the console. BUT: she still buys no items, dispite my script here:
http://collabedit.com/vcen9

what is the name of that file? Is it ever being called?

@Nostrademous yes, I added two prints in the two ifs (it jumps into 2nd one, that one that matters to purchase smthg.) but it does not purchase the item.

this is not working: npcBot:Action_PurchaseItem( sNextItem );
table.remove( ItemsToBuy, 1 );

it should be: npcBot:ActionImmediate_PurchaseItem( sNextItem );

But I used the example scripts by valve? how can they be wrong?

also @Nostrademous pls come online in steam. quicker and easier to chat...

IT IS WORKING! #fuckValve

@Nostrademous I have a working hero_selection.lua script, but then I play with another person (me + the other guy = 2 human players) one of the bots does not pick a hero. Why

the bot player-id slot # changes depending on how many people are in the game

@Nostrademous thank you. will look into that. http://collabedit.com/vcen9
How do I make pa buy vitality booster? for now she just skips it? the secret shop items.

that's harder - you either send the courier there, or walk there and buy it.

but how. and what if I go there? I don't see an action or smthg in the list to purchase secret shop items, only normal items. Can you help me?

It is the same as buying normal items, you (or courier) just have to be at the right location.

Yeah, but how do I send the bot there? is there a command GetBot():ACTION_IMMEDIATE_GOTO_SECRET_SHOP() or smthg like that?

Nope... there is a "Action_MoveToLocation( vecLocation )" and you can specify the Vector of the shop location.

"Immediate" actions are only for actions that take less than 1 frame to complete. Move locations are harder, because it might take you 30 seconds to walk there.. and while you are walking you might run into enemy heroes... what then?

That is why my code has a mode named shop "https://github.com/Nostrademous/Dota2-FullOverwrite/blob/master/modes/shop.lua" which does all that work.

Yes, it gets complicated.

That does not help me too much. Can you not just write an example code for how to walk to the secret shop, purchase the item in the list and remove it from the list?

I am using this:

function ItemPurchaseThink()

local npcBot = GetBot();
secretShopRadiant = Vector(-4472, 1328);


if ( #ItemsToBuy == 0 )
then
    --print( "first if is called" );
	npcBot:SetNextItemPurchaseValue( 0 );
	return;
end;

local sNextItem = ItemsToBuy[1];

npcBot:SetNextItemPurchaseValue( GetItemCost( sNextItem ) );

if ( npcBot:GetGold() >= GetItemCost( sNextItem ) )
then
    --print( "second if is called" );
    if ( IsItemPurchasedFromSecretShop( sNextItem ) )
    then
        npcBot:ActionPush_MoveToLocation( secretShopRadiant );
		npcBot:ActionImmediate_PurchaseItem( sNextItem );
		table.remove( ItemsToBuy, 1 );
    else
		npcBot:ActionImmediate_PurchaseItem( sNextItem );
		table.remove( ItemsToBuy, 1 );
    end;
end;

end;

But the bot keeps not purchasing the item and just skips over it. (The secret shop item; all others are bought just fine)

you cannot do that because "ActionImmediate" happen right away.

You need to do your ActionPush_MoveToLocation() and get to the shop first, before you do the rest.

if GetUnitToLocationDistance(npcBot, secretShopRadiant) > 400 then
    npcBot:Action_MoveToLocation(secretShopRadiant)
else
    npcBot:ActionImmediate_PurchaseItem( sNextItem )
    table.remove( ItemsToBuy, 1 )
end

The code above should work (but doesn't do anything if you run into enemy heroes for example on your way to shop). I assume 400 is the interaction distance with a shop... would have to check to be sure that value is sufficient.

@Nostrademous Thank you, did not test it yet, but I have no doubt it works. Other thing, I noticed my pa does use the dagger to harss, but not in creeps, although I tell her to;
--while laning or farming
if ( npcBot:GetActiveMode() == BOT_MODE_FARM or npcBot:GetActiveMode() == BOT_MODE_LANING )
then
if ( nLowestCreepHitPoints < nDamage and CanCastStiflingDaggerOnTarget( WeakestCreep ) )
then
npcBot:ActionImmediate_Chat( "Trying to lasthit with dagger", true );
return BOT_ACTION_DESIRE_MEDIUM, WeakestCreep;
end;

	if ( CanCastStiflingDaggerOnTarget(WeakestEnemy) )
	then
        npcBot:ActionImmediate_Chat( "Spamming dagger on enemy hero while laning", true );
		return BOT_ACTION_DESIRE_LOW, WeakestEnemy;
	end;
end;

only the lower part works

Not enough code for me to tell you honestly, chances are that the "WeakestCreep" variable is simply "nil" and thus it doesn't work.

print the value of "WeakestCreep" and "nLowestCreepHitPoints"

No, the variable is not nil. I can see the Action_ImmediateSay( "Tryint to lasthit with dagger", true ) in allchat. @Nostrademous Print? is it not easier to let the bot call it?

It is possible that PhantomStrike is over-writing it then. You should return with BOT_ACTION_DESIRE_MEDIUM... but in the higher level function you have code that says only do the Dagger if castDesireStiflingDagger > castDesirePhantomStrike. If Phantom Strike evaluation is also BOT_ACTION_DESIRE_MEDIUM the ">" is not met and it won't use it.

If that's not the case then perhaps he is casting the dagger, but before the cast point of the ability is met (the animation) you tell the bot to do another action, canceling the currently executing one.

Updated the code (and the collabedit). I added +0.1 after the BOT_ACTION_DESIRE_MEDIUM
edit: Don't know if it will work.

@Nostrademous so I tested it, pa is not using any of the skills on creeps. And only throws her dagger on enemy heroes.

Then it is a case of another command over-riding it.

@Nostrademous could it be something the original default bots do?

Did you create your own "bot_phantom_assassin.lua"? If so, what is your "Think()"?

No, I did not. I have no think. What is the bot_pjhantom_assassin.lua" script for?