diff --git a/common/events.cpp b/common/events.cpp index bf6a71f6ca..2241f72005 100644 --- a/common/events.cpp +++ b/common/events.cpp @@ -158,11 +158,13 @@ static struct { GEN_EV(E_UNIT_LOST_ATT, E_S_UNIT, N_("Attack Failed")), GEN_EV(E_UNIT_TIE_ATT, E_S_UNIT, N_("Attack Tied")), GEN_EV(E_UNIT_WIN_ATT, E_S_UNIT, N_("Attack Succeeded")), + GEN_EV(E_UNIT_BOMB_ATT, E_S_UNIT, N_("Attacker Bombarding")), GEN_EV(E_UNIT_BUY, E_S_UNIT, N_("Bought")), GEN_EV(E_UNIT_BUILT, E_S_UNIT, N_("Built")), GEN_EV(E_UNIT_LOST_DEF, E_S_UNIT, N_("Defender Destroyed")), GEN_EV(E_UNIT_TIE_DEF, E_S_UNIT, N_("Defender Tied")), GEN_EV(E_UNIT_WIN_DEF, E_S_UNIT, N_("Defender Survived")), + GEN_EV(E_UNIT_BOMB_DEF, E_S_UNIT, N_("Defender Bombarded")), GEN_EV(E_UNIT_BECAME_VET, E_S_UNIT, N_("Promoted to Veteran")), GEN_EV(E_UNIT_LOST_MISC, E_S_UNIT, N_("Lost Outside Battle")), GEN_EV(E_UNIT_UPGRADED, E_S_UNIT, N_("Production Upgraded")), diff --git a/common/events.h b/common/events.h index 5923113a9e..c119b6fa27 100644 --- a/common/events.h +++ b/common/events.h @@ -168,6 +168,9 @@ // Combat without winner (Combat_Rounds) #define SPECENUM_VALUE136 E_UNIT_TIE_ATT #define SPECENUM_VALUE137 E_UNIT_TIE_DEF +// bombarding +#define SPECENUM_VALUE138 E_UNIT_BOMB_ATT +#define SPECENUM_VALUE139 E_UNIT_BOMB_DEF /* * Note: If you add a new event, make sure you make a similar change diff --git a/data/misc/events.png b/data/misc/events.png index 50cb4f3200..e0946f5c46 100644 Binary files a/data/misc/events.png and b/data/misc/events.png differ diff --git a/data/misc/events.spec b/data/misc/events.spec index 65216e9422..24ab32465c 100644 --- a/data/misc/events.spec +++ b/data/misc/events.spec @@ -120,6 +120,8 @@ tiles = { "row", "column", "tag" 4, 9, "e_my_spy_nuke" 4, 10, "e_my_spy_steal_map" ; 4, 11, "e_embassy_was_expelled" + 4, 12, "e_unit_bomb_att" + 4, 13, "e_unit_bomb_def" ; 5, 0, "e_enemy_diplomat_escape" ; base sprite for enemy diplomats 5, 1, "e_enemy_diplomat_bribe" diff --git a/data/stdsounds.soundspec b/data/stdsounds.soundspec index fbbf0b5512..259bb9bee2 100644 --- a/data/stdsounds.soundspec +++ b/data/stdsounds.soundspec @@ -310,7 +310,9 @@ e_log_fatal = "stdsounds/LrgExpl.ogg" ; [warzone] ;e_unit_upgraded = "" ;e_unit_tie_def = "" ;e_unit_win_def = "" +;e_unit_bomb_def = "" ;e_unit_tie_att = "" +;e_unit_bomb_att = "" ;e_unit_win_att = "" ;e_unit_did_expel = "" ;e_unit_was_expelled = "" diff --git a/server/unithand.cpp b/server/unithand.cpp index 32225cb228..bd5dd4b66e 100644 --- a/server/unithand.cpp +++ b/server/unithand.cpp @@ -13,6 +13,7 @@ #include #include +#include // utility #include "astring.h" @@ -3692,6 +3693,7 @@ static bool unit_bombard(struct unit *punit, struct tile *ptile, { struct player *pplayer = unit_owner(punit); struct city *pcity = tile_city(ptile); + std::set players_to_notify; // Sanity check: The actor still exists. fc_assert_ret_val(pplayer, false); @@ -3733,20 +3735,7 @@ static bool unit_bombard(struct unit *punit, struct tile *ptile, unit_bombs_unit(punit, pdefender, &att_hp, &def_hp); - notify_player(pplayer, ptile, E_UNIT_WIN_ATT, ftc_server, - /* TRANS: Your Bomber bombards the English Rifleman.*/ - _("Your %s bombards the %s %s."), - unit_name_translation(punit), - nation_adjective_for_player(unit_owner(pdefender)), - unit_name_translation(pdefender)); - - notify_player( - unit_owner(pdefender), ptile, E_UNIT_WIN_DEF, ftc_server, - /* TRANS: Your Rifleman is bombarded by the French Bomber.*/ - _("Your %s is bombarded by the %s %s."), - unit_name_translation(pdefender), - nation_adjective_for_player(pplayer), - unit_name_translation(punit)); + players_to_notify.insert(unit_owner(pdefender)); punit->hp = att_hp; pdefender->hp = def_hp; @@ -3759,11 +3748,11 @@ static bool unit_bombard(struct unit *punit, struct tile *ptile, } unit_list_iterate_safe_end; - // Notify the client + // Notify the client (triggers explosion on tile) see_combat_unit(punit); send_bombardment(punit, ptile); - // Send units about affected units + // Send updates about affected units unit_list_iterate_safe(ptile->units, pdefender) { if (is_unit_reachable_at(pdefender, punit, ptile)) { @@ -3772,6 +3761,25 @@ static bool unit_bombard(struct unit *punit, struct tile *ptile, } unit_list_iterate_safe_end; + // Notify the players hit by the bombardment + for (auto player_to_notify : players_to_notify) { + notify_player( + player_to_notify, ptile, E_UNIT_BOMB_DEF, ftc_server, + /* TRANS: Your units at (x, y) have been bombarded by the French + green Bomber [id:123].*/ + _("Your units at %s were bombarded by a %s %s %s [id:%d]."), + tile_link(ptile), nation_adjective_for_player(pplayer), + unit_veteran_level_string(punit), unit_name_translation(punit), + punit->id); + } + // Notify the player that bombarded + notify_player( + pplayer, ptile, E_UNIT_BOMB_ATT, ftc_server, + /* TRANS: Your green Bomber [id:123] bombarded the units at (x, y).*/ + _("Your %s %s [id:%d] bombarded the units at %s."), + unit_veteran_level_string(punit), unit_name_translation(punit), + punit->id, tile_link(ptile)); + unit_did_action(punit); unit_forget_last_activity(punit); unit_attack_civilian_casualties(punit, pcity, paction, "bombard");