HomeUser Control Panel (unavailable in archive)ForumsTutorialsArt GalleryResourcesMaps

How to determine what units are sold at goblin lab?

03-06-2009, 12:08 PM#1
daPanda
There seems to be a lot of threads on how to add/remove units for sale, but how do you check what units are available for sale at the Goblin Laboratory at run-time?

More info: Some of my maps don't sell the zeppelin, and I want my AI to check whether the zeppelin is for sale or not, and if it is not available, not to bother going all the way to the goblin lab to buy one.
03-06-2009, 12:44 PM#2
Vexorian
Can't think of much, for example , you could basically use the NeutralOrder native and bruteforce to see if it returns 0 for a certain unit id, but this method is a little sucky, if there are cooldowns.

Since you can't dynamically add units to buildings, I think the only way is to tweak your AI so there is a manually-set constant that determines if the building can train a certain unit.
03-06-2009, 02:43 PM#3
xombie
Quote:
Originally Posted by daPanda
There seems to be a lot of threads on how to add/remove units for sale, but how do you check what units are available for sale at the Goblin Laboratory at run-time?

You could physically check the object editor (covers map initialization) and record what units are added/removed from the Goblin Laboratory in-game. I don't know, just spreadin' ideas.
03-07-2009, 10:32 AM#4
daPanda
Thanks for the ideas, guys.
Part of the problem is that this is an .ai file to replace the default melee AI to fix a number of blizzard bugs (such as Random Hero, Relative costs, GetEnemyExpansion(), etc) and to make the AI act more human-like. So I'm not sure from where I would access that info since types and functions are limited in .ai files.

So the problem I am at right now is that when the ai go to buy a zep and there isn't any to buy, they will keep going back until they obtain the requested amount specified elsewhere in the .ai file (2 in this case). I was hoping to make it work on any melee map and just 'somehow' check if the unit is even available for sale (either no slot, or cooldown, doesn't matter really).

I would have thought SellUnits would be defined and accessible "somewhere" to test if 'ngad' was an defined unit :(

The generic AI is pretty much done, and there are only a few things left to work out such as the zep purchase. So close, now yet so far :\

I was hoping to make this into somewhat of a tutorial on how to write generic melee AI using vJass where most of the underlying melee AI work is done for you, then all is left is for the user to write the race specific build orders, harvesting, and attack requirements. So far so good, other than these few things left to resolve.
03-07-2009, 07:45 PM#5
DioD
You can add units\item to shop on runtime without any problems.
if your goblin shop have proper "market skills".

Checking every possible unit is lame, keep data base.
This will be easy if you set units to sell in game, not OE.
03-07-2009, 08:36 PM#6
xombie
daPanda, there is no extremely simple way of doing what you're asking. You might be able to import a .slk table and get the data from there, though I do not know much about SLK editing :S

Edit!

I have been reading up on IssueNeutralImmediateOrder and it seems there are a few conditions.
  • There is a unit within' the range of the specified neutral building.
  • The player who wants to buy it must have an ample amount of gold/lumber.
  • The widget that is going to be bought must be available for the owner (such as a hero's requirement for Altar).
  • The widget must be available at the shop.

You could try 'n use this to detect whether or not the function returns true/false, just make sure that the other conditions are always going to be true, so you know that the returned value is a result of the neutral building not having the desired unit. Since you specified that it is a Goblin Laboratory that you are concerned about you can use IssueNeutralTargetOrder to order the Laboratory to reveal an area, as is available in melee games.

For instance, at map initialization you could try giving Neutral Hostile an indistinguishable amount of gold/lumber and then run through typical buy-able units. I'm pretty sure there are only a few that are available in melee games.
03-08-2009, 07:47 PM#7
daPanda
Quote:
Originally Posted by DioD
You can add units\item to shop on runtime without any problems.
if your goblin shop have proper "market skills".

Checking every possible unit is lame, keep data base.
This will be easy if you set units to sell in game, not OE.
This has to work on existing melee maps so I can't define what units to sell. I need to determine what units are already for sale. Obviously I would just create a boolean var during initialization to indicate whether the zep was available, if I could find a way to determine this.


xombie,
Thanks for taking the time to look into this further. But the problem is that this would require having a unit type which points to the GobLab itself in order to issue any commands on a unit. From within AI files, ForEach or FirstOfGroup etc do not work and thus I can't use any of the Enum functions to determine if there are any GobLabs on the map, let alone get a unit type handle to one.

Given this has to work in any existing melee map, I can't add any map trigger code either (and trigger code doesn't work in an .ai file).

I'm not sure how SLK files work either, but it sounds like something I may have to look into as my choices are getting pretty slim at the moment. Thanks for the suggestions.
03-09-2009, 12:08 AM#8
xombie
I was not aware you had to specifically use .ai functions, I thought you were creating the AI with triggers.