Man muß dafür einen Heli mit Namen "test" haben und eine Inf Gruppe mit Namen "pickup" und einer Einheit in dieser mit Namen "pickup". Dann kann das Skript initialisiert werden, am besten, so daß man es mehrmals ausführen kann, z.B. mit der F-10 Operation die die Flagge 902 auf true setzt und so die Infantrie Gruppe anfordert den Heli zu besetzen.
Nähert man sich der Infantriegruppe, poppt diese grünen Rauch. Wenn man dann in der Nähe landet, kommt die Gruppe zum Heli und steigt ein (natürlich nicht wirklich, sie verschwindet und eine Flagge wird gesetzt, die später genutzt werden kann um einen vollen Heli zu simulieren).
Manchmal muß man die Infantrie mit der F-10 Option mehrmals rufen, bis sie sich durchringt zum Heli zu kommen da die AI nicht immer sehr zielstrebig ist. Ich arbeite noch einem Skript mit dem man dann die Infantrie an beliebiger Stelle wieder absetzen kann und in einer vordefinierte Zone schicken kann, aber erstmal dieser Schnipsel:
Code: Alles auswählen
--create F10 options for flag 902 to request to pick up troops
--script should be called by scwitched condition / flag 902, which is initialized by F-10 menu
--create a group with the name "pickup" and the first unit name "pickup"
--create a heli with unit name "test"
local inf = Unit.getByName('pickup') --unit name of 1ste unit of pickup group
local infgroup = Group.getByName('pickup') --groupname of troops to be pickedup
local heli = Unit.getByName('test') --unit name of transport heli
local heligroup = Group.getByName('test') --group name of transport heli
mist.flagFunc.units_in_moving_zones
{
units = {"pickup"},
zone_units = {"test"},
radius = 200,--distance to call infantry
flag = 903,
stopflag = 4
}
local helipos = heli:getPosition().p
local heliagl = helipos.y - land.getHeight({x = helipos.x, y = helipos.z}) - 1.5
local helivel = heli:getVelocity()
local abshelivel = math.abs(helivel.x) + math.abs(helivel.y) + math.abs(helivel.z)
function main()
if (trigger.misc.getUserFlag(902) > 0 and trigger.misc.getUserFlag(903) > 0)
then
local infpos = inf:getPosition().p
trigger.action.smoke({x=infpos.x + math.random(5,10), y=infpos.y-2, z=infpos.z + math.random(5,10)}, trigger.smokeColor.Green)
if (abshelivel > 1)
then
trigger.action.outTextForGroup(Group.getID(heligroup), string.format("Slow down"), 10)
end
if (heliagl > 1)
then
trigger.action.outTextForGroup(Group.getID(heligroup), string.format("Get lower"), 10)
end
if (heliagl <= 1 and abshelivel <= 1)
then
trigger.action.outTextForGroup(Group.getID(heligroup), string.format("Troops are embarking, hold position!"), 10)
trigger.action.setUserFlag('904', true) --Flag 1004 indicates troops can embark
local getin =
{
group = Group.getByName('pickup'),
point = {y = helipos.y, x = helipos.x, z = helipos.z},
radius = 1,
form = "Diamond",
speed = 10,
disableRoads = 1
}
mist.groupToRandomPoint(getin)
mist.flagFunc.units_in_moving_zones --creating zone to trigger that troops embarked
{
units = {"test"},
zone_units = {"pickup"},
radius = 20, --distance at which infanty embark
flag = 905,
stopflag = 906,
req_num = 1
}
end
else
trigger.action.outTextForGroup(Group.getID(heligroup), string.format("You are too far away from LZ!"), 10)
trigger.action.setUserFlag('902', false) --initial trigger set false again
end
if (trigger.misc.getUserFlag(904) > 0 and trigger.misc.getUserFlag(905) > 0)
then
infgroup:destroy()
trigger.action.setUserFlag('906', true) --Flag 1006 indicates troops are on board
trigger.action.outTextForGroup(Group.getID(heligroup), string.format("All troops on board!"), 10)
mist.removeFunction(funcID)
end
end
local funcID = mist.scheduleFunction(main, {}, timer.getTime() + 10, 120)