[BTS - SDK] CvUnit and CvPlayerAI

macsbug

Chieftain
Joined
Oct 31, 2005
Messages
75
CvUnit:
The mod I’m currently working on requires that a method in CvPlayer calls a method in CvUnit for each of the player’s units of a specific type (in this case UNIT_ICBM). At the moment I’m simply iterating through every one of the player’s units every time the method is called. Ideally, however, I’d much rather maintain separate list of valid units. The problem is maintaining the list through ::read / ::write calls. Are there any unique identifiers CvUnit uses that persist through those, or would it be necessary to rebuild the list?

CvPlayerAI (CvCityAI?):
The AI needs to build a single additional building. When the specified building is built a flag is set in CvPlayer. The building is a National Wonder, and appears to be limited to one instance of the building per player. Which methods are used in the AI’s building selection process (or is it possible to force this behavior in some other manner)?

Any information on the above would be appreciated.
 
CvUnit: How many times per player turn are you calling your CvPlayer method? If it's just once, there's little overhead involved and I can't see it being worth the bother to maintain a special list.


CvCityAI: I think the method you're looking for is CvCityAI::AI_bestBuildingThreshold. This has been changed slightly for BTS but when I was making notes for the Warlords version this is what I came up with:

Returns the best building for this city to build.


Parameters:
iFocusFlags : bitmask for filtering emphasis selections (e.g., BUILDINGFOCUS_PRODUCTION)
iMaxTurns : the max number of allowable building turns
bAsync : if true then randomize using getASyncRand()
eIgnoreAdvisor : a specific type of advisor to ignore (or NO_ADVISOR)
 
CvUnit: How many times per player turn are you calling your CvPlayer method? If it's just once, there's little overhead involved and I can't see it being worth the bother to maintain a special list.

That will vary from turn to turn - possibly quite often. I would be hesitant to venture any sort of guess. Suffice it to say it could become a problem and maintaining a special list would be preferable.

CvCityAI: I think the method you're looking for is CvCityAI::AI_bestBuildingThreshold. This has been changed slightly for BTS but when I was making notes for the Warlords version this is what I came up with:

Thank you, that function looks like it's exactly what I was looking for :)
 
Just one more question: Who. Wrote. Some. Of. These. Functions. :eek:

--shameless bump--

If anyone has more information on whether or not CvUnit contains any unique identifiers (or some other method exists already) that would allow a pointer to some unit that existed before saving a game to be retrieved after loading that game, I'd greatly applicate it.

I can hack something together to rebuild the list but I'm very hesitant to do that if the above is possible.
 
If anyone has more information on whether or not CvUnit contains any unique identifiers (or some other method exists already) that would allow a pointer to some unit that existed before saving a game to be retrieved after loading that game, I'd greatly applicate it.

Each unit has a unique id that can access through getID() I assume these are saved with the game but I'm not sure. Is this what your looking for?
 
Each unit has a unique id that can access through getID() I assume these are saved with the game but I'm not sure. Is this what your looking for?

That will do it, thanks - I wonder how I missed that when I was scanning through CvUnit.h :crazyeye:
 
Back
Top Bottom