Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: OnGiveReputation override for Reputation Modification #21156

Open
realQuartzi opened this issue Jan 13, 2025 · 2 comments
Open

Feature: OnGiveReputation override for Reputation Modification #21156

realQuartzi opened this issue Jan 13, 2025 · 2 comments

Comments

@realQuartzi
Copy link

Describe your feature request or suggestion in detail

I propose the implementation of a hook system similar to the existing OnGiveXP, but specifically for reputation gain. This new hook, tentatively called OnGiveReputation, would allow developers to intercept and modify the amount of reputation a player gains in various scenarios.

The main use cases for this feature include:

  • Customizing reputation gains for specific factions.
  • Adding additional conditions or modifiers to reputation rewards
  • Easier Logging reputation gains for debugging or analytics purposes.

Describe a possible solution to your feature or suggestion in detail

A potential way to implement this feature is to insert hooks in the following functions:

  1. Player::RewardReputation(Unit* victim)
  2. Player::RewardReputation(Quest const* quest)

In both cases, right before the GetReputationMgr().ModifyReputation() call, we could introduce a hook that allows scripts to modify the reputation value.

This hook could look like this:
void OnGiveReputation(Player* player, int32 factionId, float& amount, ReputationSource source);

Call Examples:

  1. When a player earns reputation (via defeating a unit or completing a quest), the hook is triggered.
  2. Scripts can intercept and modify the reputation amount, optionally cancelling or overriding the default behaviour.
  3. The final reputation value is passed to ModifyReputation().

That should be close to how OnGiveXP works I believe.

Additional context

Here is an example of how OnGiveReputation could be used:

void OnGiveReputation(Player* player, uint32 factionId, float& amount, ReputationSource source) override
{
    // Is it friday? Cause I want double rep on friday...
    if(CheckIfFriday())
        amount *= 2;
}

Yes very creative :)

@realQuartzi realQuartzi changed the title Feature: OnGiveReputation() Feature: OnGiveReputation override for Reputation Modification Jan 13, 2025
@Tondorian
Copy link

In ScriptMgr in line 314 is already a method bool OnPlayerReputationChange(Player* player, uint32 factionID, int32& standing, bool incremental);

Is this good enough?

@realQuartzi
Copy link
Author

In ScriptMgr in line 314 is already a method bool OnPlayerReputationChange(Player* player, uint32 factionID, int32& standing, bool incremental);

Is this good enough?

Thank you for pointing that out!

While OnPlayerReputationChange does cover some aspects, it lacks the critical element of the ReputationSource. Knowing the source of the reputation gain is essential for implementing some other context-aware logic.
For example, distinguishing whether the reputation comes from a quest, killing a unit, or another action would allow developers to implement specific behaviours tailored to those scenarios.
Unless there is a way to reliably retrieve the ReputationSource within OnPlayerReputationChange, I believe it doesn’t fully provide the flexibility or control needed for some use cases.

If this could be added to OnPlayerReputationChange or there is a method to get this information and be able to still adjust the amount gained, then that would be great.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants