Anyone know how to spawn unit?

Ahah! When I changed it so that both processes weren't trying to make exactly the same type of unit the error message went away. Strange, because I thought that the game supported units stacking upon creation, unless there's some sort of exception made for Scythia.
 
what the dll will do and what lua will do are not always the same. The Venetian Arsenal also plops two units on the same plot as I recall. Ventian Arsenal and Scythia Horses thing are handled entirely at the dll level.

I started with the assumption I could not place two units of the same "formation" on the same plot as a safety measure because in civ5 if there was already a unit on a given plot, and it belonged to a player who was at war with the player for whom you were about to plop a unit, the enemy unit would go *poof* as part of the process of placing the new unit on the tile. In civ5 if the plot was also a city, this could cause city ownership to swap if the two players were at war. I created this for civ5 because of all of Civ5's limitations and idiosyncracies with creating units: https://forums.civfanatics.com/threads/unit-spawn-handler-lua.548792/
 
Last edited:
Interesting. It doesn't appear to be about a unit of the same type being in the same place. To me it seems to be some conflict associated with trying to make two units of the same type at the same time. It seems plausible that they wouldn't even have to be in the same place to create the error.
 
I make multiple settler units one after another, but I don't place them in the same tile. Their FormationClass would match and therefore cause possible problems when placed on the same tile. But I can place a Scout or a Warrior on the same tile as a pre-existing settler or worker because in this case the FormationClass does not match between the two units. Have you tried placing two land combat units of differing type on the same plot (such as Warrior and Slinger ?). I've always avoided these issues entirely because of the possibilities of the game not liking it in numerous crash-worthy sorts of ways,
 
Have you tried placing two land combat units of differing type on the same plot
I'm not sure.

I wonder if the issue here is that Lua code and the DLL/executable run asynchronously with each other leaving an opening for conflicts if they're trying to do the same thing at the same time.
 
I've tried placing units of the same formation class on the same plot, using LUA functions, and the game reacts just fine. However, I do have my PlotUnitLimit set to 3, and I have not tried it with the default PlotUnitLimit. Additionally, I've tried using UnitManager.MoveUnit and UnitManager.PlaceUnit to move a unit to a specific plot, while just before effecting the move, placing a foreign unit on the same plot (I thought I'd see if I could initialize combat): In other words, forcing units of two different players to occupy the same plot, and the functions work without a hitch -- provided that the two players are not at war. If the two players are at war at the time of the attempted move, the unit being moved does not move to occupy the same plot as the enemy unit.
 
P.S. I also have tried creating units of the same type on the same plot, and there is no problem. The functions fire without a problem. So, I don't think there is any issue with placing any number of units (in fact, I've placed up to 10 and more units of the same type on the same plot at the same time) of any type or formation on any given plot using LUA. The regular XML limitations of PlotUnitLimit do not seem to apply.
 
Back
Top Bottom