Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NOT AN ISSUE FOR THIS PROJECT BUT: #227

Closed
ByBurton opened this issue May 30, 2017 · 36 comments
Closed

NOT AN ISSUE FOR THIS PROJECT BUT: #227

ByBurton opened this issue May 30, 2017 · 36 comments
Labels

Comments

@ByBurton
Copy link
Contributor

@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"

@Nostrademous
Copy link
Owner

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

seem like that file doesn't exist for you

@Nostrademous
Copy link
Owner

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

@ByBurton
Copy link
Contributor Author

ByBurton commented May 30, 2017

@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

@Nostrademous
Copy link
Owner

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

@ByBurton
Copy link
Contributor Author

ByBurton commented May 30, 2017

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

@Nostrademous
Copy link
Owner

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

@ByBurton
Copy link
Contributor Author

@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.

@ByBurton
Copy link
Contributor Author

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

@Nostrademous
Copy link
Owner

it should be: npcBot:ActionImmediate_PurchaseItem( sNextItem );

@ByBurton
Copy link
Contributor Author

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

@ByBurton
Copy link
Contributor Author

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

@ByBurton
Copy link
Contributor Author

IT IS WORKING! #fuckValve

@ByBurton
Copy link
Contributor Author

@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

@Nostrademous
Copy link
Owner

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

@ByBurton
Copy link
Contributor Author

@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.

@Nostrademous
Copy link
Owner

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

@ByBurton
Copy link
Contributor Author

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?

@Nostrademous
Copy link
Owner

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

@CsharpNoobDude
Copy link

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

@Nostrademous
Copy link
Owner

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.

@ByBurton
Copy link
Contributor Author

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;

@ByBurton
Copy link
Contributor Author

ByBurton commented May 31, 2017

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

@Nostrademous
Copy link
Owner

Nostrademous commented Jun 1, 2017

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.

@ByBurton
Copy link
Contributor Author

ByBurton commented Jun 1, 2017

@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;

@ByBurton
Copy link
Contributor Author

ByBurton commented Jun 1, 2017

only the lower part works

@Nostrademous
Copy link
Owner

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

@ByBurton
Copy link
Contributor Author

ByBurton commented Jun 1, 2017

@Nostrademous
Copy link
Owner

print the value of "WeakestCreep" and "nLowestCreepHitPoints"

@ByBurton
Copy link
Contributor Author

ByBurton commented Jun 1, 2017

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?

@Nostrademous
Copy link
Owner

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.

@ByBurton
Copy link
Contributor Author

ByBurton commented Jun 1, 2017

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

@ByBurton
Copy link
Contributor Author

ByBurton commented Jun 2, 2017

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

@Nostrademous
Copy link
Owner

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

@ByBurton
Copy link
Contributor Author

ByBurton commented Jun 2, 2017

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

@Nostrademous
Copy link
Owner

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

@ByBurton
Copy link
Contributor Author

ByBurton commented Jun 6, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants