Lua trickery

AW Arcaeca

Deus Vult
Joined
Mar 10, 2013
Messages
2,984
Location
Operation Padlock ground zero
^ Title says it all.

I'd like to be able to make a boat unique unit which can then disembark onto land to become, essentially, a worker that can found one city. (I'll do stuff to nerf its abilities, don't worry).

Now JFD did something of this ilk in his alternate Carthage, with the Shophet unique GG becoming a GA upon embarking and vice versa, but the catch is that the disembarkation of the GA turning into a GG has to occur in a city.
See the problem here? If I used the same method the UU would have to "disembark" in a city... that doesn't exist yet because it hasn't been built by the UU!

So what I'm wondering is, is it possible to make a new unit mission for specifically this unit, which would turn that boat into an embarked worker/settler? bane_ already taught me the basics of making a mission, so really the question is, can you InitUnit and automatically set it to an embarked state or something? Or is there a cleaner way to do this?

I don't expect the AI to have any clue how to work it. :p
TIA,
AW
 
Based on your description, what was done was most likely achieved by using two units and killing one to spawn the other under certain circumstances. There was a Great Admiral and a Great General. If the General entered the water (there are a few indirect ways to detect this) the general would be killed and an Admiral spawned. If the Admiral entered a city, it would be killed and a General spawned.

The problem is the water->land transition. Only embarked land units can move onto land. The problem is embarked units can not attack. You could give the unit embark defense and amphibious to make it hard for naval units to kill it and make it able to effectively attack from sea, but it wouldn't be able to fight other naval units.
 
I'm not sure I follow. The unit resulting from the disembarkation is a worker/settler, no? Why does it need to be able to attack? :confused:
(For the record, the naval UU in question would replace a work boat, so it doesn't need to be able to attack anything either. Basically, I just wasn't aware that attacking would be any concern.)

And yes, I was planning to make, say, UNIT_XYZ_SEA and also UNIT_XYZ_LAND. XYZ_SEA would have an entry in <Civilization_UnitClassOverrides> and XYZ_LAND would simply have Cost = -1.

The reason JFD gave for the Shophet only being able to disembark in cities while in admiral mode was that as an admiral it is a naval unit, and ships can't move onto land, except into cities.

I guess what I was concerned about is... upon activating the mission, XYZ_SEA would be sneakily killed and XYZ_LAND would take its place... except for then, in the split second before the computer receives the command to embark XYZ_LAND, we have a non-embarked land unit on an ocean tile. I was wondering if that would make the game engine implode or something. :p
 
Isn't it easier to give to the embarked unit work boat abilities then? I believe samurai can do that.
 
Isn't it easier to give to the embarked unit work boat abilities then? I believe samurai can do that.
That's a BNW only ability. I do G&K modding, but which is also compatible with BNW.

AHg I just realized - the settler gets its "found city ability" from the XML line <Found>, so it's not like a Build that I can just replicate and remove <Kill>true</Kill> from. :cringe: I guess I'll have to make a second ability that will allow the unit to build a city (or more technically, plop down a city on the tile that the unit happens to be standing on) and then be unable to use the mission again?

And while I'm at it, optimally the unit should only be able to found a city on a continent other than the capital, sort of like the conquistador. Does anyone know how to detect continents?
 
That's a BNW only ability. I do G&K modding, but which is also compatible with BNW.

AHg I just realized - the settler gets its "found city ability" from the XML line <Found>, so it's not like a Build that I can just replicate and remove <Kill>true</Kill> from. :cringe: I guess I'll have to make a second ability that will allow the unit to build a city (or more technically, plop down a city on the tile that the unit happens to be standing on) and then be unable to use the mission again?

And while I'm at it, optimally the unit should only be able to found a city on a continent other than the capital, sort of like the conquistador. Does anyone know how to detect continents?
Haven't thought through the rest of it but as part of the unit's Build City mission you could add a promo to it that would act as a marker that this particular unit has already performed the mission once, so disable the mission any further for that particular unit.
 
Haven't thought through the rest of it but as part of the unit's Build City mission you could add a promo to it that would act as a marker that this particular unit has already performed the mission once, so disable the mission any further for that particular unit.
Noted; A promotion is factored into the mission except kind of backwards as you describe - the promotion is what allows the unit to perform the mission in the first place and then it gets removed.
The mission uses Player.InitCity() - can anyone confirm that this works?
 
Top Bottom