Set All DeathWish Objects to Fail (and reset when restarting)

#Code

A quicky and effective function that should help in making it easier for those who are creating a Deathwish without the need of failing each objective.

Set All DeathWish Objects to Fail (and reset when restarting)

[RAW] [Download]

// Simply call FailAllObjectives(); when a condition occurs to fail all objectives, call this again with false being passed in the parameter to restore all failed objectives when the map is restarted.
function FailAllObjectives(optional bool fail = true)
{
    local Class<Hat_SnatcherContract_DeathWish> contract;
    local Array< class < Hat_SnatcherContract_DeathWish > > ActiveDeathWishes;
    local int i;
 
    ActiveDeathWishes = class'Hat_SnatcherContract_DeathWish'.static.GetActiveDeathWishes();
 
    foreach ActiveDeathWishes(contract)
    {
        for(i = 0; i < contract.default.Objectives.Length; i++)
            contract.static.SetObjectiveFailed(i, fail);
    }
}
 
// Fails all objectives
FailAllObjectives();
FailAllObjectives(true); // keep in mind the parameter value is already specified as true
 
// Restores all failed objectives back to normal
FailAllObjectives(false);