User talk:Lisselli

Revision as of 02:44, 11 May 2017 by imported>Lisselli
Function SetActorValueCap(Actor akActor, String asValueName, Float afValueCap = 100.0)
    ; Store the base and current value.
    Float BaseValue = akActor.GetBaseActorValue(asValueName)
    Float CurrentValue = akActor.GetActorValue(asValueName)
    
    ; Cap default is 100. If checking for attributes, adjust the desired cap accordingly.
       
        ; Check if the current value is over the cap.
        if (BaseValue <= afValueCap && CurrentValue > afValueCap)
           
            ;Unless the base is also over the cap, we\ll assume it\s not.
            akActor.ForceActorValue(asValueName, afValueCap)
        
        elseif BaseValue > afValueCap && CurrentValue > BaseValue
            ; bring the base and current back down to the cap.
            BaseValue = BaseValue - (BaseValue - afValueCap)
            akActor.SetActorValue(asValueName, BaseValue)
            akActor.ForceActorValue(asValueName, afValueCap)
        else
            return
        endif
     
EndFunction
Return to the user page of "Lisselli".