if self.loseTimer then
ShowTimer(nil)
DestroyTimer(self.loseTimer)
self.loseTimer = nil
end
--clean up all the AIGoals for this objective
if self.AIGoals then
for i, goalPtr in ipairs(self.AIGoals) do
DeleteAIGoal(goalPtr)
end
end
--play a little ditty
if not self.multiplayerRules then
BroadcastVoiceOver("common_objComplete", self.winningTeam)
end
--delay the actual objective end by a smidge to allow time for the ditty to finish playing
--(since the designers tend to call other voiceovers from OnComplete)
self.dittyTimer = FindTimer("dittyTimer")
if not self.dittyTimer then
self.dittyTimer = CreateTimer("dittyTimer")
end
SetTimerValue(self.dittyTimer, 1.0)
StartTimer(self.dittyTimer)
self.dittyTimerResponse = OnTimerElapse(
function(timer)
--update the objective's state in the c++ code
if self.text then
CompleteObjective(self.text)
else
if self.textATT then
CompleteObjective(self.textATT)
end
if self.textDEF then
CompleteObjective(self.textDEF)
end
end
if self.container then
self.container:NotifyObjectiveComplete(self)
else
MissionVictory(winningTeam)
end