diff options
Diffstat (limited to 'src/game')
| -rw-r--r-- | src/game/Creature.cpp | 2 | ||||
| -rw-r--r-- | src/game/Unit.cpp | 14 | ||||
| -rw-r--r-- | src/game/Unit.h | 17 |
3 files changed, 31 insertions, 2 deletions
diff --git a/src/game/Creature.cpp b/src/game/Creature.cpp index e41d18ac0a0..7a4cac89408 100644 --- a/src/game/Creature.cpp +++ b/src/game/Creature.cpp @@ -116,7 +116,7 @@ bool AssistDelayEvent::Execute(uint64 /*e_time*/, uint32 /*p_time*/) { while (!m_assistants.empty()) { - Creature* assistant = (Creature*)Unit::GetUnit(m_owner, *m_assistants.begin()); + Creature* assistant = Unit::GetCreature(m_owner, *m_assistants.begin()); m_assistants.pop_front(); if (assistant && assistant->CanAssistTo(&m_owner, victim)) diff --git a/src/game/Unit.cpp b/src/game/Unit.cpp index 4932887d2d9..cabb755958a 100644 --- a/src/game/Unit.cpp +++ b/src/game/Unit.cpp @@ -2425,7 +2425,9 @@ MeleeHitOutcome Unit::RollMeleeOutcomeAgainst (const Unit *pVictim, WeaponAttack if (tmp > 0 && roll < (sum += tmp)) { DEBUG_LOG ("RollMeleeOutcomeAgainst: CRIT <%d, %d)", sum-tmp, sum); - if(GetTypeId()!=TYPEID_PLAYER && !(((Creature*)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRIT)) + if(GetTypeId() == TYPEID_UNIT && (((Creature*)this)->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_CRIT)) + DEBUG_LOG ("RollMeleeOutcomeAgainst: CRIT DISABLED)"); + else return MELEE_HIT_CRIT; } @@ -10646,6 +10648,16 @@ Unit* Unit::GetUnit(WorldObject& object, uint64 guid) return ObjectAccessor::GetUnit(object,guid); } +Player* Unit::GetPlayer(uint64 guid) +{ + return ObjectAccessor::FindPlayer(guid); +} + +Creature* Unit::GetCreature(WorldObject& object, uint64 guid) +{ + return ObjectAccessor::GetCreature(object, guid); +} + bool Unit::isVisibleForInState( Player const* u, bool inVisibleList ) const { return u->canSeeOrDetect(this, false, inVisibleList, false); diff --git a/src/game/Unit.h b/src/game/Unit.h index 33b03c821db..af902dba15a 100644 --- a/src/game/Unit.h +++ b/src/game/Unit.h @@ -1495,6 +1495,8 @@ class TRINITY_DLL_SPEC Unit : public WorldObject void addFollower(FollowerReference* pRef) { m_FollowingRefManager.insertFirst(pRef); } void removeFollower(FollowerReference* /*pRef*/ ) { /* nothing to do yet */ } static Unit* GetUnit(WorldObject& object, uint64 guid); + static Player* GetPlayer(uint64 guid); + static Creature* GetCreature(WorldObject& object, uint64 guid); MotionMaster* GetMotionMaster() { return &i_motionMaster; } @@ -1647,5 +1649,20 @@ class TRINITY_DLL_SPEC Unit : public WorldObject uint32 m_reducedThreatPercent; uint64 m_misdirectionTargetGUID; }; + +namespace Trinity +{ + template<class T> + void RandomResizeList(std::list<T> &_list, uint32 _size) + { + while(_list.size() > _size) + { + typename std::list<T>::iterator itr = _list.begin(); + advance(itr, urand(0, _list.size() - 1)); + _list.erase(itr); + } + } +} + #endif |
