Objective.setProgress 45
Set the conquer progress of the Scripted Mission Objective. Just like any other Mission Objective property, it doesn't work with Conquer Area Objective, or any other Vanilla objective type, but only with Scripted Mission Objective spawned with spawnMissionObjective call.
Notice: When all the objectives in a Mission Phase are completed (progress = 1) the Next Phase is automatically triggered
Return value
Return Type | Description |
---|---|
void | This function doesn't return anything |
Parameters
Parameter | Type | Description |
---|---|---|
1 | float | Set the progress of the objective capture (Value in the [0,...,1] range. |
Examples
Example of a mission objective that spawns a vehicle and an objective, and waits for the vehicle to be destroyed in order to progress to the next phase (network safe)
local VEHICLE_ID = "Flak38 AA"
local SPAWN_POS = vec3(0, 2, 0)
local SPAWN_ROT = vec3(0, 90, 0)
local OBJECTIVE_TEXT = "Destroy Flak 38"
local OBJECTIVE_ICON = 4
-- network initialize vehicle and objectives and save their ids
if not global.get("target_initialized") then
if er2.isMasterClient() then
local objective = spawnMissionObjective(SPAWN_POS, 20, "Destroy Flak 38", 2, true)
global.set(objective.getUniqueId(), "target_objective")
local vehicle = spawnVehicle(VEHICLE_ID, SPAWN_POS, SPAWN_ROT)
global.set(vehicle.getUniqueId(), "target_vehicle")
log(vehicle.getUniqueId())
end
global.set(true, "target_initialized")
end
-- acquire the vehicle and objective variables - network safe (either spawned by me or previous master client)
local vehicle = er2.findVehicle(global.get("target_vehicle"))
local objective = er2.findObjective(global.get("target_objective"))
local phaseCompleted = false
while not phaseCompleted do
sleep(3) -- goot for performance
if vehicle and objective then -- make sure they still exists
if vehicle.isDestroyed() then -- nice
objective.complete()
phaseCompleted = true
else
-- update objective position to follow the vehicle
objective.setPosition(vehicle.getPosition())
end
else
-- if they don't exists anymore for whatever reason, cosnider the phase complete
log("Skipping phase because objective or vehicle can't be found anymore!")
phaseCompleted = true
end
end
print ("The Flak have been destroyed!")
sleep(3)
if er2.isMasterClient() and objective then
objective.setProgress(1)
end
Simple objective spawn and progress update
-- spawn the objective at pos 0,2,0 with radius 30, text "Example objective", icon Id 1 (see setIcon function), and Ai set to attack the area
local objective = spawnMissionObjective(vec3(0,2,0), 30, "Example objective", 1, true)
-- do something here...
-- set the objective as completed (when all objectives are completed, next phase is automatically triggered)
objective.setProgress(1)