/* * Checks various stuff to do when skills change, like new spells, ... */ void recalc_skills(bool init) { process_hooks(HOOK_RECALC_SKILLS, "()"); /* Update stuffs */ p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS | PU_POWERS | PU_SANITY | PU_BODY); /* Redraw various info */ flag_bool(&p_ptr->redraw, FLAG_PR_WIPE); flag_bool(&p_ptr->redraw, FLAG_PR_BASIC); flag_bool(&p_ptr->redraw, FLAG_PR_EXTRA); flag_bool(&p_ptr->redraw, FLAG_PR_MAP); }
static void power_activate(s32b power) { power_type *x_ptr = &powers_type[power]; if (!power_chance(x_ptr)) return; switch (power) { default: if (!process_hooks(HOOK_ACTIVATE_POWER, "(d)", power)) { msg_format("Warning power_activate() called with invalid power(%d).", power); energy_use = 0; } break; } flag_bool(&p_ptr->redraw, FLAG_PR_HP); flag_bool(&p_ptr->redraw, FLAG_PR_MANA); }
/* * Increase the "number" of an item in the inventory */ void item_increase(s32b item, s32b num) { object_type *o_ptr = get_object(item); if (!o_ptr) return; /* Apply */ num += o_ptr->number; /* Bounds check */ if (num > 255) num = 255; else if (num < 0) num = 0; /* Un-apply */ num -= o_ptr->number; /* Change the number and weight */ if (num) { /* Add the number */ o_ptr->number += num; if (item >= 0) { /* Recalculate bonuses */ p_ptr->update |= (PU_BONUS); /* Recalculate mana XXX */ p_ptr->update |= (PU_MANA); /* Combine the pack */ p_ptr->notice |= (PN_COMBINE); /* Window stuff */ flag_bool(&p_ptr->window, FLAG_PW_INVEN); flag_bool(&p_ptr->window, FLAG_PW_EQUIP); } } }
int main(int argc, const char **argv) { char const* outmesh = "result.obj"; char const* atlas = "result.png"; char const* mtl = "result.mtl"; int sizehint = 32; int nsamples = 128; bool gbuffer = false; bool chartinfo = false; float multiply = 1.0; flag_usage("[options] input_mesh.obj"); flag_string(&outmesh, "outmesh", "OBJ file to produce"); flag_string(&atlas, "atlas", "PNG file to produce"); flag_string(&mtl, "material", "MTL file to produce"); flag_int(&sizehint, "sizehint", "Controls resolution of atlas"); flag_int(&nsamples, "nsamples", "Quality of ambient occlusion"); flag_bool(&gbuffer, "gbuffer", "Generate diagnostic images"); flag_bool(&chartinfo, "ids", "Group faces by charts, add alpha channel"); flag_float(&multiply, "multiply", "Scales the AO values be a constant"); flag_parse(argc, argv, "v" AOBAKER_VERSION, 1); char const* inmesh = flagset_singleton()->argv[0]; return aobaker_bake(inmesh, outmesh, mtl, atlas, sizehint, nsamples, gbuffer, chartinfo, multiply); }
/* * Note: return value indicates the amount of mana to use */ bool power_chance(power_type *x_ptr) { #if 0 // DGDGDGDG -- mana is no more hardcoded bool use_hp = FALSE; s32b diff = x_ptr->diff; /* Always true ? */ if (!x_ptr->cost) return TRUE; /* Not enough mana - use hp */ if (p_ptr->csp < x_ptr->cost) return FALSE; /* Power is not available yet */ if (p_ptr->lev < x_ptr->level) { msg_format("You need to attain level %d to use this power.", x_ptr->level); energy_use = 0; return (FALSE); } /* Too confused */ else if (intrinsic(CONFUSED)) { msg_print("You are too confused to use this power."); energy_use = 0; return (FALSE); } /* Else attempt to do it! */ if (p_ptr->lev > x_ptr->level) { s32b lev_adj = ((p_ptr->lev - x_ptr->level) / 3); if (lev_adj > 10) lev_adj = 10; diff -= lev_adj; } if (diff < 5) diff = 5; /* take time and pay the price */ p_ptr->csp -= (x_ptr->cost / 2 ) + (randint(x_ptr->cost / 2)); energy_use = get_player_energy(SPEED_POWER); /* Redraw mana and hp */ flag_bool(&p_ptr->redraw, FLAG_PR_HP); flag_bool(&p_ptr->redraw, FLAG_PR_MANA); /* Window stuff */ p_ptr->window |= (PW_PLAYER); /* Success? */ // DGDGDGDGDG this was stat_cur, needs adjusting // DGDGDGDGDG dont bother, jsut change the formula to be sane anyway if (randint(get_stat(x_ptr->stat, ind)) >= ((diff / 2) + randint(diff / 2))) { return (TRUE); } if (flush_failure) flush(); msg_print("You've failed to concentrate hard enough."); #endif return (FALSE); }
/* * Interreact with abilitiess */ void do_cmd_ability() { s32b sel = 0, start = 0, max = 0; s32b c; s32b *table; s32b i; s32b wid, hgt; if(!&ab_info[0]) { msg_print("There are no abilities for you to learn!"); return; } C_MAKE(table, max_ab_idx, s32b); /* Initialise the abilities list */ for (i = 0; i < max_ab_idx; i++) { if (ab_info[i].name && (wizard || (!ab_info[i].hidden && show_ability(i)))) add_sorted_ability(table, &max, i); } if (max == 0) { C_FREE(table, max_ab_idx, s32b); msg_print("There are no abilities for you to learn!"); return; } /* Save the screen */ screen_save(); /* Clear the screen */ Term_clear(); while (TRUE) { Term_get_size(&wid, &hgt); /* Display list of skills */ print_abilities(table, max, sel, start); /* Wait for user input */ c = inkey(); /* Leave the skill screen */ if (c == ESCAPE) break; /* Next page */ else if (c == 'n') { sel += (hgt - 7); if (sel >= max) sel = max - 1; } /* Previous page */ else if (c == 'p') { sel -= (hgt - 7); if (sel < 0) sel = 0; } /* Select / increase a skill */ else { s32b dir; /* Allow use of numpad / arrow keys / roguelike keys */ dir = get_keymap_dir(c); /* Move cursor down */ if (dir == 2) sel++; /* Move cursor up */ if (dir == 8) sel--; /* gain ability */ if (dir == 6) gain_ability(table[sel]); /* XXX XXX XXX Wizard mode commands outside of wizard2.c */ if (wizard && (c == '+')) ab_info[table[sel]].acquired = TRUE; if (wizard && (c == '-')) ab_info[table[sel]].acquired = FALSE; /* Contextual help */ if (c == '?') exec_lua(format("ingame_help('select_context', 'ability', '%s')", ab_info[table[sel]].name)); ; /* Handle boundaries and scrolling */ if (sel < 0) sel = max - 1; if (sel >= max) sel = 0; if (sel < start) start = sel; if (sel >= start + (hgt - 7)) start = sel - (hgt - 7) + 1; } } /* Load the screen */ screen_load(); C_FREE(table, max_ab_idx, s32b); /* Update stuffs */ p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS | PU_POWERS | PU_SANITY | PU_BODY); /* Redraw various info */ flag_bool(&p_ptr->redraw, FLAG_PR_WIPE); flag_bool(&p_ptr->redraw, FLAG_PR_BASIC); flag_bool(&p_ptr->redraw, FLAG_PR_EXTRA); flag_bool(&p_ptr->redraw, FLAG_PR_MAP); }
/* * Enter a store, and interact with it. * * Note that we use the standard "request_command()" function * to get a command, allowing us to use "command_arg" and all * command macros and other nifty stuff, but we use the special * "shopping" argument, to force certain commands to be converted * into other commands, normally, we convert "p" (pray) and "m" * (cast magic) into "g" (get), and "s" (search) into "d" (drop). */ void do_cmd_store(void) { s32b which; s32b maintain_num; s32b i; bool recreate = FALSE; store_type *st_ptr; store_info_type *sti_ptr; cave_type *c_ptr; /* Access the player grid */ c_ptr = &cave[p_ptr->py][p_ptr->px]; /* Verify a store */ if (!cave_feat_is(c_ptr, FLAG_CONTAINS_BUILDING)) { msg_print("You see no store here."); return; } /* Extract the store code */ which = get_flag(c_ptr, FLAG_CONTAINS_BUILDING); /* Get the store */ st_ptr = flag_get_store(&town_info[p_ptr->town_num].stores, which); /* If it does not exists yet, create it */ if (!st_ptr) { call_lua("store.create_for_town", "(d,d)", "", p_ptr->town_num, which); st_ptr = flag_get_store(&town_info[p_ptr->town_num].stores, which); if (!st_ptr) quit(format("Could not create store %d town %d! BAD BAD BAD!", which, p_ptr->town_num)); } /* Hack -- Check the "locked doors" */ if (st_ptr->store_open > turn) { msg_print("The doors are locked."); return; } sti_ptr = &st_info[st_ptr->st_idx]; /* Calculate the number of store maintainances since the last visit */ if (has_flag(sti_ptr, FLAG_STORE_MAINTAIN_TURNS)) { if (get_flag(sti_ptr, FLAG_STORE_MAINTAIN_TURNS) >= 1) maintain_num = (turn - st_ptr->last_visit) / (10L * get_flag(sti_ptr, FLAG_STORE_MAINTAIN_TURNS)); else maintain_num = 0; } else maintain_num = (turn - st_ptr->last_visit) / (10L * STORE_TURNS); /* Maintain the store max. 10 times */ if (maintain_num > 10) maintain_num = 10; if (maintain_num) { /* Maintain the store */ for (i = 0; i < maintain_num; i++) call_lua("store.maintain", "(S)", "", st_ptr); /* Save the visit */ st_ptr->last_visit = turn; } /* Forget the lite */ /* forget_lite(); */ /* Forget the view */ forget_view(); call_lua("store.display", "(S)", "", st_ptr); /* Free turn XXX XXX XXX */ energy_use = 0; /* Recreate the level only when needed */ if (recreate) { /* Reinit wilderness to activate quests ... */ p_ptr->oldpx = p_ptr->px; p_ptr->oldpy = p_ptr->py; p_ptr->leaving = TRUE; } /* Hack -- Cancel automatic command */ command_new = 0; /* Hack -- Cancel "see" mode */ command_see = FALSE; /* Flush messages XXX XXX XXX */ msg_print(NULL); /* Clear the screen */ Term_clear(); /* Update everything */ p_ptr->update |= (PU_VIEW | PU_MON_LITE); p_ptr->update |= (PU_MONSTERS); /* Redraw entire screen */ flag_bool(&p_ptr->redraw, FLAG_PR_BASIC); flag_bool(&p_ptr->redraw, FLAG_PR_EXTRA); /* Redraw map */ flag_bool(&p_ptr->redraw, FLAG_PR_MAP); /* Window stuff */ flag_bool(&p_ptr->window, FLAG_PW_OVERHEAD); }
/* * Hack -- redraw the screen * * This command performs various low level updates, clears all the "extra" * windows, does a total redraw of the main window, and requests all of the * interesting updates and redraws that I can think of. * * This command is also used to "instantiate" the results of the user * selecting various things, such as graphics mode, so it must call * the "TERM_XTRA_REACT" hook before redrawing the windows. */ void do_cmd_redraw(void) { s32b j; term *old = Term; /* Hack -- react to changes */ Term_xtra(TERM_XTRA_REACT, 0); /* Combine and Reorder the pack (later) */ p_ptr->notice |= (PN_COMBINE | PN_REORDER); /* Update torch */ p_ptr->update |= (PU_TORCH); /* Update stuff */ p_ptr->update |= (PU_BONUS | PU_HP | PU_MANA | PU_SPELLS | PU_POWERS | PU_SANITY | PU_BODY); /* Forget view */ p_ptr->update |= (PU_UN_VIEW); /* Update view */ p_ptr->update |= (PU_VIEW); /* Update monster light */ p_ptr->update |= (PU_MON_LITE); /* Update monsters */ p_ptr->update |= (PU_MONSTERS); /* Redraw everything */ flag_bool(&p_ptr->redraw, FLAG_PR_WIPE); flag_bool(&p_ptr->redraw, FLAG_PR_BASIC); flag_bool(&p_ptr->redraw, FLAG_PR_EXTRA); flag_bool(&p_ptr->redraw, FLAG_PR_MAP); /* Window stuff */ flag_bool(&p_ptr->window, FLAG_PW_ALL); /* Hack -- update */ handle_stuff(); /* Redraw every window */ for (j = 0; j < 8; j++) { /* Dead window */ if (!angband_term[j]) continue; /* Activate */ Term_activate(angband_term[j]); /* Redraw */ Term_redraw(); /* Refresh */ Term_fresh(); /* Restore */ Term_activate(old); } }