FeaturePassableTechs not working

davidlallen

Deity
Joined
Apr 28, 2008
Messages
4,743
Location
California
I have a mod where you cannot enter fallout, unless you have a certain promotion. I am using python unitCannotMoveInto. It is only a couple of lines of code, basically, if the plot is fallout, and you do not have the "rad-immune" promotion, then you cannot move into the plot. This is working.

But, it slows the game down tremendously. Like, by a factor of 5: from the same start position, the game takes 150 minutes to autoplay 350 turns. When I disable that python callback, then the game takes only 30 minutes.

I stumbled across the unit xml flag FeaturePassableTechs. Maybe I can use this to get the same effect. I give the fallout feature <bImpassible>1, and then give every unit the following:

Code:
<FeaturePassableTechs>
   <FeaturePassableTech>
      <FeatureType>FEATURE_FALLOUT</FeatureType>
      <PassableTech>TECH_MEDICINE</PassableTech>
   </FeaturePassableTech>
</FeaturePassableTechs>

What that *should* do is make fallout impassible, except when the owning player of this unit has the medicine tech. That is almost the same effect as using a promotion, close enough.

However, the above two changes seem to have no effect. The unit with this code still cannot move into fallout when I have the medicine tech.

There are no units I can find in the vanilla game, or in any mod for that matter, which use this flag. Is it possible this flag was never implemented in the code? Or is it possible there is some third thing I need to do, which I missed?

My playtesters like the restriction that you cannot move into fallout, but I don't want to give a 5x longer turn runtime just for this.

Any suggestions?
 
You can't make the feature itself impassable. Instead you need to use the FeaturePassableTech in combination with <FeatureImpassables/>
 
So, every unit has to declare the feature impassible, and then every unit has to declare the feature passable tech? Have you found/used this in any mod which I could check out?
 
So, every unit has to declare the feature impassible, and then every unit has to declare the feature passable tech? Have you found/used this in any mod which I could check out?

Check out the Fall from Heaven: Age of Ice mod that comes with BtS. Every unit in there (except 1) have feature impassable set to the Letum Frigus feature. I didnt set it to have the feature become passable with a tech, but it works exactly as Maniac said.
 
I tried this and in fact it does *not* work. I believe that putting FeaturePassableTechs onto the unit makes it completely fail to appear in the game. Here is how to reproduce the problem.

1. Set up a totally vanilla BTS 3.17, no mods.
2. Copy <install>.../CIV4UnitInfo.xml to <my games>/.../CustomAssets/...
3. In the my games copy, change the strength of the warrior to 8
4. Start a game, any map, and verify your warrior has strength 8. If you have started as a civ which has a scout instead, use the debugger and verify some other civ's warrior has strength 8
5. Change the <my games>.../CIV4UnitInfo.xml and add this to warrior (a few lines of context are shown):

Code:
   <iEspionagePoints>0</iEspionagePoints>
   <TerrainImpassables/>
   <FeatureImpassables>
      <FeatureImpassable>
         <FeatureType>FEATURE_FALLOUT</FeatureType>
         <bFeatureImpassable>1</bFeatureImpassable>
      </FeatureImpassable>
   </FeatureImpassables>
   <TerrainPassableTechs/>
   <FeaturePassableTechs>
      <FeaturePassableTech>
         <FeatureType>FEATURE_FALLOUT</FeatureType>
         <PassableTech>TECH_MEDICINE</PassableTech>
      </FeaturePassableTech>
   </FeaturePassableTechs>
   <iCombat>8</iCombat>
6. Start a game. Look, Mom, *no warriors in the game* ! Any civ which is supposed to start with a warrior, doesn't.

So, I believe that FeaturePassableTech is completely not working.

Is there something wrong with my xml?

Is there another way to accomplish the effect, where a promotion or tech or something is required to move through fallout?
 
It seems right according to the 3.17 BTS schema. I would hope the game would have flagged an actual syntax error, although there certainly are cases it does not flag. There are no examples of this particular XML used in any mod I can find. I am sure Kael would have pointed to an example if one existed.
 
this is strange, i added your code to the cavalry, only exchanged Fallout with Flood plains

Spoiler :
Code:
<FeatureImpassables>
        <FeatureImpassable>
	<FeatureType>FEATURE_FLOOD_PLAINS</FeatureType>
	<bFeatureImpassable>1</bFeatureImpassable>
        </FeatureImpassable>
</FeatureImpassables>
<TerrainPassableTechs/>
<FeaturePassableTechs>
        <FeaturePassableTech>
	 <FeatureType>FEATURE_FLOOD_PLAINS</FeatureType>
	 <PassableTech>TECH_MEDICINE</PassableTech>
        </FeaturePassableTech>
</FeaturePassableTechs>

and it worked like it should, started a game, added a cavalry with the worldbuilder near a flood plain, no movement possible, gave me medicine and i could enter the food plain with the cavalry
 
Indeed when I tried your test I saw the same thing (no starting warriors). However, the warrior itself works fine. Both you and the AI can build them and once you do (or if you place it directly with WB) the feature impassible flags work as intended. It can't enter fallout if you don't have medicine but can once you get it.

The fact that the game won't give such a unit as a starting unit looks like a completely separate issue. Perhaps those flags prevent it from being considered a suitable exploring unit and that makes it ineligible for a starter unit? (Just taking a shot there; I know nothing about the AI ;))
 
It is unfortunate if the starting unit cannot have these flags, since I intend for all but a couple of late game specialty units to have these flags.

Why should the AI reject this as a starting unit? Is there a way to force that from a mapscript (not a scenario)?
 
I´m not sure, but could it be possible to a make a python script which only runs at turn one [start of the game] and give the players the units [something like this, get a random number between 0 and 21 (town working area), if the terrain is legal, place a unit there, if not repeat]? Perhaps there is a small delay when the games starts but then the game itself will run faster. But still a strange thing.

Edit: Idea 2, another script, like you exchange the units when running out of fuel, make two surviver units, one for startup placing without impassible flag, and before turn one starts exchange this unit with a copy with this flags, could be easier to do?
 
I agree that would probably work, but it seems like an awful hack. If there is any way to understand *why* FeatureImpassableTech prevents warriors from appearing normally, that would be better.
 
I'll try that. If the warrior *consistently* *never* appears due to this apparent bug, then that should be fine. But without understanding the underlying reason, I am worried that I may make some other change which seems unrelated, and suddenly players will get two warriors.

Can any SDK expert (cough...Kael...cough) suggest why the initial warrior should disappear because of this?
 
OK, I did some poking around and my initial guess was correct. The addition of the FeatureImpassable on the warrior prevents it from being given as a starting exploration unit. It is consistent, so you should be able to adjust for it.

Here's the gory details:

1) For an ancient era start with the default CIV4EraInfos.xml, everybody is supposed to get a free exploring unit:

Code:
			<Type>ERA_ANCIENT</Type>
			...
			<iStartingExploreUnits>1</iStartingExploreUnits>

So when the civs are placed on the map the game winds up calling the function CvPlayer::addFreeUnitAI() to give those units. That function, in turn, calls CvPlayerAI::AI_unitValue() to determine which available unit is best suited for the task.

Looking at CvPlayerAI::AI_unitValue() for the case of an exploring unit:
Code:
		case UNITAI_EXPLORE:
			if (GC.getUnitInfo(eUnit).getCombat() > 0)
			{
				[COLOR="Red"]if (0 == AI_unitImpassableCount(eUnit))[/COLOR]
				{
					bValid = true;
				}
			}
			break;
The test I highlighted in red causes any unit with any impassable tags to be disqualified from being considered a potential explorer.
 
Thanks, that seems conclusive. So it is not FeaturePassableTech causing the problem, it is FeatureImpassables. I guess FFH Age Of Ice does not show this problem, because it is a scenario with the starting units already placed.

In my mod I am already placing a city; so I will just place the initial warrior also. But now that I know *why* the game doesn't place them, I am much more confident there will be no side effects.
 
Back
Top Bottom