Show
Ignore:
Timestamp:
11/19/08 13:43:15 (17 years ago)
Author:
yumileroy
Message:

[svn] Implemented player on player and player on creature possession:
* Implemented packet and vision forwarding through possessed units
* Added new OnPossess? script call alerting scripts on when possession is applied/removed
* Moved fall damage and fall under map calculations into the Player class
* Added new PossessedAI that is applied only while possession on creature is active
* Implemented summon possessed spell effect
* Fixed Eyes of the Beast

Original author: gvcoman
Date: 2008-11-05 20:51:05-06:00

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • trunk/src/game/Unit.cpp

    r173 r174  
    227227    m_charmInfo = NULL; 
    228228    m_unit_movement_flags = 0; 
     229    m_isPossessed = false; 
    229230 
    230231    // remove aurastates allowing special moves 
     
    702703            ((Player*)pVictim)->SetPvPDeath(player!=NULL); 
    703704 
    704         // Call KilledUnit for creatures 
    705         if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI()) 
    706             ((Creature*)this)->AI()->KilledUnit(pVictim); 
    707  
    708705        // 10% durability loss on death 
    709706        // clean InHateListOf 
     
    719716                ((Player*)pVictim)->GetSession()->SendPacket(&data); 
    720717            } 
     718            // Call KilledUnit for creatures 
     719            if (GetTypeId() == TYPEID_UNIT && ((Creature*)this)->AI()) 
     720                ((Creature*)this)->AI()->KilledUnit(pVictim); 
    721721        } 
    722722        else                                                // creature died 
     
    730730                cVictim->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE); 
    731731            } 
     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 
    732737            // Call creature just died function 
    733738            if (cVictim->AI()) 
     
    773778            he->DuelComplete(DUEL_INTERUPTED); 
    774779        } 
     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); 
    775787 
    776788        // battleground things (do this at the end, so the death state flag will be properly set to handle in the bg->handlekill) 
     
    71707182} 
    71717183 
     7184void Unit::UncharmSelf() 
     7185{ 
     7186    if (!GetCharmer()) 
     7187        return; 
     7188 
     7189    RemoveSpellsCausingAura(SPELL_AURA_MOD_CHARM); 
     7190} 
     7191 
     7192void 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 
    71727207void Unit::UnsummonAllTotems() 
    71737208{ 
     
    85898624    } 
    85908625 
     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 
    85918629    // different visible distance checks 
    85928630    if(u->isInFlight())                                     // what see player in flight 
    85938631    { 
    85948632        // 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))) 
    85968634            return false; 
    85978635    } 
    85988636    else if(!isAlive())                                     // distance for show body 
    85998637    { 
    8600         if (!IsWithinDistInMap(u,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f))) 
     8638        if (!IsWithinDistInMap(target,World::GetMaxVisibleDistanceForObject()+(inVisibleList ? World::GetVisibleObjectGreyDistance() : 0.0f))) 
    86018639            return false; 
    86028640    } 
     
    86068644        { 
    86078645            // 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))) 
    86098647                return false; 
    86108648        } 
     
    86138651            // Units far than max visible distance for creature or not in our map are not visible too 
    86148652            // Active unit should always be visibile 
    8615             if (!IsWithinDistInMap(u, u->isActive()  
     8653            if (!IsWithinDistInMap(target, target->isActive()  
    86168654                ? (MAX_VISIBILITY_DISTANCE - (inVisibleList ? 0.0f : World::GetVisibleUnitGreyDistance())) 
    86178655                : (World::GetMaxVisibleDistanceForCreature() + (inVisibleList ? World::GetVisibleUnitGreyDistance() : 0.0f)))) 
     
    86228660    { 
    86238661        // 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))) 
    86258663            return false; 
    86268664    } 
     
    86288666    { 
    86298667        // 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))) 
    86318669            return false; 
    86328670    } 
     
    98729910        RemoveAllDynObjects(); 
    98739911        GetMotionMaster()->Clear(false);                    // remove different non-standard movement generators. 
     9912 
     9913        UnpossessSelf(false); 
    98749914    } 
    98759915    RemoveFromWorld(); 
     
    99249964void CharmInfo::InitPossessCreateSpells() 
    99259965{ 
    9926     if(m_unit->GetTypeId() == TYPEID_PLAYER) 
    9927         return; 
    9928  
    9929     InitEmptyActionBar();                                   //charm action bar 
    9930  
    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         else 
    9936             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        } 
    99379977    } 
    99389978}