Skip to content

Commit

Permalink
improved battle messages (closes #2358)
Browse files Browse the repository at this point in the history
  • Loading branch information
hugomflavio authored and lmoureaux committed Sep 7, 2024
1 parent 7df2969 commit 255ac0f
Show file tree
Hide file tree
Showing 9 changed files with 238 additions and 166 deletions.
2 changes: 2 additions & 0 deletions common/events.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,12 @@ static struct {
GEN_EV(E_TREATY_PEACE, E_S_TREATY, N_("Peace")),
GEN_EV(E_TREATY_SHARED_VISION, E_S_TREATY, N_("Shared Vision")),
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_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_BECAME_VET, E_S_UNIT, N_("Promoted to Veteran")),
GEN_EV(E_UNIT_LOST_MISC, E_S_UNIT, N_("Lost Outside Battle")),
Expand Down
4 changes: 4 additions & 0 deletions common/events.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@
#define SPECENUM_VALUE133 E_UNIT_ACTION_TARGET_OTHER
#define SPECENUM_VALUE134 E_UNIT_ACTION_TARGET_HOSTILE
#define SPECENUM_VALUE135 E_UNIT_WAKE
// --
#define SPECENUM_VALUE136 E_UNIT_TIE_ATT
#define SPECENUM_VALUE137 E_UNIT_TIE_DEF

/*
* Note: If you add a new event, make sure you make a similar change
* to the events array in "common/events.c" using GEN_EV, to
Expand Down
21 changes: 19 additions & 2 deletions common/featured_text.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1164,8 +1164,7 @@ const char *unit_achieved_rank_string(const struct unit *punit)
fc_snprintf(buf, sizeof(buf),
/* TRANS: " and achieved the rank of <veteran level>";
* preserve leading space */
_(" and achieved the rank of %s"),
unit_veteran_level_string(punit));
_(", promoted to %s"), unit_veteran_level_string(punit));
return buf;
}

Expand Down Expand Up @@ -1208,3 +1207,21 @@ const char *unit_firepower_if_not_one(int firepower)
}
return buf;
}

/**
Get string of number of extra units killed by attacker
when a stack is taken down.
N.B.: The returned string is static, so every call to this function
overwrites the previous.
*/
const char *unit_n_stack_kills(int unitcount)
{
static char buf[MAX_LEN_LINK];

if (unitcount > 2) {
fc_snprintf(buf, sizeof(buf), _("%d units were"), unitcount = 1);
} else {
fc_snprintf(buf, sizeof(buf), _("unit was"));
}
return buf;
}
2 changes: 2 additions & 0 deletions common/featured_text.h
Original file line number Diff line number Diff line change
Expand Up @@ -238,3 +238,5 @@ const char *unit_veteran_level_string(const struct unit *punit);
const char *unit_achieved_rank_string(const struct unit *punit);
const char *unit_tired_attack_string(const struct unit *punit);
const char *unit_firepower_if_not_one(int firepower);
const char *unit_firepower_if_not_one(int firepower);
const char *unit_n_stack_kills(int unitcount);
Binary file modified data/misc/events.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
46 changes: 24 additions & 22 deletions data/misc/events.spec
Original file line number Diff line number Diff line change
Expand Up @@ -81,28 +81,30 @@ tiles = { "row", "column", "tag"
2, 11, "e_tech_goal"

3, 0, "e_unit_lost_att"
3, 1, "e_unit_win_att"
3, 1, "e_unit_action_actor_success"
3, 2, "e_unit_buy"
3, 3, "e_unit_built"
3, 4, "e_unit_lost_def"
3, 4, "e_unit_action_target_hostile"
3, 4, "e_unit_wake"
3, 5, "e_unit_lost_misc"
3, 6, "e_unit_became_vet"
3, 7, "e_unit_upgraded"
3, 8, "e_unit_relocated"
3, 9, "e_unit_orders"
3, 10, "e_unit_illegal_action"
3, 11, "e_caravan_action"
3, 12, "e_unit_win_def"
3, 13, "e_unit_escaped"
3, 14, "e_unit_was_expelled"
3, 15, "e_unit_did_expel"
3, 16, "e_unit_action_failed"
3, 17, "e_my_unit_did_heal"
3, 18, "e_my_unit_was_healed"
3, 19, "e_unit_action_target_other"
3, 1, "e_unit_tie_att"
3, 2, "e_unit_win_att"
3, 2, "e_unit_action_actor_success"
3, 3, "e_unit_buy"
3, 4, "e_unit_built"
3, 5, "e_unit_lost_def"
3, 5, "e_unit_action_target_hostile"
3, 5, "e_unit_wake"
3, 6, "e_unit_lost_misc"
3, 7, "e_unit_became_vet"
3, 8, "e_unit_upgraded"
3, 9, "e_unit_relocated"
3, 10, "e_unit_orders"
3, 11, "e_unit_illegal_action"
3, 12, "e_caravan_action"
3, 13, "e_unit_tie_def"
3, 14, "e_unit_win_def"
3, 15, "e_unit_escaped"
3, 16, "e_unit_was_expelled"
3, 17, "e_unit_did_expel"
3, 18, "e_unit_action_failed"
3, 20, "e_my_unit_did_heal"
3, 20, "e_my_unit_was_healed"
3, 20, "e_unit_action_target_other"
3, 20, "e_unit_action_actor_failure"

4, 0, "e_my_diplomat_escape" ; base sprite for my diplomats
Expand Down
2 changes: 2 additions & 0 deletions data/stdsounds.soundspec
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,9 @@ e_log_fatal = "stdsounds/LrgExpl.ogg" ; [warzone]
;e_unit_orders = ""
;e_unit_relocated = ""
;e_unit_upgraded = ""
;e_unit_tie_def = ""
;e_unit_win_def = ""
;e_unit_tie_att = ""
;e_unit_win_att = ""
;e_unit_did_expel = ""
;e_unit_was_expelled = ""
Expand Down
Loading

0 comments on commit 255ac0f

Please sign in to comment.