mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 07:48:02 +00:00
feat(Core/Creature): Implement ModifyThreatPercentTemp() function (#11521)
* feat(Core/Creature): Implement ModifyThreatTemporary function * feat(Core/Creature): Implement ModifyThreatPercentTemp() function * fix build
This commit is contained in:
@@ -201,6 +201,20 @@ bool ForcedDespawnDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool TemporaryThreatModifierEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/)
|
||||||
|
{
|
||||||
|
if (Unit* victim = ObjectAccessor::GetUnit(m_owner, m_threatVictimGUID))
|
||||||
|
{
|
||||||
|
if (m_owner.IsInCombatWith(victim))
|
||||||
|
{
|
||||||
|
m_owner.getThreatMgr().modifyThreatPercent(victim, -100); // Reset threat to zero.
|
||||||
|
m_owner.getThreatMgr().addThreat(victim, m_threatValue); // Set to the previous value it had, first before modification.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Creature::Creature(bool isWorldObject): Unit(isWorldObject), MovableMapObject(), m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0), m_lootRecipientGroup(0),
|
Creature::Creature(bool isWorldObject): Unit(isWorldObject), MovableMapObject(), m_groupLootTimer(0), lootingGroupLowGUID(0), m_PlayerDamageReq(0), m_lootRecipientGroup(0),
|
||||||
m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_wanderDistance(0.0f), m_boundaryCheckTime(2500),
|
m_corpseRemoveTime(0), m_respawnTime(0), m_respawnDelay(300), m_corpseDelay(60), m_wanderDistance(0.0f), m_boundaryCheckTime(2500),
|
||||||
m_transportCheckTimer(1000), lootPickPocketRestoreTime(0), m_reactState(REACT_AGGRESSIVE), m_defaultMovementType(IDLE_MOTION_TYPE),
|
m_transportCheckTimer(1000), lootPickPocketRestoreTime(0), m_reactState(REACT_AGGRESSIVE), m_defaultMovementType(IDLE_MOTION_TYPE),
|
||||||
@@ -3528,3 +3542,19 @@ void Creature::SetCorpseRemoveTime(uint32 delay)
|
|||||||
{
|
{
|
||||||
m_corpseRemoveTime = GameTime::GetGameTime().count() + delay;
|
m_corpseRemoveTime = GameTime::GetGameTime().count() + delay;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Creature::ModifyThreatPercentTemp(Unit* victim, int32 percent, Milliseconds duration)
|
||||||
|
{
|
||||||
|
if (victim)
|
||||||
|
{
|
||||||
|
float currentThreat = getThreatMgr().getThreat(victim);
|
||||||
|
|
||||||
|
if (percent != 0.0f)
|
||||||
|
{
|
||||||
|
getThreatMgr().modifyThreatPercent(victim, percent);
|
||||||
|
}
|
||||||
|
|
||||||
|
TemporaryThreatModifierEvent* pEvent = new TemporaryThreatModifierEvent(*this, victim->GetGUID(), currentThreat);
|
||||||
|
m_Events.AddEvent(pEvent, m_Events.CalculateTime(duration.count()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -385,6 +385,8 @@ public:
|
|||||||
|
|
||||||
void SetAssistanceTimer(uint32 value) { m_assistanceTimer = value; }
|
void SetAssistanceTimer(uint32 value) { m_assistanceTimer = value; }
|
||||||
|
|
||||||
|
void ModifyThreatPercentTemp(Unit* victim, int32 percent, Milliseconds duration);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
bool CreateFromProto(ObjectGuid::LowType guidlow, uint32 Entry, uint32 vehId, const CreatureData* data = nullptr);
|
bool CreateFromProto(ObjectGuid::LowType guidlow, uint32 Entry, uint32 vehId, const CreatureData* data = nullptr);
|
||||||
bool InitEntry(uint32 entry, const CreatureData* data = nullptr);
|
bool InitEntry(uint32 entry, const CreatureData* data = nullptr);
|
||||||
@@ -494,4 +496,16 @@ private:
|
|||||||
Seconds const m_respawnTimer;
|
Seconds const m_respawnTimer;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class TemporaryThreatModifierEvent : public BasicEvent
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
TemporaryThreatModifierEvent(Creature& owner, ObjectGuid threatVictimGUID, float threatValue) : BasicEvent(), m_owner(owner), m_threatVictimGUID(threatVictimGUID), m_threatValue(threatValue) { }
|
||||||
|
bool Execute(uint64 e_time, uint32 p_time) override;
|
||||||
|
|
||||||
|
private:
|
||||||
|
Creature& m_owner;
|
||||||
|
ObjectGuid m_threatVictimGUID;
|
||||||
|
float m_threatValue;
|
||||||
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
Reference in New Issue
Block a user