Mikoto Misaka
Chieftain
- Joined
- Nov 11, 2019
- Messages
- 4
I try it
and also try it
but it is not working.
Can you give me some advice?
Code:
INSERT INTO Types
(Type, Kind)
VALUES ('MODIFIER_NEWLEADER_CAPITAL_CITY_GRANT_UNIT_IN_CITY', 'KIND_MODIFIER'),
('NEWLEADER_TRAIT_NEWUNIT', 'KIND_TRAIT') ;
INSERT INTO DynamicModifiers
(ModifierType, CollectionType, EffectType)
VALUES
('MODIFIER_NEWLEADER_CAPITAL_CITY_GRANT_UNIT_IN_CITY', 'COLLECTION_PLAYER_CAPITAL_CITY','EFFECT_GRANT_UNIT_IN_CITY'),
INSERT INTO Modifiers
(ModifierId, ModifierType, RunOnce, Permanent, SubjectRequirementSetId)
VALUES
('TRAIT_LEADER_NEWLEADER_SEND_NEWUNIT', 'MODIFIER_NEWLEADER_CAPITAL_CITY_GRANT_UNIT_IN_CITY', 0, 0, NULL) ,
INSERT INTO ModifierArguments
(ModifierId, Name, Value)
VALUES
('TRAIT_LEADER_NEWLEADER_SEND_NEWUNIT', 'UnitType', 'UNIT_NEWUNIT'),
('TRAIT_LEADER_NEWLEADER_SEND_NEWUNIT', 'Amount', 1),
Code:
local numNEWUNIT = 1 --------------------------------------------set number of extra starting scouts
local iNEWUNIT = GameInfo.Units["UNIT_NEWUNIT"].Index -----------------set unit
function OnPlayerTurnActivated( player, bIsFirstTime )
local currentTurn = Game.GetCurrentGameTurn();
local SpawnTurn = 0;
local playerUnits;
local adjacentPlot;
local unitPlot;
if currentTurn == GameConfiguration.GetStartTurn() then
local pPlayer = Players[player]
if pPlayer:IsHuman() then
playerUnits = pPlayer:GetUnits()
for i, unit in playerUnits:Members() do
local unitTypeName = UnitManager.GetTypeName(unit)
if "LOC_UNIT_NEWUNIT_NAME" == unitTypeName then
SpawnTurn = 1;
unitPlot = Map.GetPlot(unit:GetX(), unit:GetY());
end
end
end
if SpawnTurn == 1 then
local lastPlot = unitPlot;
if numNEWUNIT> 0 then
for i = 1, numNEWUNIT do
for direction = 1, DirectionTypes.NUM_DIRECTION_TYPES - 1, 1 do
adjacentPlot = Map.GetAdjacentPlot((lastPlot:GetX() + 1), lastPlot:GetY(), direction);
if (adjacentPlot ~= nil) and not (adjacentPlot:IsWater() or adjacentPlot:IsImpassable()) then
break
end
end
pUnit = playerUnits:Create(iNEWUNIT, unitPlot:GetX(), unitPlot:GetY())
lastPlot = Map.GetPlot(pUnit:GetX(), pUnit:GetY());
end
end
function Initialize()
Events.LocalPlayerChanged.Add( OnPlayerTurnActivated );
Events.PlayerTurnActivated.Add(OnPlayerTurnActivated);
end
Initialize();
Can you give me some advice?