//-------------------------------------------------------------------- // Determine best of all possible actions by: // 1) Generating all actions // 2) Weighing all actions // 3) Doing a linear search for the best action in the list //-------------------------------------------------------------------- t_combat_ai_action_ptr t_combat_ai::get_best_action(void) { // Step 1: Generate all actions m_best_action = 0; m_best_action = generate_best_melee_action( *this ); generate_ranged(); generate_spell(); generate_move_actions( *this ); if (m_best_action != 0) return m_best_action; t_battlefield& battlefield = m_actor.get_battlefield(); if (!m_actor.is_waiting()) return new t_combat_ai_wait_action( battlefield ); return new t_combat_ai_defend_action( battlefield ); }
/* * Checks various stuff to do when skills change, like new spells, ... */ void recalc_skills(bool init) { static int thaum_level = 0; /* TODO: This should be a hook in ToME's lua */ if (init) { thaum_level = get_skill_scale(SKILL_THAUMATURGY, 100); } else { int thaum_gain = 0; /* Gain thaum spells */ while (thaum_level < get_skill_scale(SKILL_THAUMATURGY, 100)) { if (spell_num == MAX_SPELLS) break; thaum_level++; generate_spell((thaum_level + 1) / 2); thaum_gain++; } if (thaum_gain) { if (thaum_gain == 1) msg_print("You have gained one new thaumaturgy spell."); else msg_format("You have gained %d new thaumaturgy spells.", thaum_gain); } 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 */ p_ptr->redraw |= (PR_WIPE | PR_BASIC | PR_EXTRA | PR_MAP); } }