What makes the Shoshone have the Pathfinder as their default start unit?

Rob (R8XFT)

Ancient Briton
Retired Moderator
Joined
Aug 11, 2002
Messages
10,866
Location
Leeds (UK)
As per the thread title - I would like to replicate this with a scout UU myself. Raising the unit strength to 8 or above doesn't work, nor does any change in the cost of the unit. I can't find anything that points to the choice of the pathfinder instead of the warrior. Any ideas anyone?
 
It's a good idea and thanks for the response. I have tried it though and it doesn't appear to be that.
 
I know for certain that changing around the ai types can alter what starting units you get. It may not be the only factor but it's definitely one. You should also try using UNITAI_EXPLORE and UNITAI_COUNTER. The pathfinder also has UNITAI_FAST_ATTACK, it may be that one (or that one combined with UNITAI_DEFENSE).

In the eras.xml file, there's information about how many "defense" and "explore" units you get depending on the era.
 
It is UNITAI_DEFENSE, but it has to be a row in the <Unit_AITypes> table and not the <DefaultUnitAI> value for the unit

The problem being that if you do that for a true scout unit, the AI will try and use them for defense!

From CvPlayer.cpp
Code:
// Defensive units
iFreeCount = gameStartEra.getStartingDefenseUnits();
iFreeCount += playerHandicap.getStartingDefenseUnits();

if(!isHuman())
  iFreeCount += gameHandicap.getAIStartingDefenseUnits();

if(iFreeCount > 0 && !isMinorCiv())
  addFreeUnitAI(UNITAI_DEFENSE, iFreeCount);
 
Thanks to both of you. Is there a workaround that you know of that would make a modded civ get the scout instead of the worker?
 
Hi, Rob; I may have an answer.

I'm guessing it may be because the pathfinder was given UNITAI_DEFENSE (and doesn't have UNITAI_EXPLORE) and it costs 45 instead of the warrior at 40.

So, I thought maybe the game grants the player the most expensive available UNITAI_DEFENSE unit, since they added that extra 5 production and broke the standard (Civ5Eras.xml; StartingDefenseUnits = 1; Civ5HandicapInfos.xml has a StartingDefenseUnits and such for the player too, which gets added, but it's always 0.). The fact that they removed UNITAI_EXPLORE may have helped too, since maybe the game checks if a unit can cover another later free AI type and chooses the one with less first.

Also...

Check out CvPlayer.cpp, and the function at line 1316, void CvPlayer::initFreeUnits(CvGameInitialItemsOverrides& /*kOverrides*/)

I'm not accustomed to C++ and have difficulty reading it.

It looks like the game first checks if a civ has any unique traits which grants free units (or is it looking for unique units?). It then proceeds to check Defense, Worker, and Explore AI types and how many free ones to give out to the player and AI, according to CIV5Eras and CIV5HandicapInfos.

There's also this at the end:
Code:
	// If we only have one military unit and it's on defense then change its AI to explore
	if(GetNumUnitsWithUnitAI(UNITAI_EXPLORE) == 0)
	{
		int iLoop;
		CvUnit* pLoopUnit;
		for(pLoopUnit = firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = nextUnit(&iLoop))
		{
			if(pLoopUnit->AI_getUnitAIType() == UNITAI_DEFENSE)
			{
				pLoopUnit->AI_setUnitAIType(UNITAI_EXPLORE);
				break;
			}
		}
	}

Maybe that was added in to help with the new Pathfinder, and add UNITAI_EXPLORE to the first one, once it's granted as the first free unit.

I don't know... just throwing some things out here, hope it helps.

EDIT: Oops, Mr. Howard beat me to it. :lol:
 
Thanks to both of you. Is there a workaround that you know of that would make a modded civ get the scout instead of the worker?

Code in a lua file outside of an event/method runs as the game loads, so you could store a value into the modders db to see if the code had already been run (so as not to execute on loading a game) and then loop each player, see if they are the civ desired and then swap out the worker (warrior???) for a scout. Messy, but not complex.
 
Thanks again; I'm not really that great at lua and the only C++ experience I've had was in Geography along with a "pleasant lad, but must try harder" comment :).

However, you've given me the right direction to aim my little experiments towards. If I don't fathom it out by amending my unit correctly, I'll try to amend the pathfinder so it isn't selected as the default unit and work backwards from there ;).

EDIT: update: it works!! A unit cost of 45 and UNITAI_DEFENCE as one of the options is the way to go. I'd still like the unit to cost 25 though, so perhaps I'll look at how to build into the UA for scouts to cost -50% production and have their unit cost at 50 x 50%=25, as a way of offsetting this.
 
Hi, Rob; I may have an answer.

I'm guessing it may be because the pathfinder was given UNITAI_DEFENSE (and doesn't have UNITAI_EXPLORE) and it costs 45 instead of the warrior at 40.

So, I thought maybe the game grants the player the most expensive available UNITAI_DEFENSE unit, since they added that extra 5 production and broke the standard (Civ5Eras.xml; StartingDefenseUnits = 1; Civ5HandicapInfos.xml has a StartingDefenseUnits and such for the player too, which gets added, but it's always 0.). The fact that they removed UNITAI_EXPLORE may have helped too, since maybe the game checks if a unit can cover another later free AI type and chooses the one with less first.

Also...

Check out CvPlayer.cpp, and the function at line 1316, void CvPlayer::initFreeUnits(CvGameInitialItemsOverrides& /*kOverrides*/)

I'm not accustomed to C++ and have difficulty reading it.

It looks like the game first checks if a civ has any unique traits which grants free units (or is it looking for unique units?). It then proceeds to check Defense, Worker, and Explore AI types and how many free ones to give out to the player and AI, according to CIV5Eras and CIV5HandicapInfos.

There's also this at the end:
Code:
	// If we only have one military unit and it's on defense then change its AI to explore
	if(GetNumUnitsWithUnitAI(UNITAI_EXPLORE) == 0)
	{
		int iLoop;
		CvUnit* pLoopUnit;
		for(pLoopUnit = firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = nextUnit(&iLoop))
		{
			if(pLoopUnit->AI_getUnitAIType() == UNITAI_DEFENSE)
			{
				pLoopUnit->AI_setUnitAIType(UNITAI_EXPLORE);
				break;
			}
		}
	}

Maybe that was added in to help with the new Pathfinder, and add UNITAI_EXPLORE to the first one, once it's granted as the first free unit.

I don't know... just throwing some things out here, hope it helps.

EDIT: Oops, Mr. Howard beat me to it. :lol:

It's pretty bad when you're hacking stuff into your own game. Man...
 
Back
Top Bottom