[NEED HELP] Simple Fatigue Script

Need help with this Module OnHeartbeat event script. I can’t figure out how to make it index to the next day with the check.

void rs_DoFatigue(object oTarget)
{
    effect eCon  = EffectAbilityDecrease(ABILITY_CONSTITUTION, 1);
    effect eDur  = EffectVisualEffect(VFX_DUR_CESSATE_NEGATIVE);
    effect eLink = EffectLinkEffects(eCon, eDur);

    ApplyEffectToObject(DURATION_TYPE_PERMANENT, eLink, oTarget);
}


void main()
{
    object oPC = GetFirstPC();

    //Check for time lapse since last rest - if more than 24 hours, fatigue them
    int nLastRest = GetLocalInt(oPC, "LAST_RESTED");
    if ( (GetTimeHour() - nLastRest) > 24 )
    {
        FloatingTextStringOnCreature("I should rest.", oPC);
        rs_DoFatigue(oPC);
    }
}

I know this code doesn’t work because the value of GetTimeHour() - which is stored on the PC in the OnPlayerRest script is 0-23.

A function like this:

// Return the current time in hours
int bhHour() {return ((GetCalendarYear() - 1) * 12 * 30 * 24) + ((GetCalendarMonth() - 1) * 30 * 24)
                   + ((GetCalendarDay() - 1) * 24) + GetTimeHour();}

returns the time in hours since the Current Era began.

If you store that value, you can compare it with the latest value, to see whether the difference is greater than 24.

3 Likes