En gros, tu sauves le script suivant dans un fichier que tu appelles genShilka.lua, et ce fichier doit être executé par un trigger 2s après le lancement de la mission. Regarde ici pour un exemple (le fichier s'appelle baksan.lua mais c'est pareil):
http://wiki.3rd-wing.net/index.php?titl ... 3.A9diteur
Dans l'éditeur, tu définies des zones 'trigger areas' dont le nom commence par
shilka, donc shilka1, shilka2, autant que tu en veux. Le script génèrera le shilka dans un endroit aléatoire pris dans une des zones dont le nom commence par 'shilka'.
Je n'ai pas testé le script car recomposé vite-fait à la main, je vais le faire comme ça tu auras un truc qui marche, mais l'idée est là: c'est comme ça que sont faites les missions CSAR typiquement, car si le concepteur participe au vol et sait où il a placé le mec à aller chercher... ça n'a plus d'interêt !
Code : Tout sélectionner
--------------------------
-- Unique ID generation --
--------------------------
generatedUnitsNb = 100
function getGenerationId()
generatedUnitsNb = generatedUnitsNb + 10
return generatedUnitsNb
end
function getRandomLocationInPrefixedZones(prefix)
local prefixedZones={}
for zoneName, zone in pairs(mist.DBs.zonesByName) do
if (string.find(zoneName, "^"..prefix..".*")) then
table.insert(prefixedZones,zone)
end
end
if table.getn(prefixedZones) == 0 then
return nil
end
local chosenZone = prefixedZones[math.random(#prefixedZones)];
local result = {}
result.x = chosenZone.point.x + math.random(chosenZone.radius * -1, chosenZone.radius)
result.z = chosenZone.point.z + math.random(chosenZone.radius * -1, chosenZone.radius)
return result
end
function getAAAGroup(chosenUnit, chosenSkill, chosenForce, chosenLocation)
local unitId = getGenerationId()
local data = {
["visible"] = false,
["groupId"] = unitId,
["tasks"] =
{
},
["hidden"] = false,
["units"] = getAAAUnit(unitId, chosenUnit, choseSkill, chosenForce, chosenLocation),
["y"] = chosenLocation.y,
["x"] = chosenLocation.x,
["name"] = chosenUnit.." - "..unitId,
}
return data
end
function getAAAUnit(unitId, chosenUnit, chosenSkill, chosenForce, chosenLocation)
local units = {}
for i=1, chosenForce do
LastGeneratedGroundUnitId = unitId+i
units[i] = {
["type"] = chosenUnit["name"],
["y"] = chosenLocation.y,
["x"] = chosenLocation.x,
["name"] = chosenUnit..unitId..i,
["heading"] = math.random(360),
["unitId"] = unitId+i,
["skill"] = chosenSkill,
["playerCanDrive"] = true,
}
end
return units
end
unitsSkills = {
'average',
'good',
'excellent'
}
local chosenSkill = unitsSkills[math.random(#unitsSkills)];
local chosenForce = 1
local chosenLocation = getRandomLocationInPrefixedZones('shilka')
coalition.addGroup('RUSSIA', Group.Category.GROUND, getAAAGroup('ZSU-23-4 Shilka', chosenSkill, chosenForce, chosenLocation))