/*! \brief Confirm save * * If the save slot selected already has a saved game in it, confirm that we * want to overwrite it. * * \returns 0 if cancelled, 1 if confirmed */ static int confirm_action (void) { int stop = 0; int pointer_offset = (save_ptr - top_pointer) * 48; if (snc[save_ptr] == 0) return 1; fullblit(double_buffer, back); menubox (double_buffer, 128, pointer_offset + 12, 14, 1, DARKBLUE); print_font (double_buffer, 136, pointer_offset + 20, _("Confirm/Cancel"), FNORMAL); blit2screen (0, 0); fullblit(back, double_buffer); while (!stop) { readcontrols (); if (balt) { unpress (); return 1; } if (bctrl) { unpress (); return 0; } kq_yield (); } return 0; }
/* \brief Enter console mode * * Run the console. Does not return until the console * is closed. */ void run_console(void) { int c; int sl; int running; g_console.inputline[0]='\0'; g_console.on = 1; /* Wait for all keys up */ while(keypressed()) { readkey(); } running = 1; while (running == 1) { sl = strlen(g_console.inputline); /* Get a key */ while (!keypressed()) { check_animation (); blit2screen (xofs, yofs); poll_music (); kq_yield(); } switch((c = readkey()) & 0xff) { case '\r': /* Return */ if (sl == 0) { /* Stop when blank line is entered */ running = 0; g_console.on = 0; } else { g_console.on = 0; scroll_console(g_console.inputline); do_console_command(g_console.inputline); g_console.inputline[0] = '\0'; g_console.on = 1; } break; case 127: /* backspace */ if (strlen(g_console.inputline) > 0) g_console.inputline[sl - 1] = '\0'; break; default: if (strlen(g_console.inputline) < sizeof(g_console.inputline) - 1) { g_console.inputline[sl] = c & 0xff; g_console.inputline[sl + 1] = '\0'; } break; } } /* Wait for enter key up */ do { readcontrols(); } while (benter); }
/*! \brief Use item on selected target * * Do target selection for using an item and then use it. * * \param pp Item index */ static void camp_item_targetting(int pp) { int t1, tg, z; t1 = g_inv[pp][0]; if (items[t1].use == USE_NOT || items[t1].use > USE_CAMP_INF) { return; } if (items[t1].tgt == TGT_NONE || items[t1].tgt > TGT_ALLY_ALL) { return; } while (1) { update_equipstats(); tg = select_any_player(items[t1].tgt - 1, items[t1].icon, items[t1].name); if (tg > -1) { z = item_effects(0, tg, t1); if (z == 0) { play_effect(SND_BAD, 128); } else { revert_equipstats(); if (z == 1) { play_effect(SND_ITEM, 128); select_any_player(3, 0, ""); } if (items[t1].use != USE_ANY_INF && items[t1].use != USE_CAMP_INF) { remove_item(pp, 1); } return; } } else { return; } kq_yield(); } }
/*! \brief Delete game * * You guessed it... delete the game. */ static void delete_game (void) { int a, stop = 0; int pointer_offset = (save_ptr - top_pointer) * 48; sprintf (strbuf, "sg%d.sav", save_ptr); a = remove (kqres (SAVE_DIR, strbuf)); if (a == 0) { menubox (double_buffer, 128, pointer_offset + 12, 12, 1, DARKBLUE); print_font (double_buffer, 136, pointer_offset + 20, _("File Deleted"), FNORMAL); snc[save_ptr] = 0; sgp[save_ptr] = 0; shr[save_ptr] = 0; smin[save_ptr] = 0; for (a = 0; a < PSIZE; a++) { sid[save_ptr][a] = 0; shp[save_ptr][a] = 0; smp[save_ptr][a] = 0; slv[save_ptr][a] = 0; } } else { menubox (double_buffer, 128, pointer_offset + 12, 16, 1, DARKBLUE); print_font (double_buffer, 136, pointer_offset + 20, _("File Not Deleted"), FNORMAL); } blit2screen (0, 0); blit (back, double_buffer, 0, 0, 0, 0, 352, 280); while (!stop) { readcontrols (); if (balt || bctrl) { unpress (); stop = 1; } kq_yield (); } }
/*! \brief Battle gauge, action controls * \author Josh Bolduc * \date Created ???????? * \date Updated 20020914 - 16:16 (RB) * * This function controls the battle gauges and calls for action * when necessary. This is also where things like poison, sleep, * and what-not are checked. */ static void do_round (void) { int a; int index; timer_count = 0; while (!combatend) { if (timer_count >= 10) { rcount += BATTLE_INC; if (rcount >= ROUND_MAX) rcount = 0; for (index = 0; index < PSIZE + numens; index++) { if ((index < numchrs) || (index >= PSIZE)) { if (((fighter[index].sts[S_POISON] - 1) == rcount) && (fighter[index].hp > 1)) { a = rand () % ((fighter[index].mhp / 20) + 1); if (a < 2) a = 2; if ((fighter[index].hp - a) < 1) a = fighter[index].hp - 1; ta[index] = a; display_amount (index, FNORMAL, 0); fighter[index].hp -= a; } /* RB: the character is regenerating? when needed, get a */ /* random value (never lower than 5), and increase */ /* the character's health by that amount. */ if ((fighter[index].sts[S_REGEN] - 1) == rcount) { a = rand () % 5 + (fighter[index].mhp / 10); if (a < 5) a = 5; ta[index] = a; display_amount (index, FYELLOW, 0); adjust_hp (index, a); } /* RB: the character has ether actived? */ cact[index] = 1; if ((fighter[index].sts[S_ETHER] > 0) && (rcount == 0)) fighter[index].sts[S_ETHER]--; /* RB: the character is stopped? */ if (fighter[index].sts[S_STOP] > 0) { if (pidx[index] == TEMMIN) fighter[index].aux = 0; if (rcount == 0) fighter[index].sts[S_STOP]--; cact[index] = 0; } /* RB: the character is sleeping? */ if (fighter[index].sts[S_SLEEP] > 0) { if (pidx[index] == TEMMIN) fighter[index].aux = 0; if (rcount == 0) fighter[index].sts[S_SLEEP]--; cact[index] = 0; } /* RB: the character is petrified? */ if (fighter[index].sts[S_STONE] > 0) { if (pidx[index] == TEMMIN) fighter[index].aux = 0; if (rcount == 0) fighter[index].sts[S_STONE]--; cact[index] = 0; } if ((fighter[index].sts[S_DEAD] != 0) || (fighter[index].mhp <= 0)) { if (pidx[index] == TEMMIN) fighter[index].aux = 0; bspeed[index] = 0; cact[index] = 0; } if (cact[index] > 0) { if (fighter[index].sts[S_TIME] == 0) bspeed[index] += nspeed[index]; else { if (fighter[index].sts[S_TIME] == 1) bspeed[index] += (nspeed[index] / 2 + 1); else bspeed[index] += (nspeed[index] * 2); } } } else cact[index] = 0; } readcontrols (); battle_render (0, 0, 0); blit2screen (0, 0); for (index = 0; index < (PSIZE + numens); index++) { if ((bspeed[index] >= ROUND_MAX) && (cact[index] > 0)) { do_action (index); fighter[index].ctmem = 0; fighter[index].csmem = 0; cact[index] = 1; bspeed[index] = 0; } if (combatend) return; } timer_count = 0; } kq_yield (); } }