Skip to content

Commit

Permalink
Fix duplicate conquered villain messages when killing fighters after …
Browse files Browse the repository at this point in the history
…a duel
  • Loading branch information
miki151 committed May 24, 2024
1 parent 46fef70 commit cfdd703
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion collective.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -747,7 +747,7 @@ const optional<Collective::AlarmInfo>& Collective::getAlarmInfo() const {
}

bool Collective::needsToBeKilledToConquer(const Creature* c) const {
return hasTrait(c, MinionTrait::FIGHTER) || hasTrait(c, MinionTrait::LEADER);
return (hasTrait(c, MinionTrait::FIGHTER) && !c->wasDuel()) || hasTrait(c, MinionTrait::LEADER);
}

bool Collective::creatureConsideredPlayer(Creature* c) const {
Expand Down
4 changes: 4 additions & 0 deletions creature.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1703,6 +1703,10 @@ void Creature::removePrivateEnemy(const Creature* c) {
privateEnemies.erase(c);
}

bool Creature::wasDuel() const {
return !!duelInfo;
}

void Creature::setDuel(TribeId enemyTribe, Creature* opponent, GlobalTime timeout) {
duelInfo = DuelInfo{enemyTribe, opponent ? opponent->getUniqueId() : Creature::Id{}, timeout};
if (steed)
Expand Down
1 change: 1 addition & 0 deletions creature.h
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ class Creature : public Renderable, public UniqueEntity<Creature>, public OwnedO
bool canBeCaptured() const;
void removePrivateEnemy(const Creature*);
void setDuel(TribeId enemyTribe, Creature* opponent, GlobalTime timeout);
bool wasDuel() const;
const vector<AutomatonPart>& getAutomatonParts() const;
bool isAutomaton() const;
void addAutomatonPart(AutomatonPart);
Expand Down

2 comments on commit cfdd703

@KA101
Copy link

@KA101 KA101 commented on cfdd703 May 26, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would this account for multiple potential Duel-challengers, whether more than one Duke on a map or perhaps a modded Undead Duke, etc?

@miki151
Copy link
Owner Author

@miki151 miki151 commented on cfdd703 Jul 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's going to work fine since it's handled per-tribe. If a modder reports any issue then I'll revisit this.

Please sign in to comment.