mirror of
https://github.com/wesnoth/wesnoth
synced 2025-05-17 11:28:16 +00:00
fixed choose_weapon assertion failure
This commit is contained in:
parent
2f2bb402fc
commit
df1425f318
@ -83,13 +83,13 @@ Defeat:
|
||||
canrecruit=1
|
||||
recruit=Orcish Warrior,Wolf Rider,Orcish Crossbow,Orcish Assassin,Troll Warrior
|
||||
#ifdef EASY
|
||||
gold=400
|
||||
gold=250
|
||||
#endif
|
||||
#ifdef NORMAL
|
||||
gold=450
|
||||
gold=300
|
||||
#endif
|
||||
#ifdef HARD
|
||||
gold=500
|
||||
gold=350
|
||||
#endif
|
||||
enemy=1
|
||||
[/side]
|
||||
@ -99,15 +99,17 @@ Defeat:
|
||||
description=Urug-Tan
|
||||
side=3
|
||||
canrecruit=1
|
||||
recruit=Orcish Grunt,Goblin Knight,Orcish Crossbow,Orcish Assassin,Troll Warrior
|
||||
#ifdef EASY
|
||||
gold=450
|
||||
recruit=Orcish Grunt,Wolf Rider,Orcish Archer,Orcish Assassin,Troll
|
||||
gold=250
|
||||
#endif
|
||||
#ifdef NORMAL
|
||||
gold=500
|
||||
recruit=Orcish Grunt,Goblin Knight,Orcish Crossbow,Orcish Assassin,Troll Warrior
|
||||
gold=300
|
||||
#endif
|
||||
#ifdef HARD
|
||||
gold=550
|
||||
recruit=Orcish Warrior,Goblin Knight,Orcish Crossbow,Orcish Assassin,Troll Warrior
|
||||
gold=350
|
||||
#endif
|
||||
enemy=1
|
||||
[/side]
|
||||
@ -120,13 +122,13 @@ Defeat:
|
||||
canrecruit=1
|
||||
recruit=Orcish Warrior,Wolf Rider,Orcish Crossbow,Troll Warrior,Orcish Slayer
|
||||
#ifdef EASY
|
||||
gold=450
|
||||
gold=250
|
||||
#endif
|
||||
#ifdef NORMAL
|
||||
gold=500
|
||||
gold=300
|
||||
#endif
|
||||
#ifdef HARD
|
||||
gold=550
|
||||
gold=350
|
||||
#endif
|
||||
enemy=1
|
||||
[/side]
|
||||
@ -229,7 +231,7 @@ Defeat:
|
||||
message="A monster was hiding in that lake!"
|
||||
[/message]
|
||||
[role]
|
||||
type=Thief,Rogue,Mage,Elvish Shaman,Elvish Druid,Elvish Archer,Elvish Fighter,Elvish Captain,Elvish Marshal,Horseman
|
||||
type=Thief,Rogue,Mage,Elvish Shaman,Elvish Druid,Elvish Archer,Elvish Fighter,Elvish Captain,Elvish Marshal,Horseman,Elvish Lord
|
||||
role=whiner
|
||||
[/role]
|
||||
[message]
|
||||
|
51
src/ai.cpp
51
src/ai.cpp
@ -536,41 +536,44 @@ void do_move(display& disp, const gamemap& map, const game_data& gameinfo,
|
||||
|
||||
std::cout << "move: " << move.first.x << ", " << move.first.y << " - " << move.second.x << ", " << move.second.y << "\n";
|
||||
|
||||
std::cout << "calling move_unit\n";
|
||||
move_unit(gameinfo,disp,map,units,move.first,move.second,
|
||||
possible_moves,teams,team_num);
|
||||
std::cout << "end move_unit\n";
|
||||
|
||||
//search to see if there are any enemy units next
|
||||
//to the tile which really should be attacked
|
||||
//to the tile which really should be attacked once the move is done
|
||||
gamemap::location adj[6];
|
||||
get_adjacent_tiles(move.second,adj);
|
||||
battle_stats bat_stats;
|
||||
gamemap::location target;
|
||||
int weapon = -1;
|
||||
for(int n = 0; n != 6; ++n) {
|
||||
const unit_map::iterator enemy = units.find(adj[n]);
|
||||
if(enemy != units.end() &&
|
||||
current_team.is_enemy(enemy->second.side())) {
|
||||
battle_stats stats;
|
||||
const int weapon = choose_weapon(map,units,state,gameinfo,
|
||||
move.second,adj[n],stats,
|
||||
map[move.second.x][move.second.y]);
|
||||
assert(weapon != -1);
|
||||
|
||||
const location attacker = move.second;
|
||||
const location defender = adj[n];
|
||||
|
||||
recorder.add_attack(attacker,defender,weapon);
|
||||
|
||||
game_events::fire("attack",attacker,defender);
|
||||
if(units.count(attacker) && units.count(defender)) {
|
||||
attack(disp,map,attacker,defender,weapon,units,state,
|
||||
gameinfo,false);
|
||||
check_victory(units,teams);
|
||||
}
|
||||
|
||||
target = adj[n];
|
||||
weapon = choose_weapon(map,units,state,gameinfo,move.first,
|
||||
target,bat_stats,
|
||||
map[move.second.x][move.second.y]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
move_unit(gameinfo,disp,map,units,move.first,move.second,
|
||||
possible_moves,teams,team_num);
|
||||
|
||||
//if we're going to attack someone
|
||||
if(weapon != -1) {
|
||||
|
||||
const location& attacker = move.second;
|
||||
|
||||
recorder.add_attack(attacker,target,weapon);
|
||||
|
||||
game_events::fire("attack",attacker,target);
|
||||
if(units.count(attacker) && units.count(target)) {
|
||||
attack(disp,map,attacker,target,weapon,units,state,
|
||||
gameinfo,false);
|
||||
check_victory(units,teams);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
//don't allow any other units to move onto the tile our unit
|
||||
//just moved onto
|
||||
typedef std::multimap<location,location>::iterator Itor;
|
||||
|
@ -175,6 +175,8 @@ int choose_weapon(const gamemap& map, std::map<location,unit>& units,
|
||||
cur_stats = cache_itor->stats;
|
||||
|
||||
if(!(size_t(cache_itor->weapon) < itor->second.attacks().size())) {
|
||||
std::cerr << "cached illegal weapon: " << cache_itor->weapon
|
||||
<< "/" << itor->second.attacks().size() << "\n";
|
||||
}
|
||||
|
||||
assert(size_t(cache_itor->weapon) < itor->second.attacks().size());
|
||||
|
Loading…
x
Reference in New Issue
Block a user