mirror of
https://github.com/nacabaro/nacapet.git
synced 2026-01-27 16:05:32 +00:00
Cositas:
- Habia un problema a la hora de los temporizadores del hambre y la fuerza - Se me ha vuelto a romper la pantalla, asi que meti un mini hack para que funcione una pantalla de menor resolucion - Añadida la mecanica del overfeed (la tengo que probar, no se siva) - Añadida la mecanica de interrupción de suelo (esta, si que debería de funcionar, pero hasta que no consiga funcionar el cambio de bicho aqui no se prueba na) COMO CAMARÓN
This commit is contained in:
parent
b35ff2d1b2
commit
43c10d02f5
@ -69,19 +69,19 @@ def process_npet_file(origFp, eggFp, outputName):
|
||||
charaReductionTime = int(matches[0][11], 16)
|
||||
charaMinWeight = int(matches[0][12], 16)
|
||||
|
||||
destFp.write(charaId.to_bytes(1, "big"))
|
||||
destFp.write(charaId.to_bytes(1, "little"))
|
||||
destFp.write(charaName)
|
||||
destFp.write(charaHp.to_bytes(1, "big"))
|
||||
destFp.write(charaBp.to_bytes(1, "big"))
|
||||
destFp.write(charaAp.to_bytes(1, "big"))
|
||||
destFp.write(charaStage.to_bytes(1, "big"))
|
||||
destFp.write(charaAttribute.to_bytes(1, "big"))
|
||||
destFp.write(charaAttackSprite.to_bytes(1, "big"))
|
||||
destFp.write(charaSleepTime.to_bytes(4, "big"))
|
||||
destFp.write(charaWakeupTime.to_bytes(4, "big"))
|
||||
destFp.write(charaEvolutionTime.to_bytes(4, "big"))
|
||||
destFp.write(charaReductionTime.to_bytes(2, "big"))
|
||||
destFp.write(charaMinWeight.to_bytes(1, "big"))
|
||||
destFp.write(charaHp.to_bytes(1, "little"))
|
||||
destFp.write(charaBp.to_bytes(1, "little"))
|
||||
destFp.write(charaAp.to_bytes(1, "little"))
|
||||
destFp.write(charaStage.to_bytes(1, "little"))
|
||||
destFp.write(charaAttribute.to_bytes(1, "little"))
|
||||
destFp.write(charaAttackSprite.to_bytes(1, "little"))
|
||||
destFp.write(charaSleepTime.to_bytes(4, "little"))
|
||||
destFp.write(charaWakeupTime.to_bytes(4, "little"))
|
||||
destFp.write(charaEvolutionTime.to_bytes(4, "little"))
|
||||
destFp.write(charaReductionTime.to_bytes(2, "little"))
|
||||
destFp.write(charaMinWeight.to_bytes(1, "little"))
|
||||
|
||||
logging.info(f"Añadiendo nueva entrada con nombre {matches[0][1]}")
|
||||
|
||||
|
||||
@ -39,6 +39,18 @@ uint8_t buttons_getPressedButtons() {
|
||||
(k4_prev == HIGH && k4_current == LOW)
|
||||
);
|
||||
|
||||
if (retV == K4_PRESSED) {
|
||||
tft.fillScreen(TFT_BLACK);
|
||||
xPos++;
|
||||
if (xPos > 1) {
|
||||
yPos++;
|
||||
xPos = 0;
|
||||
if (yPos > 1) {
|
||||
yPos = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (retV != 0) {
|
||||
tone(SPK_PIN, BEEP_FREQ_HZ, BEEP_LEN_MS);
|
||||
lastPressedButtonTime = esp_timer_get_time();
|
||||
@ -51,7 +63,5 @@ uint8_t buttons_getPressedButtons() {
|
||||
k3_prev = k3_current;
|
||||
k4_prev = k4_current;
|
||||
|
||||
delay(15);
|
||||
|
||||
return retV;
|
||||
}
|
||||
|
||||
@ -15,10 +15,11 @@ struct CharacterData {
|
||||
uint8_t age;
|
||||
uint8_t poopNumber;
|
||||
|
||||
uint8_t careMistakes;
|
||||
uint8_t effort;
|
||||
uint8_t overfeed;
|
||||
uint8_t sleepDisturbances;
|
||||
uint8_t careMistakes = 0;
|
||||
uint8_t effort = 0;
|
||||
uint8_t overfeed = 0;
|
||||
uint8_t sleepDisturbances = 0;
|
||||
uint8_t injuries = 0;
|
||||
|
||||
uint16_t stageTotalBattled;
|
||||
uint16_t stageTotalWon;
|
||||
@ -27,7 +28,7 @@ struct CharacterData {
|
||||
uint16_t charaTotalWon;
|
||||
|
||||
int32_t sleepCareMistakeCounter = 0;
|
||||
int32_t evoLeftTimer;
|
||||
int32_t changeTimerLeft;
|
||||
int16_t hungerCareMistakeTimer;
|
||||
int16_t strengthCareMistakeTimer;
|
||||
|
||||
@ -38,12 +39,18 @@ struct CharacterData {
|
||||
bool careMistakeCallLight = false;
|
||||
bool overfeedHappened = false;
|
||||
|
||||
uint32_t sleepTime;
|
||||
uint32_t wakeupTime;
|
||||
|
||||
bool sleepy = false;
|
||||
bool asleep = false;
|
||||
bool injured = false;
|
||||
bool dead = false;
|
||||
bool traited = true;
|
||||
|
||||
// Usado para recalcular cuantos dias van a tardar en recuperarse, max 5 pls
|
||||
uint8_t dynamicSleepDists;
|
||||
|
||||
// Obtained from structure
|
||||
uint8_t idChara;
|
||||
|
||||
@ -56,10 +63,10 @@ struct CharacterData {
|
||||
uint8_t stage;
|
||||
uint8_t attribute;
|
||||
|
||||
uint32_t sleepTime;
|
||||
uint32_t wakeupTime;
|
||||
uint32_t initialSleepTime;
|
||||
uint32_t initialWakeupTime;
|
||||
|
||||
uint32_t evoTime;
|
||||
uint32_t initialChangeTimer;
|
||||
|
||||
uint16_t initialStatsReductionTime = 600;
|
||||
uint8_t minWeight;
|
||||
|
||||
@ -113,6 +113,8 @@
|
||||
#define EMPTY_HEART_ICON 10
|
||||
#define CLEANER_ICON 11
|
||||
|
||||
#define SECONDS_IN_DAY 86400
|
||||
|
||||
// STANDARD VPET PARAMETER (CARE MISTAKES)
|
||||
#define CARE_MISTAKE_COUNTER_MAX 60
|
||||
#define SLEEP_CARE_MISTAKE_COUNTER_MAX 60
|
||||
@ -132,6 +134,8 @@
|
||||
#define K4_PRESSED 1
|
||||
#define NONE_PRESSED 0
|
||||
|
||||
#define SCALE_FACTOR 3
|
||||
|
||||
#define CHARA_COUNT_IN_DEVICE 5
|
||||
|
||||
extern int screenKey;
|
||||
@ -179,4 +183,12 @@ extern Line_t** currentLine;
|
||||
|
||||
extern struct SpriteData mainCharacterSprites;
|
||||
|
||||
// ALTAMENTE TEMPORAL
|
||||
extern int xPos;
|
||||
extern int yPos;
|
||||
|
||||
#include <TFT_eSPI.h>
|
||||
|
||||
extern TFT_eSPI tft;
|
||||
|
||||
#endif
|
||||
@ -1,8 +1,11 @@
|
||||
#include "display.h"
|
||||
|
||||
int xPos = 0;
|
||||
int yPos = 0;
|
||||
|
||||
void tft_initDisplay(TFT_eSPI &tft, uint16_t color) {
|
||||
tft.init();
|
||||
tft.setRotation(0);
|
||||
tft.setRotation(1);
|
||||
tft.fillScreen(color);
|
||||
}
|
||||
|
||||
@ -15,7 +18,7 @@ void tft_initScreenBuffer(TFT_eSprite &buffer, uint16_t color) {
|
||||
}
|
||||
|
||||
void tft_drawBuffer(TFT_eSprite &buffer) {
|
||||
buffer.pushSprite(0, 0);
|
||||
buffer.pushSprite(xPos * -80, yPos * -112);
|
||||
}
|
||||
|
||||
void tft_clearBuffer(TFT_eSprite &buffer, uint16_t color) {
|
||||
|
||||
@ -2,6 +2,9 @@
|
||||
|
||||
#include "defs/sprite_data.h"
|
||||
|
||||
#define BUFFER_X 239
|
||||
#define BUFFER_Y 239
|
||||
|
||||
const char* TAG_D = "[DRAW]";
|
||||
|
||||
void draw_drawSprite(
|
||||
@ -39,10 +42,10 @@ void draw_drawSpriteCentered(
|
||||
TFT_eSprite &buffer, TFT_eSprite &spr,
|
||||
struct SpriteData* spriteData, uint8_t spriteNumber, uint8_t factor, bool flipped, int y
|
||||
) {
|
||||
int x = (TFT_WIDTH - (spriteData->spriteWidth * factor)) / 2;
|
||||
int x = (BUFFER_X - (spriteData->spriteWidth * factor)) / 2;
|
||||
int new_y;
|
||||
if (y == -1) {
|
||||
new_y = (TFT_HEIGHT - (spriteData->spriteHeight * factor)) / 2;
|
||||
new_y = (BUFFER_Y - (spriteData->spriteHeight * factor)) / 2;
|
||||
} else {
|
||||
new_y = y;
|
||||
}
|
||||
|
||||
@ -59,9 +59,11 @@ uint8_t eggNumber = 0;
|
||||
|
||||
// Tasks
|
||||
TaskHandle_t secondLoop = NULL;
|
||||
TaskHandle_t readSteps = NULL;
|
||||
|
||||
void loop2();
|
||||
void secondCoreTask(void*);
|
||||
void loop_readSteps(void*);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
@ -175,15 +177,18 @@ void loop() {
|
||||
menu_drawDeathScreen(composite, bg, sprite, &menuElementsData, &uiElementsData);
|
||||
break;
|
||||
}
|
||||
|
||||
if (screenKey == IDLE_SCREEN || screenKey == OFF_SCREEN) {
|
||||
steps_countSteps();
|
||||
}
|
||||
}
|
||||
|
||||
void loop2() {
|
||||
steps_countSteps();
|
||||
buttons_checkInactivity();
|
||||
vpet_runVpetTasks();
|
||||
|
||||
getLocalTime(&timeInfo, 50);
|
||||
dayUnixTime = mktime(&timeInfo) % 86400;
|
||||
dayUnixTime = mktime(&timeInfo) % SECONDS_IN_DAY;
|
||||
}
|
||||
|
||||
void secondCoreTask(void*) {
|
||||
|
||||
@ -53,7 +53,7 @@ void menu_drawClockEdit(TFT_eSprite &composite, TFT_eSprite &bg) {
|
||||
// Es un dia random, nada significativo, ya pondre mas adelante que tenga dia del año
|
||||
rtc.setTime(0, clockMinuteCount, clockHourCount, 1, 11, 2024);
|
||||
getLocalTime(&timeInfo, 50);
|
||||
dayUnixTime = mktime(&timeInfo) % 86400;
|
||||
dayUnixTime = mktime(&timeInfo) % SECONDS_IN_DAY;
|
||||
|
||||
coldBoot = false;
|
||||
|
||||
|
||||
@ -49,6 +49,8 @@ void menu_reloadEggs(uint8_t selectedEgg) {
|
||||
|
||||
lines_freeEggList();
|
||||
|
||||
printf("[DEBUG] fileName=%s\n", fileName);
|
||||
|
||||
lines_getSingleLine(fileName);
|
||||
lines_getLineCareMistakes(fileName);
|
||||
|
||||
|
||||
@ -11,19 +11,6 @@ void menu_feedingScreen(
|
||||
static int currentAnimationFrame = 0;
|
||||
|
||||
uint64_t currentTime = esp_timer_get_time();
|
||||
uint8_t pressedButtons = buttons_getPressedButtons();
|
||||
switch (pressedButtons) {
|
||||
case 8:
|
||||
case 4:
|
||||
screenKey = FOOD_SCREEN;
|
||||
currentAnimationFrame = 0;
|
||||
lastPressedButtonTime = currentTime;
|
||||
submenuKey = -1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
if (currentTime - lastUpdateTime > ANIMATION_THRESHOLD_TIME_US) {
|
||||
draw_drawBackground(composite, bg, 90, 90, 3);
|
||||
@ -46,4 +33,18 @@ void menu_feedingScreen(
|
||||
}
|
||||
|
||||
tft_drawBuffer(composite);
|
||||
|
||||
uint8_t pressedButtons = buttons_getPressedButtons();
|
||||
switch (pressedButtons) {
|
||||
case 8:
|
||||
case 4:
|
||||
screenKey = FOOD_SCREEN;
|
||||
currentAnimationFrame = 0;
|
||||
lastPressedButtonTime = currentTime;
|
||||
submenuKey = -1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -32,12 +32,14 @@ void menu_foodScreen(TFT_eSprite &composite, TFT_eSprite &bg, TFT_eSprite &mainC
|
||||
}
|
||||
|
||||
if (pressedButtons == 4) {
|
||||
lastUpdateTime = 0;
|
||||
switch(arrowPosition) {
|
||||
case 0:
|
||||
if (charaData.hunger < 8) {
|
||||
charaData.hungerCareMistakeTimer = charaData.initialStatsReductionTime;
|
||||
charaData.hungerCareMistakeObtained = false;
|
||||
charaData.weight++;
|
||||
charaData.hunger++;
|
||||
charaData.hungerCareMistakeTimer = charaData.initialStatsReductionTime;
|
||||
screenKey = FEEDING_SCREEN;
|
||||
submenuKey = FOOD_ICON;
|
||||
} else {
|
||||
@ -47,18 +49,20 @@ void menu_foodScreen(TFT_eSprite &composite, TFT_eSprite &bg, TFT_eSprite &mainC
|
||||
charaData.overfeedHappened = true;
|
||||
}
|
||||
}
|
||||
return;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
if (charaData.strength < 8) {
|
||||
charaData.strengthCareMistakeTimer = charaData.initialStatsReductionTime;
|
||||
charaData.strength++;
|
||||
charaData.weight += 2;
|
||||
charaData.strengthCareMistakeTimer = charaData.initialStatsReductionTime;
|
||||
screenKey = FEEDING_SCREEN;
|
||||
submenuKey = PILL_ICON;
|
||||
} else {
|
||||
screenKey = REFUSING_SCREEN;
|
||||
}
|
||||
return;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
||||
@ -45,4 +45,7 @@ void menu_eggHatchScreen(TFT_eSprite &composite, TFT_eSprite &bg, TFT_eSprite &s
|
||||
void menu_reloadEggs(uint8_t selectedEgg);
|
||||
void menu_drawDeathScreen(TFT_eSprite &composite, TFT_eSprite &bg, TFT_eSprite &sprite, struct SpriteData* uiBigSprite, struct SpriteData* uiSmallSprite);
|
||||
|
||||
void menu_sleepScreen_sleepAction();
|
||||
void menu_sleepScreen_recalculateSleep();
|
||||
|
||||
#endif
|
||||
@ -17,11 +17,11 @@ void menu_drawCurrentMenuOption(TFT_eSprite &composite, TFT_eSprite &bg, TFT_eSp
|
||||
uint8_t pressedButtons = buttons_getPressedButtons();
|
||||
|
||||
switch (pressedButtons) {
|
||||
case 8:
|
||||
case K1_PRESSED:
|
||||
menuKey++;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case K3_PRESSED:
|
||||
screenKey = IDLE_SCREEN;
|
||||
menuKey = STATUS_SCREEN_MENU;
|
||||
return;
|
||||
@ -31,7 +31,8 @@ void menu_drawCurrentMenuOption(TFT_eSprite &composite, TFT_eSprite &bg, TFT_eSp
|
||||
break;
|
||||
}
|
||||
|
||||
if (pressedButtons == 4) {
|
||||
// Separaíto mas guapito
|
||||
if (pressedButtons == K2_PRESSED) {
|
||||
switch (menuKey) {
|
||||
case STATUS_SCREEN_MENU:
|
||||
screenKey = STATUS_SCREEN;
|
||||
@ -42,10 +43,7 @@ void menu_drawCurrentMenuOption(TFT_eSprite &composite, TFT_eSprite &bg, TFT_eSp
|
||||
break;
|
||||
|
||||
case SLEEP_SCREEN_MENU:
|
||||
charaData.asleep = true;
|
||||
vpet_computeCallLight();
|
||||
menuKey = STATUS_SCREEN;
|
||||
screenKey = SLEEP_SCREEN;
|
||||
menu_sleepScreen_sleepAction();
|
||||
break;
|
||||
|
||||
case POOP_SCREEN_MENU:
|
||||
@ -107,3 +105,35 @@ void menu_drawCurrentMenuOption(TFT_eSprite &composite, TFT_eSprite &bg, TFT_eSp
|
||||
|
||||
tft_drawBuffer(composite);
|
||||
}
|
||||
|
||||
void menu_sleepScreen_sleepAction() {
|
||||
if (charaData.asleep && charaData.sleepy) {
|
||||
menu_sleepScreen_recalculateSleep();
|
||||
|
||||
charaData.sleepy = false;
|
||||
charaData.asleep = false;
|
||||
|
||||
charaData.sleepDisturbances++;
|
||||
|
||||
menuKey = STATUS_SCREEN;
|
||||
screenKey = IDLE_SCREEN;
|
||||
|
||||
} else {
|
||||
charaData.asleep = true;
|
||||
|
||||
vpet_computeCallLight(); // Lo hago por cortesia, no me gusta
|
||||
|
||||
menuKey = STATUS_SCREEN;
|
||||
screenKey = SLEEP_SCREEN;
|
||||
}
|
||||
}
|
||||
|
||||
void menu_sleepScreen_recalculateSleep() {
|
||||
uint32_t newSleepTime = (dayUnixTime + 3600) % SECONDS_IN_DAY;
|
||||
uint32_t newWakeUpTime = charaData.wakeupTime + 3600;
|
||||
|
||||
charaData.sleepTime = newSleepTime;
|
||||
charaData.wakeupTime = newWakeUpTime;
|
||||
|
||||
charaData.dynamicSleepDists++;
|
||||
}
|
||||
@ -14,6 +14,7 @@ void lines_onHatchComplete() {
|
||||
|
||||
storage_readFile(spriteFileName, &mainCharacterSprites);
|
||||
|
||||
// Primero los datos del bicho actual en nuestra estructura de datos de confianza
|
||||
charaData.hp = currentLine[currentCharacter]->characters[0].hp;
|
||||
charaData.bp = currentLine[currentCharacter]->characters[0].bp;
|
||||
charaData.ap = currentLine[currentCharacter]->characters[0].ap;
|
||||
@ -21,16 +22,16 @@ void lines_onHatchComplete() {
|
||||
charaData.stage = currentLine[currentCharacter]->characters[0].stage;
|
||||
charaData.attribute = currentLine[currentCharacter]->characters[0].attribute;
|
||||
|
||||
charaData.sleepTime = currentLine[currentCharacter]->characters[0].sleepTime;
|
||||
charaData.wakeupTime = currentLine[currentCharacter]->characters[0].wakeTime;
|
||||
charaData.evoLeftTimer = currentLine[currentCharacter]->characters[0].changeTime;
|
||||
charaData.evoTime = currentLine[currentCharacter]->characters[0].changeTime;
|
||||
|
||||
charaData.hungerCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
|
||||
charaData.strengthCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
|
||||
charaData.sleepTime = charaData.initialSleepTime = currentLine[currentCharacter]->characters[0].sleepTime;
|
||||
charaData.wakeupTime = charaData.initialWakeupTime = currentLine[currentCharacter]->characters[0].wakeTime;
|
||||
charaData.initialChangeTimer = charaData.changeTimerLeft = currentLine[currentCharacter]->characters[0].changeTime;
|
||||
|
||||
charaData.initialStatsReductionTime = currentLine[currentCharacter]->characters[0].depleteTime;
|
||||
charaData.minWeight = currentLine[currentCharacter]->characters[0].minWeight;
|
||||
|
||||
// Luego le obligamos a que nazca con hambre
|
||||
charaData.hungerCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
|
||||
charaData.strengthCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
|
||||
|
||||
charaData.hatched = true;
|
||||
}
|
||||
@ -2,8 +2,8 @@
|
||||
#include "defs/defs.h"
|
||||
|
||||
float gravity = 0.0;
|
||||
const float alpha = 0.99;
|
||||
const float thresh = 0.80;
|
||||
const float alpha = 0.95;
|
||||
const float thresh = 0.40;
|
||||
uint64_t lastStepTime = esp_timer_get_time();
|
||||
|
||||
|
||||
@ -22,7 +22,7 @@ void steps_countSteps() {
|
||||
float dyn = mag - gravity;
|
||||
|
||||
unsigned long now = esp_timer_get_time();
|
||||
if (dyn > thresh && (now - lastStepTime) > 500000) {
|
||||
if (dyn > thresh && (now - lastStepTime) > 250000) {
|
||||
stepCounter++;
|
||||
lastStepTime = now;
|
||||
}
|
||||
|
||||
@ -38,13 +38,22 @@ bool vpet_evalSleep() {
|
||||
charaData.sleepy = false;
|
||||
charaData.asleep = false;
|
||||
|
||||
if (charaData.dynamicSleepDists > 0) {
|
||||
// Primero, el sleep time ahora está reventado, hay que restaurarlo
|
||||
// fácil, simplemente recalcula a la hora de despertar
|
||||
charaData.dynamicSleepDists--;
|
||||
|
||||
charaData.sleepTime = (charaData.initialSleepTime + (charaData.dynamicSleepDists * 3600)) % SECONDS_IN_DAY;
|
||||
charaData.wakeupTime = (charaData.initialWakeupTime + (charaData.dynamicSleepDists * 3600)) % SECONDS_IN_DAY;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
} else if (
|
||||
dayUnixTime < charaData.sleepTime &&
|
||||
dayUnixTime > charaData.wakeupTime &&
|
||||
charaData.asleep &&
|
||||
charaData.sleepCareMistakeCounter < 60
|
||||
charaData.sleepCareMistakeCounter < SLEEP_COUNTER_MAX
|
||||
// Esto se ejecuta cuando mandamos a dormir al personaje
|
||||
// durante el dia.
|
||||
// Resultado, el personaje deberia de dormir una siesta
|
||||
@ -57,7 +66,7 @@ bool vpet_evalSleep() {
|
||||
dayUnixTime < charaData.sleepTime &&
|
||||
dayUnixTime > charaData.wakeupTime &&
|
||||
charaData.asleep &&
|
||||
charaData.sleepCareMistakeCounter >= 60
|
||||
charaData.sleepCareMistakeCounter >= SLEEP_COUNTER_MAX
|
||||
// Esto se ejecuta cuando la siesta del personaje acaba
|
||||
// Resultado, el personaje se despierta
|
||||
) {
|
||||
@ -88,7 +97,7 @@ bool vpet_evalSleep() {
|
||||
|
||||
} else if (
|
||||
charaData.sleepy && !charaData.asleep &&
|
||||
charaData.sleepCareMistakeCounter < 60 &&
|
||||
charaData.sleepCareMistakeCounter < SLEEP_COUNTER_MAX &&
|
||||
!charaData.sleepCareMistakeObtained
|
||||
// Esto se ejecuta cuando el personaje debería de estar durmiendo
|
||||
// pero no se le ha mandado a dormir, empieza a contar para pasar
|
||||
@ -100,7 +109,7 @@ bool vpet_evalSleep() {
|
||||
|
||||
} else if (
|
||||
charaData.sleepy && !charaData.asleep &&
|
||||
charaData.sleepCareMistakeCounter >= 60 &&
|
||||
charaData.sleepCareMistakeCounter >= SLEEP_COUNTER_MAX &&
|
||||
!charaData.sleepCareMistakeObtained
|
||||
// Esto se ejecuta cuando el personaje deberia de estar durmiendo
|
||||
// pero no se le ha mandado a dormir, y el contador ya ha llegado
|
||||
@ -135,74 +144,78 @@ bool vpet_evalSleep() {
|
||||
}
|
||||
|
||||
void vpet_evalTimers() {
|
||||
if (charaData.hungerCareMistakeTimer >= 0) {
|
||||
charaData.hungerCareMistakeTimer -= 1;
|
||||
vpet_evalHungerTimer();
|
||||
vpet_evalStrengthTimer();
|
||||
}
|
||||
|
||||
if (charaData.strengthCareMistakeTimer >= 0) {
|
||||
charaData.strengthCareMistakeTimer -= 1;
|
||||
}
|
||||
void vpet_evalHungerTimer() {
|
||||
if (charaData.hungerCareMistakeTimer > 0) {
|
||||
charaData.hungerCareMistakeTimer--;
|
||||
|
||||
if (
|
||||
charaData.hungerCareMistakeTimer < 0 ||
|
||||
charaData.strengthCareMistakeTimer < 0
|
||||
} else if (
|
||||
charaData.hungerCareMistakeTimer <= 0 &&
|
||||
charaData.hunger > 0
|
||||
) {
|
||||
if (charaData.hunger > 0) {
|
||||
charaData.hunger--;
|
||||
screenKey = TIMER_FINISHED_SCREEN;
|
||||
interruptKey = POOPING_SCREEN;
|
||||
charaData.poopNumber++;
|
||||
if (charaData.hunger < 4 && charaData.overfeedHappened) {
|
||||
charaData.overfeedHappened = false;
|
||||
}
|
||||
|
||||
if (charaData.hunger > 0) {
|
||||
charaData.hungerCareMistakeTimer = charaData.initialStatsReductionTime;
|
||||
screenKey = TIMER_FINISHED_SCREEN;
|
||||
interruptKey = POOPING_SCREEN;
|
||||
} else {
|
||||
charaData.hungerCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
if (!charaData.hungerCareMistakeObtained) {
|
||||
if (
|
||||
charaData.hunger == 0 &&
|
||||
charaData.hungerCareMistakeTimer < 0
|
||||
) {
|
||||
charaData.careMistakes++;
|
||||
charaData.hungerCareMistakeObtained = true;
|
||||
|
||||
} else if (charaData.hunger == 0) {
|
||||
interruptKey = POOPING_SCREEN;
|
||||
screenKey = TIMER_FINISHED_SCREEN;
|
||||
interruptKey = CARE_MISTAKE_SCREEN;
|
||||
}
|
||||
|
||||
if (charaData.poopNumber < 8) {
|
||||
charaData.poopNumber++;
|
||||
} else {
|
||||
charaData.injured = true;
|
||||
charaData.injuries++;
|
||||
}
|
||||
|
||||
} else if (
|
||||
charaData.hungerCareMistakeTimer <= 0 &&
|
||||
charaData.hunger == 0 &&
|
||||
!charaData.hungerCareMistakeObtained
|
||||
) {
|
||||
charaData.hungerCareMistakeObtained = true;
|
||||
charaData.careMistakes++;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (charaData.strength > 0) {
|
||||
void vpet_evalStrengthTimer() {
|
||||
if (charaData.strengthCareMistakeTimer > 0) {
|
||||
charaData.strengthCareMistakeTimer--;
|
||||
|
||||
} else if (
|
||||
charaData.strengthCareMistakeTimer <= 0 &&
|
||||
charaData.strength > 0
|
||||
) {
|
||||
charaData.strength--;
|
||||
if (charaData.strength > 0) {
|
||||
charaData.strengthCareMistakeTimer = charaData.initialStatsReductionTime;
|
||||
} else {
|
||||
charaData.strengthCareMistakeTimer = CARE_MISTAKE_COUNTER_MAX;
|
||||
}
|
||||
}
|
||||
|
||||
if (!charaData.strengthCareMistakeObtained) {
|
||||
if (
|
||||
charaData.strength == 0 &&
|
||||
charaData.strengthCareMistakeTimer < 0
|
||||
) {
|
||||
charaData.careMistakes++;
|
||||
charaData.strengthCareMistakeObtained = true;
|
||||
|
||||
} else if(charaData.strength == 0) {
|
||||
if (interruptKey != POOPING_SCREEN) {
|
||||
interruptKey = CARE_MISTAKE_SCREEN;
|
||||
screenKey = TIMER_FINISHED_SCREEN;
|
||||
}
|
||||
}
|
||||
|
||||
} else if (
|
||||
charaData.strengthCareMistakeTimer <= 0 &&
|
||||
charaData.strength == 0 &&
|
||||
!charaData.strengthCareMistakeObtained
|
||||
) {
|
||||
charaData.strengthCareMistakeObtained = true;
|
||||
charaData.careMistakes++;
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void IRAM_ATTR onActionTimerDelta() {
|
||||
runVpetTasks = true;
|
||||
@ -214,15 +227,17 @@ void vpet_runVpetTasks() {
|
||||
if (!vpet_evalSleep()) {
|
||||
vpet_evalTimers();
|
||||
}
|
||||
|
||||
printf("[MAIN]: Hunger timer %d, hunger %d\n", charaData.hungerCareMistakeTimer, charaData.hunger);
|
||||
printf("[MAIN]: Strength timer %d, strength %d\n", charaData.strengthCareMistakeTimer, charaData.strength);
|
||||
printf("[MAIN]: Evo timer %d\n", charaData.evoLeftTimer);
|
||||
printf("[MAIN]: Change timer %d\n", charaData.changeTimerLeft);
|
||||
printf("[MAIN]: RTC time is %d\n", dayUnixTime);
|
||||
printf("[MAIN]: Sleep counter is %d\n", charaData.sleepCareMistakeCounter);
|
||||
printf("[MAIN]: Care mistake count is %d\n", charaData.careMistakes);
|
||||
printf("[MAIN]: Is sleep care mistake tripped? %d\n", charaData.sleepCareMistakeObtained);
|
||||
|
||||
runVpetTasks = false;
|
||||
|
||||
} else if (runVpetTasks && !charaData.hatched && charaData.hatching) {
|
||||
charaData.hatchTimer++;
|
||||
printf("[DEBUG] hatchTimer=%i out of hatchTimer=%i\n", charaData.hatchTimer, currentLine[currentCharacter]->hatchTime);
|
||||
|
||||
@ -9,5 +9,7 @@ void vpet_computeCallLight();
|
||||
bool vpet_evalSleep();
|
||||
void vpet_evalTimers();
|
||||
void vpet_runVpetTasks();
|
||||
void vpet_evalHungerTimer();
|
||||
void vpet_evalStrengthTimer();
|
||||
|
||||
#endif
|
||||
Loading…
x
Reference in New Issue
Block a user