diff --git a/data/lua/wml/harm_unit.lua b/data/lua/wml/harm_unit.lua index c1e7f1670910..175848ba645d 100644 --- a/data/lua/wml/harm_unit.lua +++ b/data/lua/wml/harm_unit.lua @@ -163,8 +163,8 @@ function wml_actions.harm_unit(cfg) wesnoth.float_label( unit_to_harm.x, unit_to_harm.y, string.format( "%s", text ) ) local function calc_xp( level ) -- to calculate the experience in case of kill - if level == 0 then return 4 - else return level * 8 end + if level == 0 then return math.ceil(wesnoth.game_config.kill_experience / 2) + else return level * wesnoth.game_config.kill_experience end end if experience ~= false and harmer and harmer.valid @@ -174,7 +174,7 @@ function wml_actions.harm_unit(cfg) harmer.experience = harmer.experience + calc_xp( unit_to_harm.__cfg.level ) else unit_to_harm.experience = unit_to_harm.experience + harmer.__cfg.level - harmer.experience = harmer.experience + unit_to_harm.__cfg.level + harmer.experience = harmer.experience + wesnoth.game_config.combat_experience * unit_to_harm.__cfg.level end end diff --git a/src/actions/attack.cpp b/src/actions/attack.cpp index aa04b01e1f0a..fb7e4f22b304 100644 --- a/src/actions/attack.cpp +++ b/src/actions/attack.cpp @@ -1449,8 +1449,8 @@ void attack::perform() d_.orig_attacks_ = d_stats_->num_blows; a_.n_attacks_ = a_.orig_attacks_; d_.n_attacks_ = d_.orig_attacks_; - a_.xp_ = d_.get_unit().level(); - d_.xp_ = a_.get_unit().level(); + a_.xp_ = game_config::combat_xp(d_.get_unit().level()); + d_.xp_ = game_config::combat_xp(a_.get_unit().level()); bool defender_strikes_first = (d_stats_->firststrike && !a_stats_->firststrike); unsigned int rounds = std::max(a_stats_->rounds, d_stats_->rounds) - 1; diff --git a/src/ai/default/attack.cpp b/src/ai/default/attack.cpp index 43cd73ff56bc..0176ad022c0c 100644 --- a/src/ai/default/attack.cpp +++ b/src/ai/default/attack.cpp @@ -194,7 +194,7 @@ void attack_analysis::analyze(const gamemap& map, unit_map& units, if (xp_for_advance == 0) xp_for_advance = 1; - int fight_xp = defend_it->level(); + int fight_xp = game_config::combat_xp(defend_it->level()); int kill_xp = game_config::kill_xp(fight_xp); if (fight_xp >= xp_for_advance) { @@ -233,7 +233,7 @@ void attack_analysis::analyze(const gamemap& map, unit_map& units, * directly. For each level of attacker def gets 1 xp or * kill_experience. */ - int fight_xp = up->level(); + int fight_xp = game_config::combat_xp(up->level()); int kill_xp = game_config::kill_xp(fight_xp); def_avg_experience += fight_xp * (1.0 - att.hp_dist[0]) + kill_xp * att.hp_dist[0]; if (m == movements.begin()) { diff --git a/src/ai/simulated_actions.cpp b/src/ai/simulated_actions.cpp index bd54cefcccf6..2fe5ad7ecd81 100644 --- a/src/ai/simulated_actions.cpp +++ b/src/ai/simulated_actions.cpp @@ -61,8 +61,8 @@ bool simulated_attack(const map_location& attacker_loc, const map_location& defe LOG_AI_SIM_ACTIONS << "attacker's hp after attack: " << attack_unit->hitpoints() << std::endl; LOG_AI_SIM_ACTIONS << "defender's hp after attack: " << defend_unit->hitpoints() << std::endl; - int attacker_xp = defend_unit->level(); - int defender_xp = attack_unit->level(); + int attacker_xp = game_config::combat_xp(defend_unit->level()); + int defender_xp = game_config::combat_xp(attack_unit->level()); bool attacker_died = false; bool defender_died = false; if(attack_unit->hitpoints() <= 0){ diff --git a/src/attack_prediction.cpp b/src/attack_prediction.cpp index bba856c83146..cb3d33f4a0cf 100644 --- a/src/attack_prediction.cpp +++ b/src/attack_prediction.cpp @@ -2035,13 +2035,13 @@ void one_strike_fight(const battle_context_unit_stats& stats, return; } - if(stats.experience + opp_stats.level >= stats.max_experience) { + if(stats.experience + game_config::combat_xp(opp_stats.level) >= stats.max_experience) { forced_levelup(hp_dist); } else if(stats.experience + game_config::kill_xp(opp_stats.level) >= stats.max_experience) { conditional_levelup(hp_dist, opp_hp_dist[0]); } - if(opp_stats.experience + stats.level >= opp_stats.max_experience) { + if(opp_stats.experience + game_config::combat_xp(stats.level) >= opp_stats.max_experience) { forced_levelup(opp_hp_dist); } else if(opp_stats.experience + game_config::kill_xp(stats.level) >= opp_stats.max_experience) { conditional_levelup(opp_hp_dist, hp_dist[0]); @@ -2180,13 +2180,13 @@ void complex_fight(attack_prediction_mode mode, } if(levelup_considered) { - if(stats.experience + opp_stats.level >= stats.max_experience) { + if(stats.experience + game_config::combat_xp(opp_stats.level) >= stats.max_experience) { m->forced_levelup_a(); } else if(stats.experience + game_config::kill_xp(opp_stats.level) >= stats.max_experience) { m->conditional_levelup_a(); } - if(opp_stats.experience + stats.level >= opp_stats.max_experience) { + if(opp_stats.experience + game_config::combat_xp(stats.level) >= opp_stats.max_experience) { m->forced_levelup_b(); } else if(opp_stats.experience + game_config::kill_xp(stats.level) >= opp_stats.max_experience) { m->conditional_levelup_b(); @@ -2447,12 +2447,12 @@ void combatant::fight(combatant& opponent, bool levelup_considered) opponent.slowed = std::min(std::accumulate(opponent.summary[1].begin(), opponent.summary[1].end(), 0.0), 1.0); } - if(u_.experience + opponent.u_.level >= u_.max_experience) { + if(u_.experience + game_config::combat_xp(opponent.u_.level) >= u_.max_experience) { // We'll level up after the battle -> slow/poison will go away poisoned = 0.0; slowed = 0.0; } - if(opponent.u_.experience + u_.level >= opponent.u_.max_experience) { + if(opponent.u_.experience + game_config::combat_xp(u_.level) >= opponent.u_.max_experience) { opponent.poisoned = 0.0; opponent.slowed = 0.0; } diff --git a/src/game_config.cpp b/src/game_config.cpp index 5e830d0938d5..9616eda8a532 100644 --- a/src/game_config.cpp +++ b/src/game_config.cpp @@ -55,6 +55,7 @@ int village_income = 1; int village_support = 1; int recall_cost = 20; int kill_experience = 8; +int combat_experience = 1; int poison_amount = 8; int rest_heal_amount = 2; @@ -269,6 +270,7 @@ void load_config(const config &v) rest_heal_amount = v["rest_heal_amount"].to_int(2); recall_cost = v["recall_cost"].to_int(20); kill_experience = v["kill_experience"].to_int(8); + combat_experience= v["combat_experience"].to_int(1); lobby_refresh = v["lobby_refresh"].to_int(2000); default_terrain = v["default_terrain"].str(); tile_size = v["tile_size"].to_int(72); diff --git a/src/game_config.hpp b/src/game_config.hpp index d086328519a5..352dd2a7a9cf 100644 --- a/src/game_config.hpp +++ b/src/game_config.hpp @@ -34,6 +34,7 @@ namespace game_config extern int rest_heal_amount; extern int recall_cost; extern int kill_experience; + extern int combat_experience; extern unsigned int tile_size; extern unsigned lobby_network_timer; extern unsigned lobby_refresh; @@ -47,6 +48,11 @@ namespace game_config return level ? kill_experience * level : kill_experience / 2; } + inline int combat_xp(int level) + { + return combat_experience * level; + } + extern std::string wesnoth_program_dir; /** Default percentage gold carried over to the next scenario. */ diff --git a/src/scripting/game_lua_kernel.cpp b/src/scripting/game_lua_kernel.cpp index 9e800cc62263..fdefafebc043 100644 --- a/src/scripting/game_lua_kernel.cpp +++ b/src/scripting/game_lua_kernel.cpp @@ -1443,6 +1443,7 @@ int game_lua_kernel::impl_game_config_set(lua_State *L) modify_int_attrib("rest_heal_amount", game_config::rest_heal_amount = value); modify_int_attrib("recall_cost", game_config::recall_cost = value); modify_int_attrib("kill_experience", game_config::kill_experience = value); + modify_int_attrib("combat_experience", game_config::combat_experience = value); modify_int_attrib("last_turn", tod_man().set_number_of_turns_by_wml(value)); modify_string_attrib("next_scenario", gamedata().set_next_scenario(value)); modify_string_attrib("theme", diff --git a/src/scripting/lua_kernel_base.cpp b/src/scripting/lua_kernel_base.cpp index 58f3b036099f..d2af6b628d85 100644 --- a/src/scripting/lua_kernel_base.cpp +++ b/src/scripting/lua_kernel_base.cpp @@ -878,6 +878,7 @@ int lua_kernel_base::impl_game_config_get(lua_State* L) return_int_attrib("rest_heal_amount", game_config::rest_heal_amount); return_int_attrib("recall_cost", game_config::recall_cost); return_int_attrib("kill_experience", game_config::kill_experience); + return_int_attrib("combat_experience", game_config::combat_experience); return_string_attrib("version", game_config::wesnoth_version.str()); return_bool_attrib("debug", game_config::debug); return_bool_attrib("debug_lua", game_config::debug_lua);