ModObjectiveGlobal - Quest
Revision as of 07:42, 29 June 2013 by imported>Thingy Person (→Syntax: This is a non-native function, so why not put the whole thing here?)
Member of: Quest Script
Mods a global variable in a threadsafe way. Optional parameters allow automatic redisplay and completion (or failure) of a quest objective using this global variable.
Syntax
bool Function ModObjectiveGlobal(float afModValue, GlobalVariable aModGlobal, int aiObjectiveID = -1, float afTargetValue = -1.0, bool abCountingUp = true, bool abCompleteObjective = true, bool abRedisplayObjective = true)
aModGlobal.Mod(afModValue)
UpdateCurrentInstanceGlobal(aModGlobal)
if aiObjectiveID >= 0
; display/complete objectives automatically
if afTargetValue > -1
if (abCountingUp && aModGlobal.value >= afTargetValue) || (!abCountingUp && aModGlobal.value <= afTargetValue)
if (abCompleteObjective)
; complete objective
SetObjectiveCompleted(aiObjectiveID)
return true
Else
; fail objective
SetObjectiveFailed(aiObjectiveID)
return true
Endif
elseIf (abRedisplayObjective)
; redisplay objective
SetObjectiveDisplayed(aiObjectiveID, true, true)
Else
SetObjectiveDisplayed(aiObjectiveID, true, false)
endif
elseIf (abRedisplayObjective)
; no target value, always redisplay objective
SetObjectiveDisplayed(aiObjectiveID, true, true)
Else
SetObjectiveDisplayed(aiObjectiveID, true, false)
endif
endif
return false
endFunction
Parameters
- afModValue: The value to add to aModGlobal
- aModGlobal: The global variable we are modifying
- aiObjectiveID: ObjectiveID to redisplay whenever this function is called.
- Default: -1 (no objective)
- afTargetValue: Value you're counting up (or down) towards -- if you pass in a non-negative number, function will return TRUE when the global reaches the target value
- Default: -1.0 (no target value)
- abCountingUp: True to count up to target value, false to count down
- Default: true
- abCompleteObjective: True to complete the objective when target value is reached, false to fail the objective.
- Default: true
- abRedisplayObjective: True to re-display the objective every time the function is called, false to only show on success/failure.
- Default: true
Return Value
True, if there is a target value and the global value reaches the target value.
Examples
; Adds 1 to MyGlobal
MyQuest.ModObjectiveGlobal(1, MyGlobal)
; Adds 1 to MyGlobal, updates objective 10
MyQuest.ModObjectiveGlobal(1, MyGlobal, 10)
; adds 1 to ExteriorDefenderDeadCount, updates objective 30, sets stage 60 when it reaches ExteriorDefenderTotal
if MyQuest.ModObjectiveGlobal(1, ExteriorDefenderDeadCount, 30, ExteriorDefenderTotal.value)
SetStage(60)
endif