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/PetHandler.cpp

    r152 r174  
    110110                    if(pet->GetTypeId() != TYPEID_PLAYER) 
    111111                    { 
    112                         pet->GetMotionMaster()->Clear(); 
    113112                        if (((Creature*)pet)->AI()) 
    114113                            ((Creature*)pet)->AI()->AttackStart(TargetUnit); 
     
    140139                            p->setDeathState(CORPSE); 
    141140                    } 
    142                     else                                    // charmed 
    143                         _player->Uncharm(); 
     141                    else                                    // charmed or possessed 
     142                    { 
     143                        if (_player->isPossessing()) 
     144                            _player->RemovePossess(true); 
     145                        else 
     146                            _player->Uncharm(); 
     147                    } 
    144148                    break; 
    145149                default: 
     
    195199 
    196200                                                            //auto turn to target unless possessed 
    197             if(result == SPELL_FAILED_UNIT_NOT_INFRONT && !pet->HasAuraType(SPELL_AURA_MOD_POSSESS)) 
     201            if(result == SPELL_FAILED_UNIT_NOT_INFRONT && !pet->isPossessed()) 
    198202            { 
    199203                pet->SetInFront(unit_target); 
     
    223227                } 
    224228 
    225                 if( unit_target && !GetPlayer()->IsFriendlyTo(unit_target) && !pet->HasAuraType(SPELL_AURA_MOD_POSSESS)) 
     229                if( unit_target && !GetPlayer()->IsFriendlyTo(unit_target) && !pet->isPossessed()) 
    226230                { 
    227231                    pet->clearUnitState(UNIT_STAT_FOLLOW); 
     
    237241            else 
    238242            { 
    239                 if(pet->HasAuraType(SPELL_AURA_MOD_POSSESS)) 
     243                if(pet->isPossessed()) 
    240244                { 
    241245                    WorldPacket data(SMSG_CAST_FAILED, (4+1+1)); 
     
    479483        else if(pet->GetGUID() == _player->GetCharmGUID()) 
    480484        { 
    481             _player->Uncharm(); 
     485            if (_player->isPossessing()) 
     486                _player->RemovePossess(true); 
     487            else 
     488                _player->Uncharm(); 
    482489        } 
    483490    } 
     
    602609    recvPacket >> guid >> spellid; 
    603610 
     611    // This opcode is also sent from charmed and possessed units (players and creatures) 
    604612    if(!_player->GetPet() && !_player->GetCharm()) 
    605613        return; 
    606614 
    607     if(ObjectAccessor::FindPlayer(guid)) 
    608         return; 
    609  
    610     Creature* pet=ObjectAccessor::GetCreatureOrPet(*_player,guid); 
    611  
    612     if(!pet || (pet != _player->GetPet() && pet!= _player->GetCharm())) 
     615    Unit* caster = ObjectAccessor::GetUnit(*_player, guid); 
     616 
     617    if(!caster || (caster != _player->GetPet() && caster != _player->GetCharm())) 
    613618    { 
    614619        sLog.outError( "HandlePetCastSpellOpcode: Pet %u isn't pet of player %s .\n", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() ); 
     
    616621    } 
    617622 
    618     if (pet->GetGlobalCooldown() > 0) 
     623    if (caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->GetGlobalCooldown() > 0) 
    619624        return; 
    620625 
     
    627632 
    628633    // do not cast not learned spells 
    629     if(!pet->HasSpell(spellid) || IsPassiveSpell(spellid)) 
     634    if(!caster->HasSpell(spellid) || IsPassiveSpell(spellid)) 
    630635        return; 
    631636 
    632637    SpellCastTargets targets; 
    633     if(!targets.read(&recvPacket,pet)) 
    634         return; 
    635  
    636     pet->clearUnitState(UNIT_STAT_FOLLOW); 
    637  
    638     Spell *spell = new Spell(pet, spellInfo, false); 
     638    if(!targets.read(&recvPacket,caster)) 
     639        return; 
     640 
     641    caster->clearUnitState(UNIT_STAT_FOLLOW); 
     642 
     643    Spell *spell = new Spell(caster, spellInfo, false); 
    639644    spell->m_targets = targets; 
    640645 
     
    642647    if(result == -1) 
    643648    { 
    644         pet->AddCreatureSpellCooldown(spellid); 
    645         if(pet->isPet()) 
    646         { 
    647             Pet* p = (Pet*)pet; 
    648             p->CheckLearning(spellid); 
    649             //10% chance to play special pet attack talk, else growl 
    650             //actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell 
    651             if(p->getPetType() == SUMMON_PET && (urand(0, 100) < 10)) 
    652                 pet->SendPetTalk((uint32)PET_TALK_SPECIAL_SPELL); 
    653             else 
    654                 pet->SendPetAIReaction(guid); 
     649        if(caster->GetTypeId() == TYPEID_UNIT) 
     650        { 
     651            Creature* pet = (Creature*)caster; 
     652            pet->AddCreatureSpellCooldown(spellid); 
     653            if(pet->isPet()) 
     654            { 
     655                Pet* p = (Pet*)pet; 
     656                p->CheckLearning(spellid); 
     657                // 10% chance to play special pet attack talk, else growl 
     658                // actually this only seems to happen on special spells, fire shield for imp, torment for voidwalker, but it's stupid to check every spell 
     659                if(p->getPetType() == SUMMON_PET && (urand(0, 100) < 10)) 
     660                    pet->SendPetTalk((uint32)PET_TALK_SPECIAL_SPELL); 
     661                else 
     662                    pet->SendPetAIReaction(guid); 
     663            } 
    655664        } 
    656665 
     
    659668    else 
    660669    { 
    661         pet->SendPetCastFail(spellid, result); 
    662         if(!pet->HasSpellCooldown(spellid)) 
    663             pet->SendPetClearCooldown(spellid); 
     670        caster->SendPetCastFail(spellid, result); 
     671        if(caster->GetTypeId() == TYPEID_PLAYER) 
     672        { 
     673            if(!((Player*)caster)->HasSpellCooldown(spellid)) 
     674                caster->SendPetClearCooldown(spellid); 
     675        } 
     676        else 
     677        { 
     678            if(!((Creature*)caster)->HasSpellCooldown(spellid)) 
     679                caster->SendPetClearCooldown(spellid); 
     680        } 
    664681 
    665682        spell->finish(false);