added 'first strike' ability...
...and assigned it to Spearman, Halbardier, and Pikeman
This commit is contained in:
parent
0ee65d38b3
commit
768d90e9db
9 changed files with 43 additions and 13 deletions
|
@ -624,6 +624,11 @@ This attack turns the target to stone. Units that have been turned to stone may
|
|||
weapon_special_berserk_description="Berserk:
|
||||
Whether used offensively or defensively, this attack presses the engagement until one of the combatants is slain."
|
||||
|
||||
weapon_special_firststrike_description="First Strike:
|
||||
This unit always strikes first with this attack, even if they are defending."
|
||||
|
||||
weapon_special_firststrike="first strike"
|
||||
|
||||
#Multiplayer lobby/dialogs
|
||||
game_lobby="Game Lobby"
|
||||
shroud="Shroud"
|
||||
|
|
|
@ -11,7 +11,7 @@ alignment=lawful
|
|||
advanceto=null
|
||||
cost=52
|
||||
usage=fighter
|
||||
unit_description="The best of the soldiers are choosen to become Halberdiers. Their weapon, though a little slower than the sword, can strike with deadly force."
|
||||
unit_description="The best of the soldiers are choosen to become Halberdiers. Their weapon, though a little slower than the sword, can strike with deadly force. Because of the great length of their weapons, Halbardiers always strike first in combat, even when defending."
|
||||
get_hit_sound=groan.wav
|
||||
[attack]
|
||||
name=halberd
|
||||
|
@ -19,6 +19,7 @@ get_hit_sound=groan.wav
|
|||
range=short
|
||||
damage=14
|
||||
number=4
|
||||
special=firststrike
|
||||
[/attack]
|
||||
[attack]
|
||||
name=halberd
|
||||
|
@ -26,5 +27,6 @@ get_hit_sound=groan.wav
|
|||
range=short
|
||||
damage=11
|
||||
number=4
|
||||
special=first strike
|
||||
[/attack]
|
||||
[/unit]
|
||||
|
|
|
@ -11,7 +11,7 @@ alignment=lawful
|
|||
advanceto=Halbardier
|
||||
cost=22
|
||||
usage=fighter
|
||||
unit_description="Pikemen are more experienced soldiers who have changed their spears for long pikes. They can be deadly when fighting cavalry."
|
||||
unit_description="Pikemen are more experienced soldiers who have changed their spears for long pikes. Because of the length of their weapons, they always strike first in combat, even when defending. They are especially deadly when fighting cavalry."
|
||||
get_hit_sound=groan.wav
|
||||
[attack]
|
||||
name=pike
|
||||
|
@ -19,5 +19,6 @@ get_hit_sound=groan.wav
|
|||
range=short
|
||||
damage=14
|
||||
number=2
|
||||
special=firststrike
|
||||
[/attack]
|
||||
[/unit]
|
||||
|
|
|
@ -12,7 +12,7 @@ alignment=lawful
|
|||
advanceto=Swordsman,Pikeman
|
||||
cost=14
|
||||
usage=fighter
|
||||
unit_description="Spearmen are the core of the human armies. These young soldiers are given basic training and put in the front lines to do the bulk of the fighting."
|
||||
unit_description="Spearmen are the core of the human armies. These young soldiers are given basic training and put in the front lines to do the bulk of the fighting. Because of the length of their spears, they strike first in combat, even when defending."
|
||||
get_hit_sound=groan.wav
|
||||
[attack]
|
||||
name=spear
|
||||
|
@ -20,6 +20,7 @@ get_hit_sound=groan.wav
|
|||
range=short
|
||||
damage=7
|
||||
number=3
|
||||
special=firststrike
|
||||
[frame]
|
||||
begin=-100
|
||||
end=100
|
||||
|
|
|
@ -209,6 +209,7 @@ battle_stats evaluate_battle_stats(
|
|||
|
||||
static const std::string to_the_death_string("berserk");
|
||||
res.to_the_death = attack.special() == to_the_death_string;
|
||||
res.defender_strikes_first = false;
|
||||
|
||||
static const std::string backstab_string("backstab");
|
||||
if(attack.special() == backstab_string) {
|
||||
|
@ -385,6 +386,9 @@ battle_stats evaluate_battle_stats(
|
|||
}
|
||||
|
||||
res.defender_plague = (defender_attacks[defend].special() == plague_string);
|
||||
|
||||
static const std::string first_strike = "firststrike";
|
||||
res.defender_strikes_first = defender_attacks[defend].special() == first_strike && attack.special() != first_strike;
|
||||
}
|
||||
|
||||
if(attack.special() == magical_string)
|
||||
|
@ -549,7 +553,7 @@ void attack(display& gui, const gamemap& map,
|
|||
while(stats.nattacks > 0 || stats.ndefends > 0) {
|
||||
std::cerr << "start of attack loop...\n";
|
||||
|
||||
if(stats.nattacks > 0) {
|
||||
if(stats.nattacks > 0 && stats.defender_strikes_first == false) {
|
||||
const int ran_num = get_random();
|
||||
bool hits = (ran_num%100) < stats.chance_to_hit_defender;
|
||||
|
||||
|
@ -686,6 +690,9 @@ void attack(display& gui, const gamemap& map,
|
|||
--stats.nattacks;
|
||||
}
|
||||
|
||||
//if the defender got to strike first, they use it up here.
|
||||
stats.defender_strikes_first = false;
|
||||
|
||||
if(stats.ndefends > 0) {
|
||||
std::cerr << "doing defender attack...\n";
|
||||
|
||||
|
@ -1230,6 +1237,10 @@ void advance_unit(const game_data& info,
|
|||
std::map<gamemap::location,unit>& units,
|
||||
gamemap::location loc, const std::string& advance_to)
|
||||
{
|
||||
if(units.count(loc) == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
const unit& new_unit = get_advanced_unit(info,units,loc,advance_to);
|
||||
|
||||
statistics::advance_unit(new_unit);
|
||||
|
|
|
@ -59,7 +59,7 @@ struct battle_stats
|
|||
int attack_with, defend_with;
|
||||
bool attacker_plague, defender_plague;
|
||||
std::vector<std::string> attack_calculations, defend_calculations;
|
||||
bool to_the_death;
|
||||
bool to_the_death, defender_strikes_first;
|
||||
};
|
||||
|
||||
//evaluate_battle_stats: a function which, if given an attacker
|
||||
|
|
|
@ -376,8 +376,10 @@ void ai::attack_analysis::analyze(const gamemap& map,
|
|||
terrain_quality += (double(stat.chance_to_hit_attacker)/100.0)*cost * (on_village ? 0.5 : 1.0);
|
||||
resources_used += cost;
|
||||
|
||||
bool defender_strikes_first = stat.defender_strikes_first;
|
||||
|
||||
while(attacks || defends) {
|
||||
if(attacks) {
|
||||
if(attacks && !defender_strikes_first) {
|
||||
const int roll = rand()%100;
|
||||
if(roll < stat.chance_to_hit_defender) {
|
||||
defhp -= stat.damage_defender_takes;
|
||||
|
@ -394,6 +396,8 @@ void ai::attack_analysis::analyze(const gamemap& map,
|
|||
--attacks;
|
||||
}
|
||||
|
||||
defender_strikes_first = false;
|
||||
|
||||
if(defends) {
|
||||
const int roll = rand()%100;
|
||||
if(roll < stat.chance_to_hit_attacker) {
|
||||
|
|
|
@ -326,12 +326,13 @@ void turn_info::mouse_motion(const SDL_MouseMotionEvent& event)
|
|||
!current_paths_.routes.empty() && map_.on_board(selected_hex_) &&
|
||||
map_.on_board(new_hex)) {
|
||||
|
||||
unit_map::const_iterator un = find_visible_unit(units_,
|
||||
selected_hex_,
|
||||
map_,
|
||||
status_.get_time_of_day().lawful_bonus,teams_,current_team);
|
||||
unit_map::const_iterator un = find_visible_unit(units_,selected_hex_,map_,
|
||||
status_.get_time_of_day().lawful_bonus,teams_,current_team);
|
||||
|
||||
if(un != units_.end()) {
|
||||
const unit_map::const_iterator dest_un = find_visible_unit(units_,new_hex,map_,
|
||||
status_.get_time_of_day().lawful_bonus,teams_,current_team);
|
||||
|
||||
if(un != units_.end() && dest_un != units_.end()) {
|
||||
const shortest_path_calculator calc(un->second,current_team,
|
||||
units_,teams_,map_,status_);
|
||||
const bool can_teleport = un->second.type().teleports();
|
||||
|
|
|
@ -189,8 +189,6 @@ void unit_die(display& disp, const gamemap::location& loc, const unit& u)
|
|||
|
||||
disp.update_display();
|
||||
}
|
||||
|
||||
disp.draw(true,true);
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
@ -411,6 +409,9 @@ bool unit_attack_ranged(display& disp, unit_map& units, const gamemap& map,
|
|||
else if(missile_halo_effect != 0) {
|
||||
halo::set_location(missile_halo_effect,halo_xpos,halo_ypos);
|
||||
}
|
||||
} else {
|
||||
//the missile halo should disappear now, since the missile has stopped being shown
|
||||
missile_halo_effect.assign(0);
|
||||
}
|
||||
|
||||
const int wait_time = ticks + time_resolution - SDL_GetTicks();
|
||||
|
@ -451,6 +452,8 @@ bool unit_attack_ranged(display& disp, unit_map& units, const gamemap& map,
|
|||
unit_die(disp,def->first,def->second);
|
||||
}
|
||||
|
||||
disp.update_display();
|
||||
|
||||
return dead;
|
||||
}
|
||||
|
||||
|
@ -719,6 +722,8 @@ bool unit_attack(display& disp, unit_map& units, const gamemap& map,
|
|||
unit_display::unit_die(disp,def->first,def->second);
|
||||
}
|
||||
|
||||
disp.update_display();
|
||||
|
||||
return dead;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue