Changeset 174 for trunk/src/game/Unit.cpp
- Timestamp:
- 11/19/08 13:43:15 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/Unit.cpp
r173 r174 227 227 m_charmInfo = NULL; 228 228 m_unit_movement_flags = 0; 229 m_isPossessed = false; 229 230 230 231 // remove aurastates allowing special moves … … 702 703 ((Player*)pVictim)->SetPvPDeath(player!=NULL); 703 704 704 // Call KilledUnit for creatures705 if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI())706 ((Creature*)this)->AI()->KilledUnit(pVictim);707 708 705 // 10% durability loss on death 709 706 // clean InHateListOf … … 719 716 ((Player*)pVictim)->GetSession()->SendPacket(&data); 720 717 } 718 // Call KilledUnit for creatures 719 if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI()) 720 ((Creature*)this)->AI()->KilledUnit(pVictim); 721 721 } 722 722 else // creature died … … 730 730 cVictim->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); 731 731 } 732 733 // Call KilledUnit for creatures, this needs to be called after the lootable flag is set 734 if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI()) 735 ((Creature*)this)->AI()->KilledUnit(pVictim); 736 732 737 // Call creature just died function 733 738 if (cVictim->AI()) … … 773 778 he->DuelComplete(DUEL_INTERUPTED); 774 779 } 780 781 // Possessed unit died, restore control to possessor 782 pVictim->UnpossessSelf(false); 783 784 // Possessor died, remove possession 785 if(pVictim->GetTypeId() == TYPEID_PLAYER && pVictim->isPossessing()) 786 ((Player*)pVictim)->RemovePossess(false); 775 787 776 788 // battleground things (do this at the end, so the death state flag will be properly set to handle in the bg->handlekill) … … 7170 7182 } 7171 7183 7184 void Unit::UncharmSelf() 7185 { 7186 if (!GetCharmer()) 7187 return; 7188 7189 RemoveSpellsCausingAura(SPELL_AURA_MOD_CHARM); 7190 } 7191 7192 void Unit::UnpossessSelf(bool attack) 7193 { 7194 if (!isPossessed() || !GetCharmer()) 7195 return; 7196 7197 if (GetCharmer()->GetTypeId() == TYPEID_PLAYER) 7198 ((Player*)GetCharmer())->RemovePossess(attack); 7199 else 7200 { 7201 GetCharmer()->SetCharm(0); 7202 SetCharmerGUID(0); 7203 m_isPossessed = false; 7204 } 7205 } 7206 7172 7207 void Unit::UnsummonAllTotems() 7173 7208 { … … 8589 8624 } 8590 8625 8626 // If the player is currently possessing, update visibility from the possessed unit's location 8627 const Unit* target = u->GetTypeId() == TYPEID_PLAYER && u->isPossessing() ? u->GetCharm() : u; 8628 8591 8629 // different visible distance checks 8592 8630 if(u->isInFlight()) // what see player in flight 8593 8631 { 8594 8632 // use object grey distance for all (only see objects any way) 8595 if (!IsWithinDistInMap( u,World::GetMaxVisibleDistanceInFlight()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f)))8633 if (!IsWithinDistInMap(target,World::GetMaxVisibleDistanceInFlight()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f))) 8596 8634 return false; 8597 8635 } 8598 8636 else if(!isAlive()) // distance for show body 8599 8637 { 8600 if (!IsWithinDistInMap( u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f)))8638 if (!IsWithinDistInMap(target,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f))) 8601 8639 return false; 8602 8640 } … … 8606 8644 { 8607 8645 // Players far than max visible distance for player or not in our map are not visible too 8608 if (!at_same_transport && !IsWithinDistInMap( u,World::GetMaxVisibleDistanceForPlayer()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f)))8646 if (!at_same_transport && !IsWithinDistInMap(target,World::GetMaxVisibleDistanceForPlayer()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f))) 8609 8647 return false; 8610 8648 } … … 8613 8651 // Units far than max visible distance for creature or not in our map are not visible too 8614 8652 // Active unit should always be visibile 8615 if (!IsWithinDistInMap( u, u->isActive()8653 if (!IsWithinDistInMap(target, target->isActive() 8616 8654 ? (MAX_VISIBILITY_DISTANCE - (inVisibleList ? 0.0f : World::GetVisibleUnitGreyDistance())) 8617 8655 : (World::GetMaxVisibleDistanceForCreature() + (inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f)))) … … 8622 8660 { 8623 8661 // Pet/charmed far than max visible distance for player or not in our map are not visible too 8624 if (!IsWithinDistInMap( u,World::GetMaxVisibleDistanceForPlayer()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f)))8662 if (!IsWithinDistInMap(target,World::GetMaxVisibleDistanceForPlayer()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f))) 8625 8663 return false; 8626 8664 } … … 8628 8666 { 8629 8667 // Units far than max visible distance for creature or not in our map are not visible too 8630 if (!IsWithinDistInMap( u,World::GetMaxVisibleDistanceForCreature()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f)))8668 if (!IsWithinDistInMap(target,World::GetMaxVisibleDistanceForCreature()+(inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f))) 8631 8669 return false; 8632 8670 } … … 9872 9910 RemoveAllDynObjects(); 9873 9911 GetMotionMaster()->Clear(false); // remove different non-standard movement generators. 9912 9913 UnpossessSelf(false); 9874 9914 } 9875 9915 RemoveFromWorld(); … … 9924 9964 void CharmInfo::InitPossessCreateSpells() 9925 9965 { 9926 if(m_unit->GetTypeId() == TYPEID_PLAYER)9927 return;9928 9929 InitEmptyActionBar(); //charm action bar9930 9931 for(uint32 x = 0; x < CREATURE_MAX_SPELLS; ++x)9932 {9933 if (IsPassiveSpell(((Creature*)m_unit)->m_spells[x]))9934 m_unit->CastSpell(m_unit, ((Creature*)m_unit)->m_spells[x], true);9935 else9936 AddSpellToAB(0, ((Creature*)m_unit)->m_spells[x], ACT_CAST);9966 InitEmptyActionBar(); 9967 if(m_unit->GetTypeId() == TYPEID_UNIT) 9968 { 9969 for(uint32 i = 0; i < CREATURE_MAX_SPELLS; ++i) 9970 { 9971 uint32 spellid = ((Creature*)m_unit)->m_spells[i]; 9972 if(IsPassiveSpell(spellid)) 9973 m_unit->CastSpell(m_unit, spellid, true); 9974 else 9975 AddSpellToAB(0, spellid, ACT_CAST); 9976 } 9937 9977 } 9938 9978 }