Compare commits

...

19 Commits

Author SHA1 Message Date
Patrick Müssig
340ebaf732
Merge dda25dac56bc80d78d0c5d773a507984508ba913 into b83071388c7d69f42dc57e299f20241be035a850 2025-02-24 19:42:47 +01:00
vrachv
b83071388c
fix(Scripts/SunwellPlateau) Fix flame touched stacking (#21594) 2025-02-24 11:49:33 -03:00
Andrew
f234f034a1
fix(Scripts/SunwellPlateau): Fix twins respawn (#21598) 2025-02-24 11:48:44 -03:00
Andrew
835283bf26
feat(Core/Scripting): Implement ScheduleEnrageTimer() helper (#21597) 2025-02-24 09:59:18 +01:00
Andrew
8f6d651471
fix(Scripts/SunwellPlateau): Felmyst should cast Noxious Cloud only a… (#21596) 2025-02-24 02:36:22 -03:00
github-actions[bot]
f6c29614d5 chore(DB): import pending files
Referenced commit(s): 96e7a20bd9325618b7adbd1381aa4e0e50bdba23
2025-02-24 05:19:56 +00:00
Andrew
96e7a20bd9
fix(DB/Creature): Fix Felmyst flying animation in p1 and add despawn on evade (#21396) 2025-02-24 06:18:55 +01:00
Kitzunu
cd8761796f
fix(CI/Codestyle): skip SQL keyword 'NOT' (#21591) 2025-02-24 06:16:20 +01:00
Patrick Müssig
dda25dac56
Update naming to match latest master convention
Change `OnBeforePlayerReputationChange` to
`OnPlayerBeforeReputationChange` in `ScriptMgr`
Change `OnBeforeReputationChange` to
`OnPlayerBeforeReputationChange` in `PlayerScript`
2025-02-18 10:57:25 +01:00
Patrick Müssig
03bb881bf0
More style fixes 2025-02-18 10:32:41 +01:00
Patrick Müssig
9bd2b4f725
Update src/server/game/Entities/Player/Player.cpp
added default case to switch

Co-authored-by: Kitzunu <24550914+Kitzunu@users.noreply.github.com>
2025-02-18 10:32:41 +01:00
Patrick Müssig
eed0670c80
Move ReputationSource back into Player.h 2025-02-18 10:32:41 +01:00
Patrick Müssig
d306f36882
Include more ReputationSources 2025-02-18 10:32:40 +01:00
Patrick Müssig
61bd3bb922
Removed changelog 2025-02-18 10:32:40 +01:00
Patrick Müssig
840fd1c12e
fixed whitespace coding style issues 2025-02-18 10:32:36 +01:00
Patrick Müssig
f4af2f8c02
update changelog to reflect changes to ReputationSource 2025-02-18 10:31:27 +01:00
Patrick Müssig
5551408b4b
Added doxygen documentation 2025-02-18 10:31:23 +01:00
Patrick Müssig
afba80427a
Fixed compile errors 2025-02-18 10:30:23 +01:00
Patrick Müssig
8757fa6687
Added new hooks for repuation gaining to the player 2025-02-18 10:30:15 +01:00
17 changed files with 262 additions and 79 deletions

View File

@ -234,7 +234,7 @@ def backtick_check(file: io, file_path: str) -> None:
# Skip SQL keywords
if word.upper() in {"SELECT", "FROM", "JOIN", "WHERE", "GROUP", "BY", "ORDER",
"DELETE", "UPDATE", "INSERT", "INTO", "SET", "VALUES", "AND",
"IN", "OR", "REPLACE"}:
"IN", "OR", "REPLACE", "NOT"}:
continue
# Make sure the word is enclosed in backticks

View File

@ -0,0 +1,3 @@
-- DB update 2025_02_22_00 -> 2025_02_24_00
--
UPDATE `creature_template` SET `flags_extra` = `flags_extra`|512|2147483648 WHERE `entry` = 25038;

View File

@ -633,6 +633,7 @@ void BossAI::_Reset()
me->ResetLootMode();
events.Reset();
scheduler.CancelAll();
me->m_Events.KillAllEvents(false);
summons.DespawnAll();
ClearUniqueTimedEventsDone();
_healthCheckEvents.clear();
@ -787,6 +788,20 @@ void BossAI::ScheduleHealthCheckEvent(std::initializer_list<uint8> healthPct, st
_nextHealthCheck = _healthCheckEvents.front();
}
void BossAI::ScheduleEnrageTimer(uint32 spellId, Milliseconds timer, uint8 textId /*= 0*/)
{
me->m_Events.AddEventAtOffset([this, spellId, textId]
{
if (!me->IsAlive())
return;
if (textId)
Talk(textId);
DoCastSelf(spellId, true);
}, timer);
}
// WorldBossAI - for non-instanced bosses
WorldBossAI::WorldBossAI(Creature* creature) :

View File

@ -485,6 +485,12 @@ public:
void ScheduleHealthCheckEvent(uint32 healthPct, std::function<void()> exec);
void ScheduleHealthCheckEvent(std::initializer_list<uint8> healthPct, std::function<void()> exec);
// @brief Casts the spell after the fixed time and says the text id if provided. Timer will run even if the creature is casting or out of combat.
// @param spellId The spell to cast.
// @param timer The time to wait before casting the spell.
// @param textId The text id to say.
void ScheduleEnrageTimer(uint32 spellId, Milliseconds timer, uint8 textId = 0);
// Hook used to execute events scheduled into EventMap without the need
// to override UpdateAI
// note: You must re-schedule the event within this method if the event

View File

@ -748,7 +748,10 @@ void Battleground::RewardReputationToTeam(uint32 factionId, uint32 reputation, T
AddPct(repGain, itr->second->GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN));
AddPct(repGain, itr->second->GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_FACTION_REPUTATION_GAIN, realFactionId));
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(realFactionId))
{
ScriptMgr::instance()->OnPlayerBeforeReputationChange(itr->second, factionId, repGain, ReputationSource::PvP);
itr->second->GetReputationMgr().ModifyReputation(factionEntry, repGain);
}
}
}

View File

@ -5910,7 +5910,7 @@ float Player::CalculateReputationGain(ReputationSource source, uint32 creatureOr
float repMod = noQuestBonus ? 0.0f : float(GetTotalAuraModifier(SPELL_AURA_MOD_REPUTATION_GAIN));
// faction specific auras only seem to apply to kills
if (source == REPUTATION_SOURCE_KILL)
if (source == ReputationSource::Kill)
repMod += GetTotalAuraModifierByMiscValue(SPELL_AURA_MOD_FACTION_REPUTATION_GAIN, faction);
percent += rep > 0.f ? repMod : -repMod;
@ -5918,17 +5918,17 @@ float Player::CalculateReputationGain(ReputationSource source, uint32 creatureOr
float rate;
switch (source)
{
case REPUTATION_SOURCE_KILL:
case ReputationSource::Kill:
rate = sWorld->getRate(RATE_REPUTATION_LOWLEVEL_KILL);
break;
case REPUTATION_SOURCE_QUEST:
case REPUTATION_SOURCE_DAILY_QUEST:
case REPUTATION_SOURCE_WEEKLY_QUEST:
case REPUTATION_SOURCE_MONTHLY_QUEST:
case REPUTATION_SOURCE_REPEATABLE_QUEST:
case ReputationSource::Quest:
case ReputationSource::DailyQuest:
case ReputationSource::WeeklyQuest:
case ReputationSource::MonthlyQuest:
case ReputationSource::RepeatableQuest:
rate = sWorld->getRate(RATE_REPUTATION_LOWLEVEL_QUEST);
break;
case REPUTATION_SOURCE_SPELL:
case ReputationSource::Spell:
default:
rate = 1.0f;
break;
@ -5946,27 +5946,29 @@ float Player::CalculateReputationGain(ReputationSource source, uint32 creatureOr
float repRate = 0.0f;
switch (source)
{
case REPUTATION_SOURCE_KILL:
case ReputationSource::Kill:
repRate = repData->creatureRate;
break;
case REPUTATION_SOURCE_QUEST:
case ReputationSource::Quest:
repRate = repData->questRate;
break;
case REPUTATION_SOURCE_DAILY_QUEST:
case ReputationSource::DailyQuest:
repRate = repData->questDailyRate;
break;
case REPUTATION_SOURCE_WEEKLY_QUEST:
case ReputationSource::WeeklyQuest:
repRate = repData->questWeeklyRate;
break;
case REPUTATION_SOURCE_MONTHLY_QUEST:
case ReputationSource::MonthlyQuest:
repRate = repData->questMonthlyRate;
break;
case REPUTATION_SOURCE_REPEATABLE_QUEST:
case ReputationSource::RepeatableQuest:
repRate = repData->questRepeatableRate;
break;
case REPUTATION_SOURCE_SPELL:
case ReputationSource::Spell:
repRate = repData->spellRate;
break;
default:
break;
}
// for custom, a rate of 0.0 will totally disable reputation gain for this faction/type
@ -5976,7 +5978,7 @@ float Player::CalculateReputationGain(ReputationSource source, uint32 creatureOr
percent *= repRate;
}
if (source != REPUTATION_SOURCE_SPELL && GetsRecruitAFriendBonus(false))
if (source != ReputationSource::Spell && GetsRecruitAFriendBonus(false))
percent *= 1.0f + sWorld->getRate(RATE_REPUTATION_RECRUIT_A_FRIEND_BONUS);
return CalculatePct(rep, percent);
@ -6011,7 +6013,9 @@ void Player::RewardReputation(Unit* victim)
if (Rep->RepFaction1 && (!Rep->TeamDependent || teamId == TEAM_ALLIANCE))
{
float donerep1 = CalculateReputationGain(REPUTATION_SOURCE_KILL, victim->GetLevel(), static_cast<float>(Rep->RepValue1), ChampioningFaction ? ChampioningFaction : Rep->RepFaction1);
float donerep1 = CalculateReputationGain(ReputationSource::Kill, victim->GetLevel(), static_cast<float>(Rep->RepValue1), ChampioningFaction ? ChampioningFaction : Rep->RepFaction1);
ScriptMgr::instance()->OnPlayerBeforeReputationChange(this, static_cast<float>(Rep->RepValue1), donerep1, ReputationSource::Kill);
ScriptMgr::instance()->OnPlayerBeforeReputationChange(this, static_cast<float>(Rep->RepValue1), donerep1, victim);
FactionEntry const* factionEntry1 = sFactionStore.LookupEntry(ChampioningFaction ? ChampioningFaction : Rep->RepFaction1);
if (factionEntry1)
@ -6022,7 +6026,9 @@ void Player::RewardReputation(Unit* victim)
if (Rep->RepFaction2 && (!Rep->TeamDependent || teamId == TEAM_HORDE))
{
float donerep2 = CalculateReputationGain(REPUTATION_SOURCE_KILL, victim->GetLevel(), static_cast<float>(Rep->RepValue2), ChampioningFaction ? ChampioningFaction : Rep->RepFaction2);
float donerep2 = CalculateReputationGain(ReputationSource::Kill, victim->GetLevel(), static_cast<float>(Rep->RepValue2), ChampioningFaction ? ChampioningFaction : Rep->RepFaction2);
ScriptMgr::instance()->OnPlayerBeforeReputationChange(this, static_cast<float>(Rep->RepValue1), donerep2, ReputationSource::Kill);
ScriptMgr::instance()->OnPlayerBeforeReputationChange(this, static_cast<float>(Rep->RepValue1), donerep2, victim);
FactionEntry const* factionEntry2 = sFactionStore.LookupEntry(ChampioningFaction ? ChampioningFaction : Rep->RepFaction2);
if (factionEntry2)
@ -6061,25 +6067,31 @@ void Player::RewardReputation(Quest const* quest)
if (quest->IsDaily())
{
rep = CalculateReputationGain(REPUTATION_SOURCE_DAILY_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], false);
rep = CalculateReputationGain(ReputationSource::DailyQuest, GetQuestLevel(quest), rep, quest->RewardFactionId[i], false);
ScriptMgr::instance()->OnPlayerBeforeReputationChange(this, quest->RewardFactionId[i], rep, ReputationSource::DailyQuest);
}
else if (quest->IsWeekly())
{
rep = CalculateReputationGain(REPUTATION_SOURCE_WEEKLY_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], false);
rep = CalculateReputationGain(ReputationSource::WeeklyQuest, GetQuestLevel(quest), rep, quest->RewardFactionId[i], false);
ScriptMgr::instance()->OnPlayerBeforeReputationChange(this, quest->RewardFactionId[i], rep, ReputationSource::WeeklyQuest);
}
else if (quest->IsMonthly())
{
rep = CalculateReputationGain(REPUTATION_SOURCE_MONTHLY_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], false);
rep = CalculateReputationGain(ReputationSource::MonthlyQuest, GetQuestLevel(quest), rep, quest->RewardFactionId[i], false);
ScriptMgr::instance()->OnPlayerBeforeReputationChange(this, quest->RewardFactionId[i], rep, ReputationSource::MonthlyQuest);
}
else if (quest->IsRepeatable())
{
rep = CalculateReputationGain(REPUTATION_SOURCE_REPEATABLE_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], false);
rep = CalculateReputationGain(ReputationSource::RepeatableQuest, GetQuestLevel(quest), rep, quest->RewardFactionId[i], false);
ScriptMgr::instance()->OnPlayerBeforeReputationChange(this, quest->RewardFactionId[i], rep, ReputationSource::RepeatableQuest);
}
else
{
rep = CalculateReputationGain(REPUTATION_SOURCE_QUEST, GetQuestLevel(quest), rep, quest->RewardFactionId[i], false);
rep = CalculateReputationGain(ReputationSource::Quest, GetQuestLevel(quest), rep, quest->RewardFactionId[i], false);
ScriptMgr::instance()->OnPlayerBeforeReputationChange(this, quest->RewardFactionId[i], rep, ReputationSource::Quest);
}
ScriptMgr::instance()->OnPlayerBeforeReputationChange(this, quest->RewardFactionId[i], rep, quest);
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(quest->RewardFactionId[i]))
{
GetReputationMgr().ModifyReputation(factionEntry, rep, quest->HasSpecialFlag(QUEST_SPECIAL_FLAGS_NO_REP_SPILLOVER));

View File

@ -234,15 +234,31 @@ enum ActionButtonType
ACTION_BUTTON_ITEM = 0x80
};
enum ReputationSource
/**
* @brief This enum represent all known sources a character can get reputation
*/
enum class ReputationSource : uint8
{
REPUTATION_SOURCE_KILL,
REPUTATION_SOURCE_QUEST,
REPUTATION_SOURCE_DAILY_QUEST,
REPUTATION_SOURCE_WEEKLY_QUEST,
REPUTATION_SOURCE_MONTHLY_QUEST,
REPUTATION_SOURCE_REPEATABLE_QUEST,
REPUTATION_SOURCE_SPELL
/// The player killed an enemy
Kill,
/// The player turned in a quest
Quest,
/// The player turned in a daily quest
DailyQuest,
/// The player turned in a weekly quest
WeeklyQuest,
/// The player turned in a montly quest
MonthlyQuest,
/// The player turned in a repeatable quest
RepeatableQuest,
/// The player used a spell
Spell,
// The player get reputation by doing PvP related tasks
PvP,
/// The player get reputation by a console command
Console,
/// The player get some reputation by server configuration
Config
};
enum QuestSound

View File

@ -1018,11 +1018,14 @@ void WorldSession::HandlePlayerLoginFromDB(LoginQueryHolder const& holder)
{
ReputationMgr& repMgr = pCurrChar->GetReputationMgr();
auto SendFullReputation = [&repMgr](std::initializer_list<uint32> factionsList)
auto SendFullReputation = [&repMgr, pCurrChar](std::initializer_list<uint32> factionsList)
{
for (auto const& itr : factionsList)
{
repMgr.SetOneFactionReputation(sFactionStore.LookupEntry(itr), 42999.f, false);
auto faction = sFactionStore.LookupEntry(itr);
float reputation = 42999.f;
ScriptMgr::instance()->OnPlayerBeforeReputationChange(pCurrChar, faction->ID, reputation, ReputationSource::Config);
repMgr.SetOneFactionReputation(sFactionStore.LookupEntry(itr), reputation, false);
}
};

View File

@ -129,6 +129,26 @@ void ScriptMgr::OnPlayerGiveXP(Player* player, uint32& amount, Unit* victim, uin
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_GIVE_EXP, script->OnPlayerGiveXP(player, amount, victim, xpSource));
}
void ScriptMgr::OnPlayerBeforeReputationChange(Player* player, uint32 factionId, float& amount, Unit* victim)
{
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_REPUTATION_CHANGE_UNIT, script->OnPlayerBeforeReputationChange(player, factionId, amount, victim));
}
void ScriptMgr::OnPlayerBeforeReputationChange(Player* player, uint32 factionId, float& amount, Quest const* quest)
{
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_REPUTATION_CHANGE_QUEST, script->OnPlayerBeforeReputationChange(player, factionId, amount, quest));
}
void ScriptMgr::OnPlayerBeforeReputationChange(Player* player, uint32 factionId, float& amount, Spell* spell)
{
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_REPUTATION_CHANGE_SPELL, script->OnPlayerBeforeReputationChange(player, factionId, amount, spell));
}
void ScriptMgr::OnPlayerBeforeReputationChange(Player* player, uint32 factionId, float& amount, ReputationSource reputationSource)
{
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_REPUTATION_CHANGE_SOURCE, script->OnPlayerBeforeReputationChange(player, factionId, amount, reputationSource));
}
bool ScriptMgr::OnPlayerReputationChange(Player* player, uint32 factionID, int32& standing, bool incremental)
{
CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_ON_REPUTATION_CHANGE, !script->OnPlayerReputationChange(player, factionID, standing, incremental));

View File

@ -18,6 +18,7 @@
#ifndef SCRIPT_OBJECT_PLAYER_SCRIPT_H_
#define SCRIPT_OBJECT_PLAYER_SCRIPT_H_
#include "Player.h"
#include "ScriptObject.h"
#include "SharedDefines.h"
#include <vector>
@ -48,6 +49,10 @@ enum PlayerHook
PLAYERHOOK_ON_MONEY_CHANGED,
PLAYERHOOK_ON_BEFORE_LOOT_MONEY,
PLAYERHOOK_ON_GIVE_EXP,
PLAYERHOOK_ON_BEFORE_REPUTATION_CHANGE_UNIT,
PLAYERHOOK_ON_BEFORE_REPUTATION_CHANGE_QUEST,
PLAYERHOOK_ON_BEFORE_REPUTATION_CHANGE_SPELL,
PLAYERHOOK_ON_BEFORE_REPUTATION_CHANGE_SOURCE,
PLAYERHOOK_ON_REPUTATION_CHANGE,
PLAYERHOOK_ON_REPUTATION_RANK_CHANGE,
PLAYERHOOK_ON_LEARN_SPELL,
@ -275,6 +280,54 @@ public:
// Called when a player gains XP (before anything is given)
virtual void OnPlayerGiveXP(Player* /*player*/, uint32& /*amount*/, Unit* /*victim*/, uint8 /*xpSource*/) { }
/**
* @brief Called before a player gains or looses Reputation
*
* @param [in] player instance of the current player
* @param [in] factionId id of the faction which reputation changes
* @param[in,out] amount the amount of reputation the player gets or loses
* @param[in] victim the unit which was killed to gain reputation
* @remark avoid hooking both versions of this event ReputationSource is a more generic one.<br />
* ReputationSource is called first.
*/
virtual void OnPlayerBeforeReputationChange(Player* /*player*/, uint32 /*factionId*/, float& /*amount*/, Unit* /*victim*/ ) {}
/**
* @brief Called before a player gains or looses Reputation
*
* @param [in] player instance of the current player
* @param [in] factionId id of the faction which reputation changes
* @param[in,out] amount the amount of reputation the player gets or loses
* @param[in] quest the quest which was turn in to gain reputation
* @remark avoid hooking both versions of this event ReputationSource is a more generic one.<br />
* ReputationSource is called first.
*/
virtual void OnPlayerBeforeReputationChange(Player* /*player*/, uint32 /*factionId*/ , float& /*amount*/, Quest const* /*quest*/) {}
/**
* @brief Called before a player gains or looses Reputation
*
* @param [in] player instance of the current player
* @param [in] factionId id of the faction which reputation changes
* @param[in,out] amount the amount of reputation the player gets or loses
* @param[in] spell the spell which was used to gain reputation
* @remark avoid hooking both versions of this event ReputationSource is a more generic one.<br />
* ReputationSource is called first.
*/
virtual void OnPlayerBeforeReputationChange(Player* /*player*/, uint32 /*factionId*/, float& /*amount*/ , Spell* /*spell*/) {}
/**
* @brief Called before a player gains or looses Reputation
*
* @param [in] player instance of the current player
* @param [in] factionId id of the faction which reputation changes
* @param[in,out] amount the amount of reputation the player gets or loses
* @param[in] reputationSource an enum which determinate the source used to gain or loose reputation
* @remark avoid hooking both versions of this event ReputationSource is a more generic one.<br />
* ReputationSource is called first.
*/
virtual void OnPlayerBeforeReputationChange(Player* /*player*/, uint32 /*factionId*/, float& /*amount*/, ReputationSource /*reputationSource*/) {}
// Called when a player's reputation changes (before it is actually changed)
virtual bool OnPlayerReputationChange(Player* /*player*/, uint32 /*factionID*/, int32& /*standing*/, bool /*incremental*/) { return true; }

View File

@ -32,6 +32,7 @@
#include "LFGMgr.h"
#include "ObjectMgr.h"
#include "PetDefines.h"
#include "Player.h"
#include "SharedDefines.h"
#include "Tuples.h"
#include "Weather.h"
@ -311,6 +312,56 @@ public: /* PlayerScript */
void OnPlayerMoneyChanged(Player* player, int32& amount);
void OnPlayerBeforeLootMoney(Player* player, Loot* loot);
void OnPlayerGiveXP(Player* player, uint32& amount, Unit* victim, uint8 xpSource);
/**
* @brief Called before a player gains or looses Reputation
*
* @param [in] player instance of the current player
* @param [in] factionId id of the faction which reputation changes
* @param[in,out] amount the amount of reputation the player gets or loses
* @param[in] victim the unit which was killed to gain reputation
*
* @remark avoid hooking both versions of this event ReputationSource is a more generic one.<br />
* ReputationSource is called first.
*/
void OnPlayerBeforeReputationChange(Player* player, uint32 factionId, float& amount, Unit* victim);
/**
* @brief Called before a player gains or looses Reputation
*
* @param [in] player instance of the current player
* @param [in] factionId id of the faction which reputation changes
* @param[in,out] amount the amount of reputation the player gets or loses
* @param[in] quest the quest which was turn in to gain reputation
* @remark avoid hooking both versions of this event ReputationSource is a more generic one.<br />
* ReputationSource is called first.
*/
void OnPlayerBeforeReputationChange(Player* player, uint32 factionId, float& amount, Quest const* quest);
/**
* @brief Called before a player gains or looses Reputation
*
* @param [in] player instance of the current player
* @param [in] factionId id of the faction which reputation changes
* @param[in,out] amount the amount of reputation the player gets or loses
* @param[in] spell the spell which was used to gain reputation
* @remark avoid hooking both versions of this event ReputationSource is a more generic one.<br />
* ReputationSource is called first.
*/
void OnPlayerBeforeReputationChange(Player* player, uint32 factionId, float& amount, Spell* spell);
/**
* @brief Called before a player gains or looses Reputation
*
* @param [in] player instance of the current player
* @param [in] factionId id of the faction which reputation changes
* @param[in,out] amount the amount of reputation the player gets or loses
* @param[in] reputationSource an enum which determinate the source used to gain or loose reputation
*
* @remark avoid hooking both versions of this event ReputationSource is a more generic one.<br />
* ReputationSource is called first.
*/
void OnPlayerBeforeReputationChange(Player* player, uint32 factionId, float& amount, ReputationSource reputationSource);
bool OnPlayerReputationChange(Player* player, uint32 factionID, int32& standing, bool incremental);
void OnPlayerReputationRankChange(Player* player, uint32 factionID, ReputationRank newRank, ReputationRank oldRank, bool increased);
void OnPlayerLearnSpell(Player* player, uint32 spellID);

View File

@ -4747,7 +4747,9 @@ void Spell::EffectReputation(SpellEffIndex effIndex)
if (!factionEntry)
return;
repChange = player->CalculateReputationGain(REPUTATION_SOURCE_SPELL, 0, repChange, factionId);
repChange = player->CalculateReputationGain(ReputationSource::Spell, 0, repChange, factionId);
ScriptMgr::instance()->OnPlayerBeforeReputationChange(player, factionId, repChange, ReputationSource::Spell);
ScriptMgr::instance()->OnPlayerBeforeReputationChange(player, factionId, repChange, this);
player->GetReputationMgr().ModifyReputation(factionEntry, repChange);
}

View File

@ -29,6 +29,7 @@ EndScriptData */
#include "Pet.h"
#include "Player.h"
#include "ReputationMgr.h"
#include "ScriptMgr.h"
#include "StringConvert.h"
using namespace Acore::ChatCommands;
@ -826,8 +827,9 @@ public:
handler->SendErrorMessage(LANG_COMMAND_FACTION_NOREP_ERROR, factionEntry->name[handler->GetSessionDbcLocale()], factionId);
return false;
}
target->GetReputationMgr().SetOneFactionReputation(factionEntry, float(amount), false);
float rep = target->GetReputationMgr().GetReputation(factionId) - float(amount);
ScriptMgr::instance()->OnPlayerBeforeReputationChange(target, factionId, rep, ReputationSource::Console);
target->GetReputationMgr().SetOneFactionReputation(factionEntry, rep, false);
target->GetReputationMgr().SendState(target->GetReputationMgr().GetState(factionEntry));
handler->PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->name[handler->GetSessionDbcLocale()], factionId,

View File

@ -28,6 +28,7 @@ EndScriptData */
#include "ObjectMgr.h"
#include "Player.h"
#include "ReputationMgr.h"
#include "ScriptMgr.h"
using namespace Acore::ChatCommands;
@ -309,7 +310,9 @@ public:
{
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(repFaction))
{
player->GetReputationMgr().SetReputation(factionEntry, static_cast<float>(repValue));
auto repDiv = static_cast<float>(repValue - curRep);
ScriptMgr::instance()->OnPlayerBeforeReputationChange(player, repFaction, repDiv, ReputationSource::Console);
player->GetReputationMgr().SetReputation(factionEntry, repDiv + curRep);
}
}
}
@ -323,7 +326,9 @@ public:
{
if (FactionEntry const* factionEntry = sFactionStore.LookupEntry(repFaction))
{
player->GetReputationMgr().SetReputation(factionEntry, static_cast<float>(repValue2));
auto repDiv = static_cast<float>(repValue2 - curRep);
ScriptMgr::instance()->OnPlayerBeforeReputationChange(player, repFaction, repDiv, ReputationSource::Console);
player->GetReputationMgr().SetReputation(factionEntry, repDiv + curRep);
}
}
}

View File

@ -22,6 +22,7 @@
#include "SpellInfo.h"
#include "SpellScript.h"
#include "SpellScriptLoader.h"
#include "SpellAuraEffects.h"
#include "sunwell_plateau.h"
enum Quotes
@ -83,7 +84,10 @@ struct boss_sacrolash : public BossAI
_isSisterDead = false;
BossAI::Reset();
me->SetLootMode(0);
me->m_Events.KillAllEvents(false);
if (Creature* alythess = instance->GetCreature(DATA_ALYTHESS))
if (!alythess->IsAlive())
alythess->Respawn(true);
}
void DoAction(int32 param) override
@ -105,18 +109,6 @@ struct boss_sacrolash : public BossAI
}
}
void EnterEvadeMode(EvadeReason why) override
{
BossAI::EnterEvadeMode(why);
if (Creature* alythess = instance->GetCreature(DATA_ALYTHESS))
{
if (!alythess->IsAlive())
alythess->Respawn(true);
else if (!alythess->IsInEvadeMode())
alythess->AI()->EnterEvadeMode(why);
}
}
void JustEngagedWith(Unit* who) override
{
BossAI::JustEngagedWith(who);
@ -124,10 +116,7 @@ struct boss_sacrolash : public BossAI
if (alythess->IsAlive() && !alythess->IsInCombat())
alythess->AI()->AttackStart(who);
me->m_Events.AddEventAtOffset([&] {
Talk(YELL_BERSERK);
DoCastSelf(SPELL_ENRAGE, true);
}, 6min);
ScheduleEnrageTimer(SPELL_ENRAGE, 6min, YELL_BERSERK);
ScheduleTimedEvent(10s, [&] {
DoCastSelf(SPELL_SHADOW_BLADES);
@ -195,7 +184,10 @@ struct boss_alythess : public BossAI
_isSisterDead = false;
BossAI::Reset();
me->SetLootMode(0);
me->m_Events.KillAllEvents(false);
if (Creature* sacrolash = instance->GetCreature(DATA_SACROLASH))
if (!sacrolash->IsAlive())
sacrolash->Respawn(true);
}
void DoAction(int32 param) override
@ -217,18 +209,6 @@ struct boss_alythess : public BossAI
}
}
void EnterEvadeMode(EvadeReason why) override
{
BossAI::EnterEvadeMode(why);
if (Creature* sacrolash = instance->GetCreature(DATA_SACROLASH))
{
if (!sacrolash->IsAlive())
sacrolash->Respawn(true);
else if (!sacrolash->IsInEvadeMode())
sacrolash->AI()->EnterEvadeMode(why);
}
}
void JustEngagedWith(Unit* who) override
{
BossAI::JustEngagedWith(who);
@ -236,10 +216,7 @@ struct boss_alythess : public BossAI
if (sacrolash->IsAlive() && !sacrolash->IsInCombat())
sacrolash->AI()->AttackStart(who);
me->m_Events.AddEventAtOffset([&] {
Talk(YELL_BERSERK);
DoCastSelf(SPELL_ENRAGE, true);
}, 6min);
ScheduleEnrageTimer(SPELL_ENRAGE, 6min, YELL_BERSERK);
ScheduleTimedEvent(1s, [&] {
DoCastVictim(SPELL_BLAZE);
@ -389,8 +366,15 @@ public:
return ValidateSpellInfo({ _touchSpell });
}
void OnPeriodic(AuraEffect const* /*aurEff*/)
void OnPeriodic(AuraEffect const* aurEff)
{
if (aurEff->GetId() == SPELL_FLAME_SEAR)
{
uint32 tick = aurEff->GetTickNumber();
if (tick % 2 != 0 || tick > 10)
return;
}
if (Unit* owner = GetOwner()->ToUnit())
owner->CastSpell(owner, _touchSpell, true);
}

View File

@ -134,7 +134,7 @@ struct boss_felmyst : public BossAI
void JustEngagedWith(Unit* who) override
{
BossAI::JustEngagedWith(who);
me->CastSpell(me, SPELL_NOXIOUS_FUMES, true);
me->m_Events.AddEventAtOffset([&] {
Talk(YELL_BERSERK);
DoCastSelf(SPELL_BERSERK, true);
@ -144,7 +144,7 @@ struct boss_felmyst : public BossAI
Position landPos = who->GetPosition();
me->m_Events.AddEventAtOffset([&, landPos] {
me->GetMotionMaster()->MovePoint(POINT_GROUND, landPos, false, true);
me->GetMotionMaster()->MoveLand(POINT_GROUND, landPos);
}, 2s);
}
@ -168,11 +168,14 @@ struct boss_felmyst : public BossAI
void MovementInform(uint32 type, uint32 point) override
{
if (type != POINT_MOTION_TYPE)
if (type != EFFECT_MOTION_TYPE && type != POINT_MOTION_TYPE)
return;
if (point == POINT_GROUND)
{
if (!me->HasAura(SPELL_NOXIOUS_FUMES))
DoCastSelf(SPELL_NOXIOUS_FUMES, true);
me->HandleEmoteCommand(EMOTE_ONESHOT_LAND);
me->SetCanFly(false);
me->SetDisableGravity(false);

View File

@ -25,6 +25,7 @@
#include "OutdoorPvPScript.h"
#include "Player.h"
#include "ReputationMgr.h"
#include "ScriptMgr.h"
#include "Transport.h"
#include "World.h"
#include "WorldPacket.h"
@ -117,7 +118,9 @@ bool OutdoorPvPSI::HandleAreaTrigger(Player* player, uint32 trigger)
// add 19 honor
player->RewardHonor(nullptr, 1, 19);
// add 20 cenarion circle repu
player->GetReputationMgr().ModifyReputation(sFactionStore.LookupEntry(609), 20.f);
float reputation = 20.f;
sScriptMgr->OnPlayerBeforeReputationChange(player, 609, reputation, ReputationSource::PvP);
player->GetReputationMgr().ModifyReputation(sFactionStore.LookupEntry(609), reputation);
// complete quest
player->KilledMonsterCredit(SI_TURNIN_QUEST_CM_A);
}
@ -143,7 +146,9 @@ bool OutdoorPvPSI::HandleAreaTrigger(Player* player, uint32 trigger)
// add 19 honor
player->RewardHonor(nullptr, 1, 19);
// add 20 cenarion circle repu
player->GetReputationMgr().ModifyReputation(sFactionStore.LookupEntry(609), 20.f);
float reputation = 20.f;
sScriptMgr->OnPlayerBeforeReputationChange(player, 609, reputation, ReputationSource::PvP);
player->GetReputationMgr().ModifyReputation(sFactionStore.LookupEntry(609), reputation);
// complete quest
player->KilledMonsterCredit(SI_TURNIN_QUEST_CM_H);
}