Skip to content

Commit 81a1f36

Browse files
author
WALL OF JUSTICE
committed
* thank the tank can handle multiple enemies and arrow attacks, rhythm of the knight only awards achievement once
1 parent fc9b84c commit 81a1f36

File tree

5 files changed

+41
-27
lines changed

5 files changed

+41
-27
lines changed

src/actarrow.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1215,6 +1215,21 @@ void actArrow(Entity* my)
12151215
}
12161216
}
12171217

1218+
if ( hit.entity->behavior == &actPlayer )
1219+
{
1220+
if ( parent )
1221+
{
1222+
if ( hitstats->defending )
1223+
{
1224+
updateAchievementThankTheTank(hit.entity->skill[2], parent, false);
1225+
}
1226+
else
1227+
{
1228+
achievementThankTheTankPair[hit.entity->skill[2]].erase(parent->getUID());
1229+
}
1230+
}
1231+
}
1232+
12181233
bool armorDegraded = false;
12191234

12201235
// hit armor degrade

src/entity.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10962,10 +10962,6 @@ void Entity::attack(int pose, int charge, Entity* target)
1096210962
messagePlayerMonsterEvent(playerhit, color, *myStats, Language::get(698), Language::get(699), MSG_ATTACKS);
1096310963
if ( playerhit >= 0 )
1096410964
{
10965-
if ( !achievementStatusThankTheTank[playerhit] )
10966-
{
10967-
achievementThankTheTankPair[playerhit] = std::make_pair(0, 0);
10968-
}
1096910965
if ( behavior == &actMonster )
1097010966
{
1097110967
updateAchievementBaitAndSwitch(playerhit, false);
@@ -11044,6 +11040,7 @@ void Entity::attack(int pose, int charge, Entity* target)
1104411040
{
1104511041
achievementStatusRhythmOfTheKnight[playerhit] = false;
1104611042
achievementRhythmOfTheKnightVec[playerhit].clear();
11043+
achievementThankTheTankPair[playerhit].erase(this->getUID());
1104711044
//messagePlayer(0, "used AC!");
1104811045
}
1104911046
}

src/game.cpp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1538,9 +1538,6 @@ void gameLogic(void)
15381538
if ( achievementStatusThankTheTank[c] )
15391539
{
15401540
steamAchievementClient(c, "BARONY_ACH_THANK_THE_TANK");
1541-
achievementStatusThankTheTank[c] = false;
1542-
achievementThankTheTankPair[c].first = 0;
1543-
achievementThankTheTankPair[c].second = 0;
15441541
}
15451542

15461543
int bodyguards = 0;

src/scores.cpp

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,8 @@ Sint32 conductGameChallenges[NUM_CONDUCT_CHALLENGES] = { 0 }; // additional 'con
4040
Sint32 gameStatistics[NUM_GAMEPLAY_STATISTICS] = { 0 }; // general saved game statistics to be stored in here.
4141
std::vector<std::pair<Uint32, Uint32>> achievementRhythmOfTheKnightVec[MAXPLAYERS] = {};
4242
bool achievementStatusRhythmOfTheKnight[MAXPLAYERS] = { false };
43-
std::pair<Uint32, Uint32> achievementThankTheTankPair[MAXPLAYERS] = { std::make_pair(0, 0) };
43+
bool achievementRhythmOfTheKnight[MAXPLAYERS] = { false };
44+
std::map<Uint32, Uint32> achievementThankTheTankPair[MAXPLAYERS];
4445
bool achievementStatusBaitAndSwitch[MAXPLAYERS] = { false };
4546
Uint32 achievementBaitAndSwitchTimer[MAXPLAYERS] = { 0 };
4647
std::unordered_set<int> clientLearnedAlchemyIngredients[MAXPLAYERS];
@@ -3453,11 +3454,11 @@ void setDefaultPlayerConducts()
34533454
for ( int c = 0; c < MAXPLAYERS; ++c )
34543455
{
34553456
achievementStatusRhythmOfTheKnight[c] = false;
3457+
achievementRhythmOfTheKnight[c] = false;
34563458
achievementStatusStrobe[c] = false;
34573459
achievementStatusThankTheTank[c] = false;
34583460
achievementRhythmOfTheKnightVec[c].clear();
3459-
achievementThankTheTankPair[c].first = 0;
3460-
achievementThankTheTankPair[c].second = 0;
3461+
achievementThankTheTankPair[c].clear();
34613462
achievementStrobeVec[c].clear();
34623463
achievementStatusBaitAndSwitch[c] = false;
34633464
achievementBaitAndSwitchTimer[c] = 0;
@@ -4023,7 +4024,11 @@ void updateAchievementRhythmOfTheKnight(int player, Entity* target, bool playerI
40234024
{
40244025
//messagePlayer(0, "achievement get!, time taken %f", timeTaken);
40254026
achievementStatusRhythmOfTheKnight[player] = true;
4026-
steamAchievementClient(player, "BARONY_ACH_RHYTHM_OF_THE_KNIGHT");
4027+
if ( !achievementRhythmOfTheKnight[player] )
4028+
{
4029+
steamAchievementClient(player, "BARONY_ACH_RHYTHM_OF_THE_KNIGHT");
4030+
achievementRhythmOfTheKnight[player] = true;
4031+
}
40274032
}
40284033
achievementRhythmOfTheKnightVec[player].clear();
40294034
}
@@ -4100,40 +4105,39 @@ void updateAchievementThankTheTank(int player, Entity* target, bool targetKilled
41004105
{
41014106
return;
41024107
}
4103-
if ( !target )
4108+
if ( !target || target->behavior != &actMonster )
41044109
{
41054110
return;
41064111
}
4107-
if ( achievementStatusThankTheTank[player] || multiplayer == CLIENT )
4112+
if ( multiplayer == CLIENT )
41084113
{
41094114
return;
41104115
}
41114116

4117+
4118+
auto& entry = achievementThankTheTankPair[player][target->getUID()];
41124119
if ( !targetKilled )
41134120
{
4114-
achievementThankTheTankPair[player] = std::make_pair(ticks, target->getUID()); // track the monster UID defending against
4121+
entry = ticks;
41154122
//messagePlayer(0, "pair: %d, %d", achievementThankTheTankPair[player].first, achievementThankTheTankPair[player].second);
41164123
}
4117-
else if ( achievementThankTheTankPair[player].first != 0
4118-
&& achievementThankTheTankPair[player].second != 0 ) // check there is a ticks/UID entry.
4124+
else if ( entry != 0 ) // check there is a ticks/UID entry.
41194125
{
41204126
if ( players[player] && players[player]->entity )
41214127
{
41224128
if ( players[player]->entity->checkEnemy(target) )
41234129
{
4124-
if ( target->getUID() == achievementThankTheTankPair[player].second )
4130+
// check timestamp within 3 seconds.
4131+
if ( (ticks - entry) / 50.f < 3.f )
41254132
{
4126-
// same target dying, check timestamp within 3 seconds.
4127-
if ( (ticks - achievementThankTheTankPair[player].first) / 50.f < 3.f )
4133+
achievementStatusThankTheTank[player] = true;
4134+
achievementThankTheTankPair[player].erase(target->getUID());
4135+
if ( players[player]->mechanics.allowedRaiseBlockingAgainstEntity(*target) )
41284136
{
4129-
achievementStatusThankTheTank[player] = true;
4130-
if ( players[player]->mechanics.allowedRaiseBlockingAgainstEntity(*target) )
4137+
int skillLVL = 3 * (stats[player]->getProficiency(PRO_SHIELD) / 20);
4138+
if ( local_rng.rand() % (5 + skillLVL) == 0 )
41314139
{
4132-
int skillLVL = 3 * (stats[player]->getProficiency(PRO_SHIELD) / 20);
4133-
if ( local_rng.rand() % (5 + skillLVL) == 0 )
4134-
{
4135-
players[player]->entity->increaseSkill(PRO_SHIELD);
4136-
}
4140+
players[player]->entity->increaseSkill(PRO_SHIELD);
41374141
}
41384142
}
41394143
}

src/scores.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,8 @@ extern Sint32 conductGameChallenges[NUM_CONDUCT_CHALLENGES];
288288
extern Sint32 gameStatistics[NUM_GAMEPLAY_STATISTICS];
289289
extern std::vector<std::pair<Uint32, Uint32>> achievementRhythmOfTheKnightVec[MAXPLAYERS];
290290
extern bool achievementStatusRhythmOfTheKnight[MAXPLAYERS];
291-
extern std::pair<Uint32, Uint32> achievementThankTheTankPair[MAXPLAYERS];
291+
extern bool achievementRhythmOfTheKnight[MAXPLAYERS];
292+
extern std::map<Uint32, Uint32> achievementThankTheTankPair[MAXPLAYERS];
292293
extern bool achievementStatusBaitAndSwitch[MAXPLAYERS];
293294
extern Uint32 achievementBaitAndSwitchTimer[MAXPLAYERS];
294295
extern std::unordered_set<int> clientLearnedAlchemyIngredients[MAXPLAYERS];

0 commit comments

Comments
 (0)