diff options
Diffstat (limited to 'src/game/Pet.h')
-rw-r--r-- | src/game/Pet.h | 134 |
1 files changed, 61 insertions, 73 deletions
diff --git a/src/game/Pet.h b/src/game/Pet.h index d55c467826a..49daad429ed 100644 --- a/src/game/Pet.h +++ b/src/game/Pet.h @@ -1,7 +1,7 @@ /* - * Copyright (C) 2005-2008 MaNGOS <http://www.mangosproject.org/> + * Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/> * - * Copyright (C) 2008 Trinity <http://www.trinitycore.org/> + * Copyright (C) 2008-2009 Trinity <http://www.trinitycore.org/> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -22,28 +22,28 @@ #define TRINITYCORE_PET_H #include "ObjectDefines.h" -#include "Creature.h" #include "Unit.h" +#include "TemporarySummon.h" enum PetType { SUMMON_PET = 0, HUNTER_PET = 1, - GUARDIAN_PET = 2, - MINI_PET = 3, - POSSESSED_PET = 4, - MAX_PET_TYPE = 5 + MAX_PET_TYPE = 4, }; extern char const* petTypeSuffix[MAX_PET_TYPE]; +#define MAX_PET_STABLES 4 + +// stored in character_pet.slot enum PetSaveMode { - PET_SAVE_AS_DELETED =-1, - PET_SAVE_AS_CURRENT = 0, - PET_SAVE_IN_STABLE_SLOT_1 = 1, - PET_SAVE_IN_STABLE_SLOT_2 = 2, - PET_SAVE_NOT_IN_SLOT = 3 + PET_SAVE_AS_DELETED = -1, // not saved in fact + PET_SAVE_AS_CURRENT = 0, // in current slot (with player) + PET_SAVE_FIRST_STABLE_SLOT = 1, + PET_SAVE_LAST_STABLE_SLOT = MAX_PET_STABLES, // last in DB stable slot index (including), all higher have same meaning as PET_SAVE_NOT_IN_SLOT + PET_SAVE_NOT_IN_SLOT = 100 // for avoid conflict with stable size grow will use 100 }; enum HappinessState @@ -53,16 +53,6 @@ enum HappinessState HAPPY = 3 }; -enum LoyaltyLevel -{ - REBELLIOUS = 1, - UNRULY = 2, - SUBMISSIVE = 3, - DEPENDABLE = 4, - FAITHFUL = 5, - BEST_FRIEND = 6 -}; - enum PetSpellState { PETSPELL_UNCHANGED = 0, @@ -75,15 +65,14 @@ enum PetSpellType { PETSPELL_NORMAL = 0, PETSPELL_FAMILY = 1, + PETSPELL_TALENT = 2, }; struct PetSpell { - uint16 slotId; - uint16 active; - - PetSpellState state : 16; - PetSpellType type : 16; + ActiveStates active; + PetSpellState state; + PetSpellType type; }; enum ActionFeedback @@ -100,6 +89,12 @@ enum PetTalk PET_TALK_ATTACK = 1 }; +enum AtLoadFlags +{ + AT_LOAD_NONE = 0, + AT_LOAD_RESET_SPELLS = 1, +}; + enum PetNameInvalidReason { PET_NAME_INVALID = 1, @@ -117,26 +112,24 @@ enum PetNameInvalidReason PET_NAME_DECLENSION_DOESNT_MATCH_BASE_NAME = 16 }; -typedef UNORDERED_MAP<uint16, PetSpell*> PetSpellMap; -typedef std::map<uint32,uint32> TeachSpellMap; +typedef UNORDERED_MAP<uint32, PetSpell> PetSpellMap; typedef std::vector<uint32> AutoSpellList; #define HAPPINESS_LEVEL_SIZE 333000 -extern const uint32 LevelUpLoyalty[6]; -extern const uint32 LevelStartLoyalty[6]; - #define ACTIVE_SPELLS_MAX 4 -#define OWNER_MAX_DISTANCE 100 +#define OWNER_MAX_DISTANCE 100.0f #define PET_FOLLOW_DIST 1 #define PET_FOLLOW_ANGLE (M_PI/2) -class Pet : public Creature +class Player; + +class Pet : public Guardian { public: - explicit Pet(PetType type = MAX_PET_TYPE); + explicit Pet(Player *owner, PetType type = MAX_PET_TYPE); virtual ~Pet(); void AddToWorld(); @@ -147,9 +140,11 @@ class Pet : public Creature bool isControlled() const { return getPetType()==SUMMON_PET || getPetType()==HUNTER_PET; } bool isTemporarySummoned() const { return m_duration > 0; } - bool Create (uint32 guidlow, Map *map, uint32 Entry, uint32 pet_number); + bool IsPermanentPetFor(Player* owner); // pet have tab in character windows and set UNIT_FIELD_PETNUMBER + + bool Create (uint32 guidlow, Map *map, uint32 phaseMask, uint32 Entry, uint32 pet_number); bool CreateBaseAtCreature(Creature* creature); - bool LoadPetFromDB( Unit* owner,uint32 petentry = 0,uint32 petnumber = 0, bool current = false ); + bool LoadPetFromDB( Player* owner,uint32 petentry = 0,uint32 petnumber = 0, bool current = false ); void SavePetToDB(PetSaveMode mode); void Remove(PetSaveMode mode, bool returnreagent = false); static void DeleteFromDB(uint32 guidlow); @@ -166,26 +161,17 @@ class Pet : public Creature return m_autospells[pos]; } - void RegenerateFocus(); + void Regenerate(Powers power); void LooseHappiness(); - void TickLoyaltyChange(); - void ModifyLoyalty(int32 addvalue); HappinessState GetHappinessState(); - uint32 GetMaxLoyaltyPoints(uint32 level); - uint32 GetStartLoyaltyPoints(uint32 level); - void KillLoyaltyBonus(uint32 level); - uint32 GetLoyaltyLevel() { return GetByteValue(UNIT_FIELD_BYTES_1, 1); } - void SetLoyaltyLevel(LoyaltyLevel level); void GivePetXP(uint32 xp); void GivePetLevel(uint32 level); - bool InitStatsForLevel(uint32 level); + void SynchronizeLevelWithOwner(); bool HaveInDiet(ItemPrototype const* item) const; uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel); void SetDuration(int32 dur) { m_duration = dur; } - int32 GetBonusDamage() { return m_bonusdamage; } - void SetBonusDamage(int32 damage) { m_bonusdamage = damage; } - + /* bool UpdateStats(Stats stat); bool UpdateAllStats(); void UpdateResistances(uint32 school); @@ -194,14 +180,12 @@ class Pet : public Creature void UpdateMaxPower(Powers power); void UpdateAttackPowerAndDamage(bool ranged = false); void UpdateDamagePhysical(WeaponAttackType attType); + */ - bool CanTakeMoreActiveSpells(uint32 SpellIconID); - void ToggleAutocast(uint32 spellid, bool apply); - bool HasTPForSpell(uint32 spellid); - int32 GetTPForSpell(uint32 spellid); + bool CanTakeMoreActiveSpells(uint32 SpellIconID); + void ToggleAutocast(uint32 spellid, bool apply); bool HasSpell(uint32 spell) const; - void AddTeachSpell(uint32 learned_id, uint32 source_id) { m_teachspells[learned_id] = source_id; } void LearnPetPassives(); void CastPetAuras(bool current); @@ -214,43 +198,48 @@ class Pet : public Creature void _LoadSpells(); void _SaveSpells(); - bool addSpell(uint16 spell_id,uint16 active = ACT_DECIDE, PetSpellState state = PETSPELL_NEW, uint16 slot_id=0xffff, PetSpellType type = PETSPELL_NORMAL); - bool learnSpell(uint16 spell_id); - void removeSpell(uint16 spell_id); - bool _removeSpell(uint16 spell_id); + bool addSpell(uint32 spell_id,ActiveStates active = ACT_DECIDE, PetSpellState state = PETSPELL_NEW, PetSpellType type = PETSPELL_NORMAL); + bool learnSpell(uint32 spell_id); + void learnSpellHighRank(uint32 spellid); + void InitLevelupSpellsForLevel(); + bool unlearnSpell(uint32 spell_id, bool learn_prev, bool clear_ab = true); + bool removeSpell(uint32 spell_id, bool learn_prev, bool clear_ab = true); + void CleanupActionBar(); PetSpellMap m_spells; - TeachSpellMap m_teachspells; AutoSpellList m_autospells; void InitPetCreateSpells(); - void CheckLearning(uint32 spellid); + + bool resetTalents(bool no_cost = false); uint32 resetTalentsCost() const; + void InitTalentForLevel(); - void SetTP(int32 TP); - int32 GetDispTP(); + uint8 GetMaxTalentPointsForLevel(uint32 level); + uint8 GetFreeTalentPoints() { return GetByteValue(UNIT_FIELD_BYTES_1, 1); } + void SetFreeTalentPoints(uint8 points) { SetByteValue(UNIT_FIELD_BYTES_1, 1, points); } - int32 m_TrainingPoints; uint32 m_resetTalentsCost; time_t m_resetTalentsTime; + uint32 m_usedTalentCount; - uint64 GetAuraUpdateMask() { return m_auraUpdateMask; } - void SetAuraUpdateMask(uint8 slot) { m_auraUpdateMask |= (uint64(1) << slot); } - void UnsetAuraUpdateMask(uint8 slot) { m_auraUpdateMask &= ~(uint64(1) << slot); } - void ResetAuraUpdateMask() { m_auraUpdateMask = 0; } + const uint64& GetAuraUpdateMaskForRaid() const { return m_auraRaidUpdateMask; } + void SetAuraUpdateMaskForRaid(uint8 slot) { m_auraRaidUpdateMask |= (uint64(1) << slot); } + void ResetAuraUpdateMaskForRaid() { m_auraRaidUpdateMask = 0; } DeclinedName const* GetDeclinedNames() const { return m_declinedname; } bool m_removed; // prevent overwrite pet state in DB at next Pet::Update if pet already removed(saved) + + Player *GetOwner() { return m_owner; } protected: - uint32 m_regenTimer; + Player *m_owner; uint32 m_happinessTimer; - uint32 m_loyaltyTimer; PetType m_petType; int32 m_duration; // time until unsummon (used mostly for summoned guardians and not used for controlled pets) - int32 m_loyaltyPoints; - int32 m_bonusdamage; - uint64 m_auraUpdateMask; + uint64 m_auraRaidUpdateMask; + bool m_loading; + uint32 m_regenTimer; DeclinedName *m_declinedname; @@ -265,4 +254,3 @@ class Pet : public Creature } }; #endif - |