removed floating point calculations from time of day bonus/penalty
This commit is contained in:
parent
0b15e95855
commit
1913db85ca
4 changed files with 27 additions and 20 deletions
|
@ -237,9 +237,9 @@ battle_stats evaluate_battle_stats(
|
|||
if(defender_attacks[defend].special() == magical_string)
|
||||
res.chance_to_hit_attacker = 70;
|
||||
|
||||
res.damage_attacker_takes = int(double(
|
||||
a->second.damage_against(defender_attacks[defend]))
|
||||
* combat_modifier(state,units,d->first,d->second.type().alignment()));
|
||||
const int base_damage = a->second.damage_against(defender_attacks[defend]);
|
||||
const int modifier = combat_modifier(state,units,d->first,d->second.type().alignment());
|
||||
res.damage_attacker_takes = (base_damage * (100+modifier))/100;
|
||||
|
||||
if(charge)
|
||||
res.damage_attacker_takes *= 2;
|
||||
|
@ -278,10 +278,10 @@ battle_stats evaluate_battle_stats(
|
|||
if(res.chance_to_hit_defender < 60 && attack.special() == marksman_string)
|
||||
res.chance_to_hit_defender = 60;
|
||||
|
||||
res.damage_defender_takes = int(util::round(
|
||||
double(d->second.damage_against(attack))
|
||||
* combat_modifier(state,units,a->first,a->second.type().alignment())))
|
||||
* (charge ? 2 : 1) * (backstab ? 2 : 1);
|
||||
const int base_damage = d->second.damage_against(attack);
|
||||
const int modifier = combat_modifier(state,units,a->first,a->second.type().alignment());
|
||||
res.damage_defender_takes = ((d->second.damage_against(attack) * (100 + modifier))/100)
|
||||
* (charge ? 2 : 1) * (backstab ? 2 : 1);
|
||||
|
||||
if(under_leadership(units,attacker))
|
||||
res.damage_defender_takes += res.damage_defender_takes/8 + 1;
|
||||
|
@ -774,10 +774,10 @@ const time_of_day& timeofday_at(const gamestatus& status,
|
|||
return status.get_time_of_day(lighten);
|
||||
}
|
||||
|
||||
double combat_modifier(const gamestatus& status,
|
||||
const std::map<gamemap::location,unit>& units,
|
||||
const gamemap::location& loc,
|
||||
unit_type::ALIGNMENT alignment)
|
||||
int combat_modifier(const gamestatus& status,
|
||||
const std::map<gamemap::location,unit>& units,
|
||||
const gamemap::location& loc,
|
||||
unit_type::ALIGNMENT alignment)
|
||||
{
|
||||
const time_of_day& tod = timeofday_at(status,units,loc);
|
||||
|
||||
|
|
|
@ -142,10 +142,10 @@ const time_of_day& timeofday_at(const gamestatus& status,
|
|||
|
||||
//returns the amount that a unit's damage should be multiplied by due to
|
||||
//the current time of day.
|
||||
double combat_modifier(const gamestatus& status,
|
||||
const std::map<gamemap::location,unit>& units,
|
||||
const gamemap::location& loc,
|
||||
unit_type::ALIGNMENT alignment);
|
||||
int combat_modifier(const gamestatus& status,
|
||||
const std::map<gamemap::location,unit>& units,
|
||||
const gamemap::location& loc,
|
||||
unit_type::ALIGNMENT alignment);
|
||||
|
||||
//structure which records information to be able to undo a movement
|
||||
struct undo_action {
|
||||
|
|
|
@ -804,8 +804,8 @@ int play_multiplayer(display& disp, game_data& units_data, config cfg,
|
|||
level_ptr = levels[maps_menu.selection()];
|
||||
|
||||
std::string map_data = (*level_ptr)["map_data"];
|
||||
if(map_data == "") {
|
||||
map_data = read_file("data/maps/" + level_ptr->values["map"]);
|
||||
if(map_data == "" && (*level_ptr)["map"] != "") {
|
||||
map_data = read_file("data/maps/" + (*level_ptr)["map"]);
|
||||
}
|
||||
|
||||
gamemap map(cfg,map_data);
|
||||
|
|
|
@ -35,7 +35,7 @@ LEVEL_RESULT play_level(game_data& gameinfo, config& terrain_config,
|
|||
gamestatus status(*level,num_turns);
|
||||
|
||||
std::string map_data = (*level)["map_data"];
|
||||
if(map_data == "") {
|
||||
if(map_data == "" && (*level)["map"] != "") {
|
||||
map_data = read_file("data/maps/" + (*level)["map"]);
|
||||
}
|
||||
|
||||
|
@ -207,8 +207,15 @@ LEVEL_RESULT play_level(game_data& gameinfo, config& terrain_config,
|
|||
if(replaying) {
|
||||
const hotkey::basic_handler key_events_handler(gui);
|
||||
std::cerr << "doing replay " << player_number << "\n";
|
||||
replaying = do_replay(gui,map,gameinfo,units,teams,
|
||||
player_number,status,state_of_game);
|
||||
try {
|
||||
replaying = do_replay(gui,map,gameinfo,units,teams,
|
||||
player_number,status,state_of_game);
|
||||
} catch(replay::error& e) {
|
||||
std::cerr << "caught replay::error\n";
|
||||
gui::show_dialog(gui,NULL,"",string_table["bad_save_message"],gui::OK_ONLY);
|
||||
|
||||
replaying = false;
|
||||
}
|
||||
std::cerr << "result of replay: " << (replaying?"true":"false") << "\n";
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue