Unit Visibility

I should be able to make it at weekend.
I have already planned UU being invisible on hills/mountains, so there will be little editing.

Do you want it to check certain unit or promotion (in case of promotion, you can easily make it work for several different units, but you have make promotion).
 
I should be able to make it at weekend.
I have already planned UU being invisible on hills/mountains, so there will be little editing.

Do you want it to check certain unit or promotion (in case of promotion, you can easily make it work for several different units, but you have make promotion).

Great!!

I think promotion fits more accordingly, maybe also easier to edit into other units and features
 
Code:
GameEvents.UnitSetXY.Add(function(player, unit, x, y)
local cUnit = Players[player]:GetUnitByID(unit);
	if cUnit:IsHasPromotion( GameInfoTypes.FakePromotionName ) then
		if Map.GetPlot(x,y) ~= nil then
			local cPlot = Map.GetPlot(x,y);
			if cPlot:GetFeatureType() == GameInfoTypes.FEATURE_FOREST then
				if not cUnit:IsHasPromotion( GameInfoTypes.InviPromotionName ) then
					cUnit:SetHasPromotion( GameInfoTypes.InviPromotionName ,true);
				end
			else
				if cUnit:IsHasPromotion( GameInfoTypes.InviPromotionName ) then
					cUnit:SetHasPromotion( GameInfoTypes.InviPromotionName ,false);
				end
			end
		end
	end
end)
You will have to make two promotions in XML:

FakePromotionName - the one you have to add to your unit.
InviPromotionName - the one with Invisible = true.

(you can/even should change names, but remember to change them in LUA as well)

Unfortunately, I wasn't able to test it in game.
 
This piece of code is adding promotion to units with certain promotion, when they set forest plot.

Invisible is based on Submarines' one. Submarines are still quite easily detected.

It is quite hard to check if working at all (how it works, if works, on land units?).

First, check if code is properly adding promotion (just enter this unit on forest, make sure promotion icon is visible).

Second, pick Americanos and observe enemy civilization (i would add this promotion to warriors, so you can check everything in one game), map should have enough forest to not make you bored, but not too much, to make you easily observe.

I was expecting, invisible for land units to be some kind of counter against ranged attacks. I am afraid city is also detecting invisible units. Iirc in vanilla, you had to enter tile with submarine to detect it, now it is already detected if adjancent. You can even display the unit range movement and it will disable the tile with submarine even if not visible...

@Edit
Just checked Civ5UnitPromotions.xml:
You have to add:
Code:
			<Invisible>INVISIBLE_SUBMARINE</Invisible>
instead true. It seems that you can make your own "InvisibleType" if you want. (Edit2: Nope, you can't without recompile DLL...)
 
Back
Top Bottom