added AI improvements/fixes
This commit is contained in:
parent
970553ae6d
commit
78ab068286
8 changed files with 28 additions and 13 deletions
|
@ -12,7 +12,7 @@
|
|||
|
||||
turns=30
|
||||
id=North_Elves
|
||||
next_scenario=null
|
||||
next_scenario=Elven_Council
|
||||
|
||||
objectives="
|
||||
Victory:
|
||||
|
@ -265,12 +265,12 @@ Defeat:
|
|||
[/if]
|
||||
[/event]
|
||||
|
||||
[endlevel]
|
||||
[event]
|
||||
name=victory
|
||||
[message]
|
||||
id=nelves_17
|
||||
description=El'rien
|
||||
message="Elven friends, you have made it to safety!"
|
||||
message="Elf-friends, you have made it to safety!"
|
||||
[/message]
|
||||
[message]
|
||||
id=nelves_18
|
||||
|
@ -282,7 +282,7 @@ Defeat:
|
|||
description=El'rien
|
||||
message="Indeed. We will escort you to our capital, where we will make Council."
|
||||
[/message]
|
||||
[/endlevel]
|
||||
[/event]
|
||||
|
||||
{deaths.cfg}
|
||||
[/scenario]
|
||||
|
|
|
@ -9,7 +9,7 @@ experience=500
|
|||
level=2
|
||||
alignment=neutral
|
||||
advanceto=null
|
||||
cost=40
|
||||
cost=30
|
||||
usage=scout
|
||||
unit_description="The swiftest of riders, the Outrider is fast in forest as well as in the open. They can even use a bow from horseback, firing arrows at their enemies."
|
||||
get_hit_sound=groan.wav
|
||||
|
|
|
@ -10,7 +10,7 @@ experience=500
|
|||
level=2
|
||||
alignment=chaotic
|
||||
advanceto=null
|
||||
cost=22
|
||||
cost=28
|
||||
usage=scout
|
||||
unit_description="Some goblins train their wolves to overcome their fear of fire. Wielding torches and nets, Goblin Pillagers bring havoc to their enemies."
|
||||
get_hit_sound=groan.wav
|
||||
|
|
10
src/ai.cpp
10
src/ai.cpp
|
@ -249,7 +249,7 @@ void do_move(display& disp, const gamemap& map, const game_data& gameinfo,
|
|||
}
|
||||
}
|
||||
|
||||
const unit_map::iterator leader = find_leader(units,team_num);
|
||||
unit_map::iterator leader = find_leader(units,team_num);
|
||||
|
||||
//no moves left, recruitment phase and leader movement phase
|
||||
//take stock of our current set of units
|
||||
|
@ -270,10 +270,12 @@ void do_move(display& disp, const gamemap& map, const game_data& gameinfo,
|
|||
if(leader->first != start_pos) {
|
||||
leader_moved = true;
|
||||
const paths::routes_map::const_iterator itor = leader_paths.routes.find(start_pos);
|
||||
if(itor != leader_paths.routes.end()) {
|
||||
if(itor != leader_paths.routes.end() && units.count(start_pos) == 0) {
|
||||
move_unit(gameinfo,disp,map,units,leader->first,start_pos,
|
||||
possible_moves,teams,team_num);
|
||||
|
||||
|
||||
leader = find_leader(units,team_num);
|
||||
assert(leader != units.end());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -336,7 +338,7 @@ void do_move(display& disp, const gamemap& map, const game_data& gameinfo,
|
|||
for(std::vector<gamemap::location>::const_iterator v = villages.begin();
|
||||
v != villages.end(); ++v) {
|
||||
const paths::routes_map::const_iterator itor = leader_paths.routes.find(*v);
|
||||
if(itor == leader_paths.routes.end()) {
|
||||
if(itor == leader_paths.routes.end() || units.count(*v) != 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
|
|
@ -758,6 +758,8 @@ void event_handler::handle_event_command(const queued_event& event_info, const s
|
|||
if(result.empty() || result == "victory") {
|
||||
const bool bonus = cfg["bonus"] == "yes";
|
||||
throw end_level_exception(VICTORY,bonus);
|
||||
} else if(result == "continue") {
|
||||
throw end_level_exception(CONTINUE);
|
||||
} else {
|
||||
throw end_level_exception(DEFEAT);
|
||||
}
|
||||
|
|
|
@ -210,7 +210,15 @@ LEVEL_RESULT play_level(game_data& gameinfo, config& game_config,
|
|||
|
||||
const teams_manager team_manager(teams);
|
||||
|
||||
const config* const theme_cfg = game_config.find_child("theme","name",preferences::theme());
|
||||
const config* theme_cfg = NULL;
|
||||
if((*level)["theme"] != "") {
|
||||
theme_cfg = game_config.find_child("theme","name",(*level)["theme"]);
|
||||
}
|
||||
|
||||
if(theme_cfg == NULL) {
|
||||
theme_cfg = game_config.find_child("theme","name",preferences::theme());
|
||||
}
|
||||
|
||||
const config dummy_cfg;
|
||||
display gui(units,video,map,status,teams,theme_cfg != NULL ? *theme_cfg : dummy_cfg);
|
||||
|
||||
|
@ -526,6 +534,9 @@ redo_turn:
|
|||
string_table["defeat_message"],
|
||||
gui::OK_ONLY);
|
||||
return DEFEAT;
|
||||
} else if(end_level.result == CONTINUE) {
|
||||
//basically like a victory but without all the celebrations
|
||||
return VICTORY;
|
||||
} else if(end_level.result == VICTORY) {
|
||||
try {
|
||||
game_events::fire("victory");
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
#include <sstream>
|
||||
#include <string>
|
||||
|
||||
enum LEVEL_RESULT { VICTORY, DEFEAT, QUIT, REPLAY };
|
||||
enum LEVEL_RESULT { VICTORY, DEFEAT, QUIT, REPLAY, CONTINUE };
|
||||
|
||||
struct end_level_exception {
|
||||
end_level_exception(LEVEL_RESULT res, bool bonus=true)
|
||||
|
|
|
@ -118,7 +118,7 @@ size_t menu::max_items_onscreen() const
|
|||
return size_t(max_items_);
|
||||
}
|
||||
|
||||
const size_t max_height = max_height_ == -1 ? (display_->y()*7)/10 : max_height_;
|
||||
const size_t max_height = max_height_ == -1 ? (display_->y()*6)/10 : max_height_;
|
||||
std::vector<int> heights;
|
||||
size_t n;
|
||||
for(n = 0; n != items_.size(); ++n) {
|
||||
|
|
Loading…
Add table
Reference in a new issue