Changeset 174 for trunk/src/game/PetHandler.cpp
- Timestamp:
- 11/19/08 13:43:15 (17 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/game/PetHandler.cpp
r152 r174 110 110 if(pet->GetTypeId() != TYPEID_PLAYER) 111 111 { 112 pet->GetMotionMaster()->Clear();113 112 if (((Creature*)pet)->AI()) 114 113 ((Creature*)pet)->AI()->AttackStart(TargetUnit); … … 140 139 p->setDeathState(CORPSE); 141 140 } 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 } 144 148 break; 145 149 default: … … 195 199 196 200 //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()) 198 202 { 199 203 pet->SetInFront(unit_target); … … 223 227 } 224 228 225 if( unit_target && !GetPlayer()->IsFriendlyTo(unit_target) && !pet-> HasAuraType(SPELL_AURA_MOD_POSSESS))229 if( unit_target && !GetPlayer()->IsFriendlyTo(unit_target) && !pet->isPossessed()) 226 230 { 227 231 pet->clearUnitState(UNIT_STAT_FOLLOW); … … 237 241 else 238 242 { 239 if(pet-> HasAuraType(SPELL_AURA_MOD_POSSESS))243 if(pet->isPossessed()) 240 244 { 241 245 WorldPacket data(SMSG_CAST_FAILED, (4+1+1)); … … 479 483 else if(pet->GetGUID() == _player->GetCharmGUID()) 480 484 { 481 _player->Uncharm(); 485 if (_player->isPossessing()) 486 _player->RemovePossess(true); 487 else 488 _player->Uncharm(); 482 489 } 483 490 } … … 602 609 recvPacket >> guid >> spellid; 603 610 611 // This opcode is also sent from charmed and possessed units (players and creatures) 604 612 if(!_player->GetPet() && !_player->GetCharm()) 605 613 return; 606 614 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())) 613 618 { 614 619 sLog.outError( "HandlePetCastSpellOpcode: Pet %u isn't pet of player %s .\n", uint32(GUID_LOPART(guid)),GetPlayer()->GetName() ); … … 616 621 } 617 622 618 if ( pet->GetGlobalCooldown() > 0)623 if (caster->GetTypeId() == TYPEID_UNIT && ((Creature*)caster)->GetGlobalCooldown() > 0) 619 624 return; 620 625 … … 627 632 628 633 // do not cast not learned spells 629 if(! pet->HasSpell(spellid) || IsPassiveSpell(spellid))634 if(!caster->HasSpell(spellid) || IsPassiveSpell(spellid)) 630 635 return; 631 636 632 637 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); 639 644 spell->m_targets = targets; 640 645 … … 642 647 if(result == -1) 643 648 { 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 } 655 664 } 656 665 … … 659 668 else 660 669 { 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 } 664 681 665 682 spell->finish(false);