Closed adamqqqplay closed 1 year ago
@JoshdanG @ArcherWayne Please take a look at item_purchase_generic.lua and give me some advice on how to call ItemPurchaseSystem directly. The current implementation may introduce some additional overhead.
Does this actually work? Does item_purchase_generic get loaded separately for each hero?
Thanks for your detailed review. It does work in my local tests. item_purchase_generic will run a separate instance for each hero, and find the corresponding item build list in the subdirectory through the hero's name.
I think the individual hero files should only contain X.ItemsToBuy and everything else should be handled centrally. If needed you could add a "X.shouldBuySupportItems=true" and other similar attributes, but I think currently any variance there is accidental.
What you said is right, I also want to achieve this, but the current item purchase function is a little complicated, and I haven't seen the logic between them clearly yet.
Just calling the folder "hero" seems wrong. What's the end goal in terms of folder structure? There will likely be multiple files for each hero. Probably you want either hero/items/hero_name.lua or hero/hero_name/items.lua
I think this directory can include the hero's ability building list and item building list, so I temporarily named it "hero". Your opinion is very useful, I will reconsider how to modify it.
I created a pull request to show what I was suggesting about reducing the file contents. https://github.com/adamqqqplay/dota2ai/pull/130
There was one snag I overlooked -- ItemPurchaseSystem was unnecessarily using "self" and ItemsToBuy, so I cleaned this up as well.
I have marked it as draft because I only did the change for 10 heros and set hero selection to debug so only they would be used. If you want to use it I can clean it up to be a proper pull request.
I created a pull request to show what I was suggesting about reducing the file contents. #130
There was one snag I overlooked -- ItemPurchaseSystem was unnecessarily using "self" and ItemsToBuy, so I cleaned this up as well.
I have marked it as draft because I only did the change for 10 heros and set hero selection to debug so only they would be used. If you want to use it I can clean it up to be a proper pull request.
@JoshdanG Thanks very much! I think your work is very great. If you have time, you can merge these two PRs and submit it to the master branch. If you haven't gotten around to it yet, I'm going to take the time to deal with that this weekend.
Finished at #133
Move all itempurchase*.lua to subdirectory to reduce maintenance costs and make it easier for players to edit.
Fix: #126