Craig_Sutter
Deity
Sorry for a delayed response. I've instituted some of the ideas suggested. I usually do use print to find errors, however, I am not certain how to use print to determine if "SetDeployFromOperationTurn(1); " or "AddTemporaryDominanceZone" are working properly. In any case, I have used "unit:SetXY()" to good effect... if the units teleport to where I intend, the code for other elements is likely working... and they do... I have also rationalized the if/for tabs. Not certain if I'm following the standard operational procedure for this... I simply matched the ends to the proper if/for statements.
So, I have set up code to jump a random number of combat units to a designated hex, and apply "SetDeployFromOperationTurn(1) " to each unit.
I have revealed the terrain and a clear path from those units to the target hex for "AddTemporaryDominanceZone".
I'm pretty certain the functions are being applied to the unit and player appropriately.
Only problem is... my units all head back home and not to the designated hex (which is a city).
Here is the code...
So why are the intended effects not occurring:
1) is a DoW necessary?
2) should the target hex not be a city?
3) should the units start closer to the target hex?
4) is "unit:SetDeployFromOperationTurn(1)" not in the correct sequence?
5) is "pHladir:AddTemporaryDominanceZone (53, 48);" not being applied correctly?
I'm going to continue to experiment with this code. I'll shuffle the order of application of unit characteristics and teleportation. I'll change the teleport hex to see if distance is a factor. I'll experiment with larger numbers of units. I hope I can see some unit movement towards the target hex.
I'll keep posted if I make some progress.
So, I have set up code to jump a random number of combat units to a designated hex, and apply "SetDeployFromOperationTurn(1) " to each unit.
I have revealed the terrain and a clear path from those units to the target hex for "AddTemporaryDominanceZone".
I'm pretty certain the functions are being applied to the unit and player appropriately.
Only problem is... my units all head back home and not to the designated hex (which is a city).
Here is the code...
Code:
function HladirAttackOnBamborough()
if Game.GetGameTurn() == 0 then
--set Hladir as player
local pHladir
for iPlayer=0, GameDefines.MAX_MAJOR_CIVS-1 do
local pHladir = Players[iPlayer]
if (pHladir:IsAlive() and not pHladir:IsHuman()) then
if (GameInfo.Civilizations.CIVILIZATION_SONGHAI.ID == pHladir:GetCivilizationType()) then
-- loop through Hladir units and find combaat units
-- select half of those units, embark, and teleport them
-- add that unit to operation
for unit in pHladir:Units() do
if (unit:IsCombatUnit()) then
if (Game.Rand(100, "Selecting attack unit") < 100) then
unit:SetEmbarked(true);
unit:SetXY(58, 39)
unit:SetDeployFromOperationTurn(1);
end
end
end
pHladir:AddTemporaryDominanceZone (53, 48);
end
end
end
end
end
Events.ActivePlayerTurnEnd.Add(HladirAttackOnBamborough)
So why are the intended effects not occurring:
1) is a DoW necessary?
2) should the target hex not be a city?
3) should the units start closer to the target hex?
4) is "unit:SetDeployFromOperationTurn(1)" not in the correct sequence?
5) is "pHladir:AddTemporaryDominanceZone (53, 48);" not being applied correctly?
I'm going to continue to experiment with this code. I'll shuffle the order of application of unit characteristics and teleportation. I'll change the teleport hex to see if distance is a factor. I'll experiment with larger numbers of units. I hope I can see some unit movement towards the target hex.
I'll keep posted if I make some progress.