Пример #1
0
 void CreatePet(Player *player, Creature * m_creature, uint32 entry) {
  
         if(player->getClass() != CLASS_HUNTER) {
             m_creature->MonsterWhisper("You are not a Hunter!", player->GetGUID());
             player->PlayerTalkClass->SendCloseGossip();
             return;
         }
  
         if(player->GetPet()) {
             m_creature->MonsterWhisper("First you must drop your Pet!", player->GetGUID());
             player->PlayerTalkClass->SendCloseGossip();
             return;
         }
  
         Creature *creatureTarget = m_creature->SummonCreature(entry, player->GetPositionX(), player->GetPositionY()+2, player->GetPositionZ(), player->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 500);
         if(!creatureTarget) return;
        
         Pet* pet = player->CreateTamedPetFrom(creatureTarget, 0);
         if(!pet) return;
  
         // kill original creature
         creatureTarget->setDeathState(JUST_DIED);
         creatureTarget->RemoveCorpse();
         creatureTarget->SetHealth(0);                       // just for nice GM-mode view
  
         pet->SetPower(POWER_HAPPINESS, 1048000);
  
         //pet->SetUInt32Value(UNIT_FIELD_PETEXPERIENCE,0);
         //pet->SetUInt32Value(UNIT_FIELD_PETNEXTLEVELEXP, uint32((Trinity::XP::xp_to_level(70))/4));
  
         // prepare visual effect for levelup
             pet->SetUInt32Value(UNIT_FIELD_LEVEL, player->getLevel() - 1);
             pet->GetMap()->AddToMap((Creature*)pet);
                
         // visual effect for levelup
         pet->SetUInt32Value(UNIT_FIELD_LEVEL, player->getLevel());
  
        
         if(!pet->InitStatsForLevel(player->getLevel()))
             // sLog->outError("Pet Create fail: no init stats for entry %u", entry);
  
         pet->UpdateAllStats();
        
         // caster have pet now
         player->SetMinion(pet, true);
  
         pet->SavePetToDB(PET_SAVE_AS_CURRENT);
         pet->InitTalentForLevel();
         player->PetSpellInitialize();
        
         //end
         player->PlayerTalkClass->SendCloseGossip();
         m_creature->MonsterWhisper("Pet added. You might want to feed it and name it somehow.", player->GetGUID());
     }
void CreatePet(Player *player, Creature * m_creature, uint32 entry) {

        if(player->getClass() != CLASS_HUNTER) {
            player->PlayerTalkClass->SendCloseGossip();
            return;
        }
 
        if(player->GetPet()) {
            m_creature->MonsterWhisper("First you must drop your Pet!", player->GetGUID());
            m_creature->MonsterWhisper("First you must drop your Pet!", player->GetGUID(), true);
            player->PlayerTalkClass->SendCloseGossip();
            return;
        }
 
        Creature *creatureTarget = m_creature->SummonCreature(entry, player->GetPositionX(), player->GetPositionY()+2, player->GetPositionZ(), player->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 500);
        if(!creatureTarget) return;
        
        Pet* pet = player->CreateTamedPetFrom(creatureTarget, 0);
        if(!pet) return;
 
        // kill original creature
        creatureTarget->setDeathState(JUST_DIED);
        creatureTarget->RemoveCorpse();
        creatureTarget->SetHealth(0);                       // just for nice GM-mode view

		pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, player->GetGUID());
		pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, player->getFaction());
 
        // prepare visual effect for levelup
        pet->SetUInt32Value(UNIT_FIELD_LEVEL, player->getLevel() - 1);
        pet->GetMap()->AddToMap(pet->ToCreature());
        // visual effect for levelup
        pet->SetUInt32Value(UNIT_FIELD_LEVEL, player->getLevel());
		
		pet->GetCharmInfo()->SetPetNumber(sObjectMgr->GeneratePetNumber(), true);
        if(!pet->InitStatsForLevel(player->getLevel()))
			sLog->outInfo(LOG_FILTER_PETS, "Pet Create fail: no init stats for entry %u", entry);
 
        pet->UpdateAllStats();
        
        // caster have pet now
		player->SetMinion(pet, true);
 
        pet->SavePetToDB(PET_SAVE_AS_CURRENT);
        pet->InitTalentForLevel();
        player->PetSpellInitialize();
        
        //end
        player->PlayerTalkClass->SendCloseGossip();
        m_creature->MonsterWhisper("Pet added. You might want to feed it and name it somehow.", player->GetGUID());
        m_creature->MonsterWhisper("Pet added. You might want to feed it and name it somehow.", player->GetGUID(), true);
    }
Пример #3
0
    void CreatePet(Player *player, Creature * m_creature, uint32 entry) {
     
            if(player->getClass() != CLASS_HUNTER) 
			{
                player->PlayerTalkClass->SendCloseGossip();
                return;
            }
     
            if(player->GetPet()) 
			{
                player->PlayerTalkClass->SendCloseGossip();
                return;
            }
     
            Creature *creatureTarget = m_creature->SummonCreature(entry, player->GetPositionX(), player->GetPositionY()+2, player->GetPositionZ(), player->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 500);
            if(!creatureTarget) return;
           
            Pet* pet = player->CreateTamedPetFrom(creatureTarget, 0);
			
            if (!pet)
			    return;
     
            // kill original creature
            creatureTarget->setDeathState(JUST_DIED);
            creatureTarget->RemoveCorpse();
            creatureTarget->SetHealth(0);                       // just for nice GM-mode view
     
            pet->SetPower(POWER_HAPPINESS, 1048000);
     
            pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, player->GetGUID());
            pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, player->getFaction());
     
            // prepare visual effect for levelup
            pet->SetUInt32Value(UNIT_FIELD_LEVEL, player->getLevel() - 1);
            pet->GetMap()->AddToMap(pet->ToCreature());
            // visual effect for levelup for lulz
            pet->SetUInt32Value(UNIT_FIELD_LEVEL, player->getLevel());
                   
            pet->GetCharmInfo()->SetPetNumber(sObjectMgr->GeneratePetNumber(), true);
            if (!pet->InitStatsForLevel(player->getLevel()))
                pet->UpdateAllStats();
         
            // caster has pet now
            player->SetMinion(pet, true);
     
            pet->SavePetToDB(PET_SAVE_AS_CURRENT);
            pet->InitTalentForLevel();
            player->PetSpellInitialize();
           
            //inform that has da pet
            player->PlayerTalkClass->SendCloseGossip();
        }
void CreatePet(Player *player, Creature * m_creature, uint32 entry) {

    if(sConfigMgr->GetBoolDefault("BeastMaster.OnlyHunter", false)) // Checks to see if Only Hunters can have pets.
     {
        if(player->getClass() != CLASS_HUNTER) {
            ChatHandler(player->GetSession()).PSendSysMessage("You are not a Hunter!", LANG_UNIVERSAL, player);
            return;
        }
     }

    if(player->GetPet()) {
        ChatHandler(player->GetSession()).PSendSysMessage("First you must abandon your Pet!", LANG_UNIVERSAL, player);
        return;
    }

    Creature *creatureTarget = m_creature->SummonCreature(entry, player->GetPositionX(), player->GetPositionY()+2, player->GetPositionZ(), player->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 500);
    if(!creatureTarget) return;

    Pet* pet = player->CreateTamedPetFrom(creatureTarget, 0);

    if(!pet) return;

        // kill original creature
    creatureTarget->setDeathState(JUST_DIED);
    creatureTarget->RemoveCorpse();
    creatureTarget->SetHealth(0);                       // just for nice GM-mode view

    pet->SetPower(POWER_HAPPINESS, 1048000);

    // prepare visual effect for levelup
    pet->SetUInt32Value(UNIT_FIELD_LEVEL, player->getLevel() - 1);
    pet->GetMap()->AddToMap((Creature*)pet);
        // visual effect for levelup
    pet->SetUInt32Value(UNIT_FIELD_LEVEL, player->getLevel());

    if(!pet->InitStatsForLevel(player->getLevel()))
        TC_LOG_ERROR("scripts", "Pet Create fail: no init stats for entry %u", entry);
        pet->UpdateAllStats();

    // caster have pet now
        player->SetMinion(pet, true);

        pet->SavePetToDB(PET_SAVE_AS_CURRENT);
        pet->InitTalentForLevel();
        player->PetSpellInitialize();
    //end
        player->CLOSE_GOSSIP_MENU();
        ChatHandler(player->GetSession()).PSendSysMessage("Pet added. You might want to feed it and name it somehow.", LANG_UNIVERSAL, player);
        return;
    }
Пример #5
0
		void CreatePet(Player *player, Creature * m_creature, uint32 entry) 
		{
			if(player->getClass() != CLASS_HUNTER) 
			{
				m_creature->MonsterWhisper("You are not a Hunter!", player->GetGUID());
				player->PlayerTalkClass->SendCloseGossip();
				return;
			}
 
			if(player->GetPet()) 
			{
				m_creature->MonsterWhisper("First you must drop your Pet!", player->GetGUID());
				player->PlayerTalkClass->SendCloseGossip();
				return;
			}
 
			Creature *creatureTarget = m_creature->SummonCreature(entry, player->GetPositionX(), player->GetPositionY()+2, player->GetPositionZ(), player->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 500);
			if(!creatureTarget) return;
        
			Pet* pet = player->CreateTamedPetFrom(creatureTarget, 0);
			if(!pet) 
				return;
 
			creatureTarget->setDeathState(JUST_DIED);
			creatureTarget->RemoveCorpse();
			creatureTarget->SetHealth(0);                       // just for nice GM-mode view
 
			pet->SetPower(POWER_HAPPINESS, 1048000);
			pet->setPowerType(POWER_FOCUS);
 
			pet->SetUInt32Value(UNIT_FIELD_LEVEL, player->getLevel() - 1);
			pet->GetMap()->AddToMap(pet->ToCreature());

			pet->SetUInt32Value(UNIT_FIELD_LEVEL, player->getLevel());
 
        
			if(!pet->InitStatsForLevel(player->getLevel()))
				sLog->outError (LOG_FILTER_GENERAL,"Pet Create fail: no init stats for entry %u", entry);
 
			pet->UpdateAllStats();
        
			player->SetMinion(pet, true);
 
			pet->SavePetToDB(PET_SAVE_AS_CURRENT);
			pet->InitTalentForLevel();
			player->PetSpellInitialize();
        
			player->PlayerTalkClass->SendCloseGossip();
			m_creature->MonsterWhisper("Pet added. You might want to feed it and name it somehow.", player->GetGUID());
		}
Пример #6
0
bool ChatHandler::HandleCreatePetCommand(const char* /*args*/)
{
    Player* player = m_session->GetPlayer();
    Creature* creatureTarget = getSelectedCreature();

    if (!creatureTarget || creatureTarget->isPet() || creatureTarget->GetTypeId() == TYPEID_PLAYER)
    {
        PSendSysMessage(LANG_SELECT_CREATURE);
        SetSentErrorMessage(true);
        return false;
    }

    CreatureTemplate const* cInfo = sObjectMgr->GetCreatureTemplate(creatureTarget->GetEntry());
    // Creatures with family 0 crashes the server
    if (cInfo->family == 0)
    {
        PSendSysMessage("This creature cannot be tamed. (family id: 0).");
        SetSentErrorMessage(true);
        return false;
    }

    if (player->GetPetGUID())
    {
        PSendSysMessage("You already have a pet");
        SetSentErrorMessage(true);
        return false;
    }

    // Everything looks OK, create new pet
    Pet* pet = new Pet(player, HUNTER_PET);
    if (!pet->CreateBaseAtCreature(creatureTarget))
    {
        delete pet;
        PSendSysMessage("Error 1");
        return false;
    }

    creatureTarget->setDeathState(JUST_DIED);
    creatureTarget->RemoveCorpse();
    creatureTarget->SetHealth(0); // just for nice GM-mode view

    pet->SetUInt64Value(UNIT_FIELD_CREATEDBY, player->GetGUID());
    pet->SetUInt32Value(UNIT_FIELD_FACTIONTEMPLATE, player->getFaction());

    if (!pet->InitStatsForLevel(creatureTarget->getLevel()))
    {
        sLog->outError("InitStatsForLevel() in EffectTameCreature failed! Pet deleted.");
        PSendSysMessage("Error 2");
        delete pet;
        return false;
    }

    // prepare visual effect for levelup
    pet->SetUInt32Value(UNIT_FIELD_LEVEL, creatureTarget->getLevel()-1);

    pet->GetCharmInfo()->SetPetNumber(sObjectMgr->GeneratePetNumber(), true);
    // this enables pet details window (Shift+P)
    pet->InitPetCreateSpells();
    pet->SetFullHealth();

    pet->GetMap()->AddToMap(pet->ToCreature());

    // visual effect for levelup
    pet->SetUInt32Value(UNIT_FIELD_LEVEL, creatureTarget->getLevel());

    player->SetMinion(pet, true);
    pet->SavePetToDB(PET_SAVE_AS_CURRENT);
    player->PetSpellInitialize();

    return true;
}
    //npc tame handling
    static bool HandleNpcTameCommand(ChatHandler* handler, const char* /*args*/)
    {
        Creature *creatureTarget = handler->getSelectedCreature ();
        if (!creatureTarget || creatureTarget->isPet ())
        {
            handler->PSendSysMessage (LANG_SELECT_CREATURE);
            handler->SetSentErrorMessage (true);
            return false;
        }

        Player *player = handler->GetSession()->GetPlayer ();

        if (player->GetPetGUID ())
        {
            handler->SendSysMessage (LANG_YOU_ALREADY_HAVE_PET);
            handler->SetSentErrorMessage (true);
            return false;
        }

        CreatureInfo const* cInfo = creatureTarget->GetCreatureInfo();

        if (!cInfo->isTameable (player->CanTameExoticPets()))
        {
            handler->PSendSysMessage (LANG_CREATURE_NON_TAMEABLE,cInfo->Entry);
            handler->SetSentErrorMessage (true);
            return false;
        }

        // Everything looks OK, create new pet
        Pet* pet = player->CreateTamedPetFrom (creatureTarget);
        if (!pet)
        {
            handler->PSendSysMessage (LANG_CREATURE_NON_TAMEABLE,cInfo->Entry);
            handler->SetSentErrorMessage (true);
            return false;
        }

        // place pet before player
        float x,y,z;
        player->GetClosePoint (x,y,z,creatureTarget->GetObjectSize (),CONTACT_DISTANCE);
        pet->Relocate (x,y,z,M_PI-player->GetOrientation ());

        // set pet to defensive mode by default (some classes can't control controlled pets in fact).
        pet->SetReactState(REACT_DEFENSIVE);

        // calculate proper level
        uint8 level = (creatureTarget->getLevel() < (player->getLevel() - 5)) ? (player->getLevel() - 5) : creatureTarget->getLevel();

        // prepare visual effect for levelup
        pet->SetUInt32Value(UNIT_FIELD_LEVEL, level - 1);

        // add to world
        pet->GetMap()->Add(pet->ToCreature());

        // visual effect for levelup
        pet->SetUInt32Value(UNIT_FIELD_LEVEL, level);

        // caster have pet now
        player->SetMinion(pet, true, PET_SLOT_UNK_SLOT);

        pet->SavePetToDB(PET_SLOT_ACTUAL_PET_SLOT);
        player->PetSpellInitialize();

        return true;
    }
Пример #8
0
void CreatePet(Player* player, Creature* creature, uint32 entry)
{
    if (player->GetPet())
    {
        player->GetSession()->SendNotification("You already have a pet!");
        player->CLOSE_GOSSIP_MENU();
        return;
    }

    Creature *creatureTarget = creature->SummonCreature(entry, player->GetPositionX(), player->GetPositionY() + 2, player->GetPositionZ(), player->GetOrientation(), TEMPSUMMON_CORPSE_TIMED_DESPAWN, 500);
    if (!creatureTarget)
        return;

    Pet* pet = player->CreateTamedPetFrom(creatureTarget, 0);
    if (!pet)
        return;
 
    // kill original creature
    creatureTarget->setDeathState(JUST_DIED);
    creatureTarget->RemoveCorpse();
    creatureTarget->SetHealth(0);
 
    pet->SetPower(POWER_HAPPINESS, 1048000);
    pet->SetTP(350);

    // prepare visual effect for levelup
    pet->SetUInt32Value(UNIT_FIELD_LEVEL, player->getLevel() - 1);
    pet->GetMap()->Add(pet->ToCreature());
    // visual effect for levelup
    pet->SetUInt32Value(UNIT_FIELD_LEVEL, player->getLevel());

    if (!pet->InitStatsForLevel(player->getLevel()))
        sLog->outError("Pet Create fail: No init stats for pet with entry %u", entry);

    pet->UpdateAllStats();
    player->SetMinion(pet, true);
    pet->SavePetToDB(PET_SAVE_AS_CURRENT);
    player->PetSpellInitialize();

    // make sure player has all training spells
    player->learnSpell(27348); // bite
    player->learnSpell(28343); // charge
    player->learnSpell(27347); // claw
    player->learnSpell(27346); // cower
    player->learnSpell(23112); // dash
    player->learnSpell(23150); // dive
    player->learnSpell(35324); // fire breath
    player->learnSpell(24599); // furious howl
    player->learnSpell(35308); // gore
    player->learnSpell(25017); // lightning breath
    player->learnSpell(35391); // poison spit
    player->learnSpell(24455); // prowl
    player->learnSpell(27361); // scorpid poison
    player->learnSpell(27349); // screech
    player->learnSpell(26065); // spell shield
    player->learnSpell(27366); // thunderstomp
    player->learnSpell(35348); // warp
    player->learnSpell(27350); // arcane res
    player->learnSpell(27353); // shadow res
    player->learnSpell(27351); // fire res
    player->learnSpell(27352); // frost res
    player->learnSpell(27354); // nature res
    player->learnSpell(27362); // natural armor
    player->learnSpell(27364); // great stamina
    player->learnSpell(35700); // avoidance
    player->learnSpell(25077); // cobra reflexes

    player->CLOSE_GOSSIP_MENU();
    player->GetSession()->SendAreaTriggerMessage("Pet tamed successfully.");
}
Пример #9
0
void CPlayer::CreatePet(uint32 entry, bool classcheck)
{
    if (classcheck && getClass() != CLASS_HUNTER)
        return;

    CreatureInfo const *cinfo = sObjectMgr.GetCreatureTemplate(entry);
    if (!cinfo)
    {
        BoxChat << MSG_COLOR_WHITE << " This pet doesn't exist in our database. Please report that creature " << entry << " is missing." << std::endl;
        return;
    }

    CreatureCreatePos pos(GetSession()->GetPlayer(), GetOrientation());

    Creature* pCreature = new Creature;

    // used guids from specially reserved range (can be 0 if no free values)
    uint32 lowguid = sObjectMgr.GenerateStaticCreatureLowGuid();
    if (!lowguid)
        return;

    if (!pCreature->Create(lowguid, pos, cinfo))
    {
        delete pCreature;
        return;
    }

    //--------------------------------------------------

    if (GetPetGuid())
        UnsummonPetTemporaryIfAny();

    Pet* pet = new Pet(HUNTER_PET);

    if (!pet->CreateBaseAtCreature(pCreature))
    {
        delete pet;
        return;
    }

    pet->SetOwnerGuid(GetObjectGuid());
    pet->SetCreatorGuid(GetObjectGuid());
    pet->setFaction(getFaction());
    pet->SetUInt32Value(UNIT_CREATED_BY_SPELL, 13481);

    if (IsPvP())
        pet->SetPvP(true);

    if (!pet->InitStatsForLevel(pCreature->getLevel()))
    {
        sLog.outError("Pet::InitStatsForLevel() failed for creature (Entry: %u)!", pCreature->GetEntry());
        delete pet;
        return;
    }

    pet->GetCharmInfo()->SetPetNumber(sObjectMgr.GeneratePetNumber(), true);
    // this enables pet details window (Shift+P)
    pet->AIM_Initialize();
    pet->InitPetCreateSpells();
    pet->SetHealth(pet->GetMaxHealth());

    // add to world
    pet->GetMap()->Add((Creature*)pet);

    // visual effect for levelup
    pet->SetUInt32Value(UNIT_FIELD_LEVEL, 70);

    for (auto x = 0; x < 6; x++)
    {
        pet->SetPower(POWER_HAPPINESS, 66600000);
        pet->ModifyLoyalty(150000);
        pet->TickLoyaltyChange();
        pet->SetTP(350);
    }

    // caster have pet now
    SetPet(pet);

    pet->SavePetToDB(PET_SAVE_AS_CURRENT);
    PetSpellInitialize();
    pet->learnSpell(27052);
    pet->learnSpell(35698);
    pet->learnSpell(25076);
    pet->learnSpell(27048);
    pet->learnSpell(27053);
    pet->learnSpell(27054);
    pet->learnSpell(27062);
    pet->learnSpell(27047);
    pet->learnSpell(24551);
    delete pCreature;
}