Is this possible?

KennyTG

Chieftain
Joined
May 26, 2014
Messages
45
I'm working on a civilization and I want part of their UA to be that after x number of turns or researching a certain technology they gain a large group of units (multiple copies of the same unit). Also is it possible to do something like this based on the progress of another civilization or the era that the majority of civilizations are in?

I'd prefer to do this in xml, but if it's not possible in xml then I can venture into lua coding.

Thanks.
 
What I meant about "based on the progress of another civilization" was either you made a DOF with that civ or the majority of civs had reached a certain tech level.
 
Essentially what I want to do is when someone enters the medieval era x number of units spawn for the civilization I'm creating.
 
Here it is:

Code:
local bGiveUnits = true

function GiveUnitsMedieval(eraID, iPlayer)
	if eraID == 2 then
		for i = 0, GameDefines.MAX_MAJOR_CIVS-1, 1 do
			local pPlayer = Players[i]
			if pPlayer:GetCivilizationType() == GameInfoTypes["CIVILIZATION_[B]YOURCIV[/B]"] and bGiveUnits == true then
				bGiveUnits = false
				local pCapital = pPlayer:GetCapitalCity()
				u = 1
				while u <= 3 do -- number of units
					local pUnit = pPlayer:InitUnit(GameInfoTypes.UNIT_WORKER, pCapital:GetX(), pCapital:GetY()) -- here instead of 'UNIT_WORKER' you put whatever is the unit you want
					pUnit:JumpToNearestValidPlot()
					u = u + 1
				end
			end
		end
	end
end
Events.SerialEventEraChanged.Add(GiveUnitsMedieval)

It gives units the turn AFTER someone advances to the Medieval Era, but apparently that's a limitation of the code (someone more versed in coding may be able to do something about it), so unless you use WHoward's DLL, that's the best I can do.

All you have to do for this to work is to edit the "YOURCIV" to your Civilization and tweak the number and Unit you want to spawn.


Also, I'm not from the US. Happy 4th. :)
 
Thanks again bane. I'm fine with it happening the turn after the medieval era.
 
I can't seem to get it to work. I'm new to using lua in modding. I've tried changing the VFS from "false" to "true", etc. Do I need an xml to accompany the lua? What should that xml look like?
 
this tutorial shows you what settings are required for each type of file.

In your case it wil lbe a VFS=false and a 'InGame UIAddin' as shown how to do by whoward in the tutorial. You don't need an additional XML file to get this type of lua to function.
 
Thanks LeeS. I had tried that earlier, but I didn't know I could just type the name of my file in.
 
Top Bottom