Created
April 19, 2018 18:52
-
-
Save SydMontague/17f9ef023d8af44b63bd4e968a2410cb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void setFoodTimer() { | |
if(digimonLevel == 1) { // Fresh, next even hour | |
r2 = ((currentHour / 2) + 1) * 2 | |
if(r2 > 24) | |
r2 -= 24 | |
store(r2, 0x13849A) | |
} | |
else if(digimonLevel == 2) { // In-Training, next by 3 dividable hour | |
r2 = ((currentHour / 3) + 1) * 3 | |
if(r2 > 24) | |
r2 -= 24 | |
store(r2, 0x13849A) | |
} | |
else { // Everything else | |
for(i = 0; i < 8; i++) { // Loop over hunger times | |
hungerTime = hungerTimes[i]; | |
if(nextHungerHour >= currentHour) { // stored nextHungerHour is after the currentHour (-> new day) | |
if(nextHungerHour < hungerTime) { // hungerTime must be after nextHungerTime | |
store(hungerTime, 0x13849A) | |
break | |
} | |
} | |
else { // stored nextHungerHour is before currentHour (-> same day) | |
if(currentHour < hungerTime) { // hungerTime must be after currentHour | |
store(hungerTime, 0x13849A) | |
break | |
} | |
} | |
hungerTime = hungerTimes[i + 1] | |
if(hungerTime == -1 || i == 7) { // no time matched, so either nextHungerHour or currentHour is 23 | |
for(j = 0; j < 8; j++) { | |
hungerTime = hungerTimes[j] | |
if(currentHour < hungerTime) { | |
store(hungerTime, 0x13849A) | |
break | |
} | |
else { | |
hungerTime = hungerTimes[j + 1] | |
if(hungerTime == -1 || j == 7) { // still no match, use first time | |
hungerTime = hungerTimes[0] | |
store(hungerTime, 0x13849A) | |
break | |
} | |
} | |
} | |
break | |
} | |
} | |
} | |
if(calculatedNextFeed >= currentHour) | |
tmp = (calculatedNextFeed - currentHour) * 60 | |
else | |
tmp = (24 - currentHour + calculatedNextFeed) * 60 | |
store(tmp, 0x13849E) | |
if(currentMinute == 0) | |
return | |
store(tmp - currentMinute, 0x13849E) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment