add encounter_random_end_time function