Like in castle fight I'm making a build continuously train units back to back as they finish. The spawner's supposed to be able to upgrade as well. When the spawner first finishes being built a unit is queued up to train perfectly, when it finishes though the upgrade ability is permanently grayed out. The triggers are pretty simple so I don't know why this is happening.
Here the triggers, I wrote them in JASS since typing > clicking. There simple triggers though, nothing complex. The first trigger handles adding the spawners to a unit group and train the initial unit. The second trigger handles the continuation of training. Since the upgrade greys out after a unit finishes I'm guessing it has to do with the second triggers. The "most important variable" is set to the number of types of spawners and udg_TrainBuilding[], udg_TrainUnits[] are set elsewhere.
Here the triggers, I wrote them in JASS since typing > clicking. There simple triggers though, nothing complex. The first trigger handles adding the spawners to a unit group and train the initial unit. The second trigger handles the continuation of training. Since the upgrade greys out after a unit finishes I'm guessing it has to do with the second triggers. The "most important variable" is set to the number of types of spawners and udg_TrainBuilding[], udg_TrainUnits[] are set elsewhere.
JASS:
function Trig_BuildingTrain_Group_Actions takes nothing returns nothing
local integer temp = -1
local integer temptype = GetUnitTypeId(GetConstructedStructure())
loop
set temp = temp + 1
exitwhen (temp == udg_MOSTIMPORTANTVARIABLE) or (temptype == udg_TrainBuilding[temp])
endloop
if(not(temptype == udg_TrainBuilding[temp])) then
//call DisplayTextToForce(GetPlayersAll(), "Your most important variable is WRONG.")
else
call GroupAddUnit(udg_SpawnBuildings, GetConstructedStructure())
call IssueTrainOrderByIdBJ(GetConstructedStructure(),udg_TrainUnits[temp])
endif
endfunction
//===========================================================================
function InitTrig_BuildingTrain_Group takes nothing returns nothing
set gg_trg_BuildingTrain_Group = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_BuildingTrain_Group, EVENT_PLAYER_UNIT_CONSTRUCT_FINISH )
call TriggerAddAction( gg_trg_BuildingTrain_Group, function Trig_BuildingTrain_Group_Actions )
endfunction
JASS:
function Trig_BuildingTrain_Possible_Fix_Actions takes nothing returns nothing
local integer temp = 0
local integer temp2 = -1
if(IsUnitInGroup(GetTriggerUnit(), udg_SpawnBuildings)) then
//call DisplayTextToForce(GetPlayersAll(), GetUnitName(GetTriggerUnit()))
loop
set temp2 = temp2 + 1
set temp = udg_TrainBuilding[temp2]
exitwhen (temp2 == udg_MOSTIMPORTANTVARIABLE) or (temp == GetUnitTypeId(GetTriggerUnit()))
endloop
call IssueImmediateOrderById(GetTriggerUnit(),udg_TrainUnits[temp2])
endif
endfunction
//===========================================================================
function InitTrig_BuildingTrain_Possible_Fix takes nothing returns nothing
set gg_trg_BuildingTrain_Possible_Fix = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_BuildingTrain_Main, EVENT_PLAYER_UNIT_TRAIN_FINISH )
call TriggerAddAction( gg_trg_BuildingTrain_Possible_Fix, function Trig_BuildingTrain_Possible_Fix_Actions )
endfunction