at first i want to say thanks for the help got here =)
I want to order all idle workers to start mining on the ressource field that is the nearest to each one.
But it throws me an error that it need a targed (but i give targed -> UnitFromId(10) (wich is a mineral field placed with terrain editor, later i want to make this be the nearest mineral field to the unit "UnitGroupLoopCurrent()").
whats the issue here? =)
Edit: now i made a supersimplified variant:
UnitIssueOrder(UnitFromId(19), OrderTargetingItem(AbilityCommand("SCVHarvest", 0), UnitFromId(10)), c_orderQueueReplace);
and it still not working :(
UnitFromId(19) is a scv placed with the editor and UnitFromId(10) is a mineral field
at first i want to say thanks for the help got here =)
I want to order all idle workers to start mining on the ressource field that is the nearest to each one.
Thats my code:
while (!UnitGroupLoopDone()) {
UnitIssueOrder(UnitGroupLoopCurrent(), OrderTargetingItem(AbilityCommand("SCVHarvest", 0), UnitFromId(10)), c_orderQueueReplace);
UnitGroupLoopStep();
}
UnitGroupLoopEnd();
But it throws me an error that it need a targed (but i give targed -> UnitFromId(10) (wich is a mineral field placed with terrain editor, later i want to make this be the nearest mineral field to the unit "UnitGroupLoopCurrent()").
whats the issue here? =)
Edit: now i made a supersimplified variant:
UnitIssueOrder(UnitFromId(19), OrderTargetingItem(AbilityCommand("SCVHarvest", 0), UnitFromId(10)), c_orderQueueReplace);
and it still not working :(
UnitFromId(19) is a scv placed with the editor and UnitFromId(10) is a mineral field
Correct me if I'm wrong but isn't a Mineral Field a Unit, not an Item?
so then the interface is using the wrong datatype for this?
it want me to return a unit.
well i did it now this way: If someone else is every searching for this problem:
UnitGroupLoopBegin(UnitGroupIdle(1, true));
while (!UnitGroupLoopDone()) {
if ((UnitGetType(UnitGroupLoopCurrent()) == "SCV")) {
UnitIssueOrder(UnitGroupLoopCurrent(), OrderTargetingUnit(null, libNtve_gf_ClosestUnitToPoint(UnitGetPosition(UnitGroupLoopCurrent()), UnitGroup("MineralField", c_playerAny, RegionEntireMap(), UnitFilter(0, 0, 0, 0), 0))), c_orderQueueReplace);
}
UnitGroupLoopStep();
}
in this case the scv only harvesting mineralfield (not on highyield minerals or gas), but for me its what i wanted :)