First Commit

For Azeroth!
This commit is contained in:
Yehonal
2016-06-26 10:39:44 +02:00
commit e8e94a0a66
3777 changed files with 1419268 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,190 @@
/*
* Copyright (C)
* Copyright (C)
*
* 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 the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SUNWELLCORE_PET_H
#define SUNWELLCORE_PET_H
#include "PetDefines.h"
#include "TemporarySummon.h"
#define PET_FOCUS_REGEN_INTERVAL 4 * IN_MILLISECONDS
#define PET_LOSE_HAPPINES_INTERVAL 7500
#define HAPPINESS_LEVEL_SIZE 333000
struct PetSpell
{
ActiveStates active;
PetSpellState state;
PetSpellType type;
};
class AsynchPetSummon
{
public:
AsynchPetSummon(uint32 entry, Position position, PetType petType, uint32 duration, uint32 createdBySpell, uint64 casterGUID) :
m_entry(entry), pos(position), m_petType(petType),
m_duration(duration), m_createdBySpell(createdBySpell), m_casterGUID(casterGUID) { }
Position pos;
uint32 m_entry, m_createdBySpell, m_duration;
PetType m_petType;
uint64 m_casterGUID;
};
typedef UNORDERED_MAP<uint32, PetSpell> PetSpellMap;
typedef std::vector<uint32> AutoSpellList;
class Player;
class Pet : public Guardian
{
public:
explicit Pet(Player* owner, PetType type = MAX_PET_TYPE);
virtual ~Pet();
void AddToWorld();
void RemoveFromWorld();
void SetDisplayId(uint32 modelId);
PetType getPetType() const { return m_petType; }
void setPetType(PetType type) { m_petType = type; }
bool isControlled() const { return getPetType() == SUMMON_PET || getPetType() == HUNTER_PET; }
bool isTemporarySummoned() const { return m_duration > 0; }
bool IsPermanentPetFor(Player* owner) const; // 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 CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner);
bool CreateBaseAtTamed(CreatureTemplate const* cinfo, Map* map, uint32 phaseMask);
static bool LoadPetFromDB(Player* owner, uint8 asynchLoadType, uint32 petentry = 0, uint32 petnumber = 0, bool current = false, AsynchPetSummon* info = NULL);
bool isBeingLoaded() const { return m_loading;}
void SavePetToDB(PetSaveMode mode, bool logout);
void Remove(PetSaveMode mode, bool returnreagent = false);
static void DeleteFromDB(uint32 guidlow);
void setDeathState(DeathState s, bool despawn = false); // overwrite virtual Creature::setDeathState and Unit::setDeathState
void Update(uint32 diff); // overwrite virtual Creature::Update and Unit::Update
uint8 GetPetAutoSpellSize() const { return m_autospells.size(); }
uint32 GetPetAutoSpellOnPos(uint8 pos) const
{
if (pos >= m_autospells.size())
return 0;
else
return m_autospells[pos];
}
void LoseHappiness();
HappinessState GetHappinessState();
void GivePetXP(uint32 xp);
void GivePetLevel(uint8 level);
void SynchronizeLevelWithOwner();
bool HaveInDiet(ItemTemplate const* item) const;
uint32 GetCurrentFoodBenefitLevel(uint32 itemlevel) const;
void SetDuration(int32 dur) { m_duration = dur; }
int32 GetDuration() const { return m_duration; }
/*
bool UpdateStats(Stats stat);
bool UpdateAllStats();
void UpdateResistances(uint32 school);
void UpdateArmor();
void UpdateMaxHealth();
void UpdateMaxPower(Powers power);
void UpdateAttackPowerAndDamage(bool ranged = false);
void UpdateDamagePhysical(WeaponAttackType attType);
*/
void ToggleAutocast(SpellInfo const* spellInfo, bool apply);
bool HasSpell(uint32 spell) const;
void LearnPetPassives();
void CastPetAuras(bool current);
void _SaveSpellCooldowns(SQLTransaction& trans, bool logout);
void _SaveAuras(SQLTransaction& trans, bool logout);
void _SaveSpells(SQLTransaction& trans);
void _LoadSpellCooldowns(PreparedQueryResult result);
void _LoadAuras(PreparedQueryResult result, uint32 timediff);
void _LoadSpells(PreparedQueryResult result);
bool addSpell(uint32 spellId, 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;
AutoSpellList m_autospells;
void InitPetCreateSpells();
bool resetTalents();
static void resetTalentsForAllPetsOf(Player* owner, Pet* online_pet = NULL);
void InitTalentForLevel();
uint8 GetMaxTalentPointsForLevel(uint8 level);
uint8 GetFreeTalentPoints() { return GetByteValue(UNIT_FIELD_BYTES_1, 1); }
void SetFreeTalentPoints(uint8 points) { SetByteValue(UNIT_FIELD_BYTES_1, 1, points); }
uint32 m_usedTalentCount;
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() const { return m_owner; }
void SetLoading(bool load) { m_loading = load; }
void HandleAsynchLoadSucceed();
static void HandleAsynchLoadFailed(AsynchPetSummon* info, Player* player, uint8 asynchLoadType, uint8 loadResult);
uint8 GetAsynchLoadType() const { return asynchLoadType; }
void SetAsynchLoadType(uint8 type) { asynchLoadType = type; }
protected:
Player* m_owner;
int32 m_happinessTimer;
PetType m_petType;
int32 m_duration; // time until unsummon (used mostly for summoned guardians and not used for controlled pets)
uint64 m_auraRaidUpdateMask;
bool m_loading;
int32 m_petRegenTimer; // xinef: used for focus regeneration
DeclinedName *m_declinedname;
uint8 asynchLoadType;
private:
void SaveToDB(uint32, uint8, uint32) // override of Creature::SaveToDB - must not be called
{
ASSERT(false);
}
void DeleteFromDB() // override of Creature::DeleteFromDB - must not be called
{
ASSERT(false);
}
};
#endif

View File

@@ -0,0 +1,206 @@
/*
* Copyright (C)
* Copyright (C)
*
* 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 the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef SUNWELLCORE_PET_DEFINES_H
#define SUNWELLCORE_PET_DEFINES_H
enum PetType
{
SUMMON_PET = 0,
HUNTER_PET = 1,
MAX_PET_TYPE = 4
};
#define MAX_PET_STABLES 4
// stored in character_pet.slot
enum PetSaveMode
{
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
{
UNHAPPY = 1,
CONTENT = 2,
HAPPY = 3
};
enum PetSpellState
{
PETSPELL_UNCHANGED = 0,
PETSPELL_CHANGED = 1,
PETSPELL_NEW = 2,
PETSPELL_REMOVED = 3
};
enum PetSpellType
{
PETSPELL_NORMAL = 0,
PETSPELL_FAMILY = 1,
PETSPELL_TALENT = 2
};
enum ActionFeedback
{
FEEDBACK_NONE = 0,
FEEDBACK_PET_DEAD = 1,
FEEDBACK_NOTHING_TO_ATT = 2,
FEEDBACK_CANT_ATT_TARGET = 3
};
enum PetTalk
{
PET_TALK_SPECIAL_SPELL = 0,
PET_TALK_ATTACK = 1
};
// used at pet loading query list preparing, and later result selection
enum PetLoadQueryIndex
{
PET_LOAD_QUERY_LOADAURAS = 0,
PET_LOAD_QUERY_LOADSPELLS = 1,
PET_LOAD_QUERY_LOADSPELLCOOLDOWN = 2,
MAX_PET_LOAD_QUERY,
};
enum PetLoadStage
{
PET_LOAD_DEFAULT = 0,
PET_LOAD_HANDLE_UNSTABLE_CALLBACK = 1, // used also in HandleStableSwapPetCallback, uses same error / ok messages
PET_LOAD_BG_RESURRECT = 2,
PET_LOAD_SUMMON_PET = 3,
PET_LOAD_SUMMON_DEAD_PET = 4
};
enum PetLoadState
{
PET_LOAD_OK = 0,
PET_LOAD_NO_RESULT = 1,
PET_LOAD_ERROR = 2
};
enum NPCEntries
{
// Warlock
NPC_INFERNAL = 89,
NPC_IMP = 416,
NPC_FELHUNTER = 417,
NPC_VOIDWALKER = 1860,
NPC_SUCCUBUS = 1863,
NPC_DOOMGUARD = 11859,
NPC_FELGUARD = 17252,
// Mage
NPC_WATER_ELEMENTAL_TEMP = 510,
NPC_MIRROR_IMAGE = 31216,
NPC_WATER_ELEMENTAL_PERM = 37994,
// Druid
NPC_TREANT = 1964,
// Priest
NPC_SHADOWFIEND = 19668,
// Shaman
NPC_FIRE_ELEMENTAL = 15438,
NPC_EARTH_ELEMENTAL = 15352,
NPC_FERAL_SPIRIT = 29264,
// Death Knight
NPC_RISEN_GHOUL = 26125,
NPC_BLOODWORM = 28017,
NPC_ARMY_OF_THE_DEAD = 24207,
NPC_EBON_GARGOYLE = 27829,
// Generic
NPC_GENERIC_IMP = 12922,
NPC_GENERIC_VOIDWALKER = 8996
};
enum PetScalingSpells
{
SPELL_PET_AVOIDANCE = 32233,
SPELL_HUNTER_PET_SCALING_01 = 34902,
SPELL_HUNTER_PET_SCALING_02 = 34903,
SPELL_HUNTER_PET_SCALING_03 = 34904,
SPELL_HUNTER_PET_SCALING_04 = 61017, // Hit / Expertise
// Warlock
SPELL_WARLOCK_PET_SCALING_01 = 34947,
SPELL_WARLOCK_PET_SCALING_02 = 34956,
SPELL_WARLOCK_PET_SCALING_03 = 34957,
SPELL_WARLOCK_PET_SCALING_04 = 34958,
SPELL_WARLOCK_PET_SCALING_05 = 61013, // Hit / Expertise
SPELL_GLYPH_OF_FELGUARD = 56246,
SPELL_INFERNAL_SCALING_01 = 36186,
SPELL_INFERNAL_SCALING_02 = 36188,
SPELL_INFERNAL_SCALING_03 = 36189,
SPELL_INFERNAL_SCALING_04 = 36190,
SPELL_RITUAL_ENSLAVEMENT = 22987,
// Shaman
SPELL_FERAL_SPIRIT_SPIRIT_HUNT = 58877,
SPELL_FERAL_SPIRIT_SCALING_01 = 35674,
SPELL_FERAL_SPIRIT_SCALING_02 = 35675,
SPELL_FERAL_SPIRIT_SCALING_03 = 35676,
SPELL_FIRE_ELEMENTAL_SCALING_01 = 35665,
SPELL_FIRE_ELEMENTAL_SCALING_02 = 35666,
SPELL_FIRE_ELEMENTAL_SCALING_03 = 35667,
SPELL_FIRE_ELEMENTAL_SCALING_04 = 35668,
SPELL_EARTH_ELEMENTAL_SCALING_01 = 65225,
SPELL_EARTH_ELEMENTAL_SCALING_02 = 65226,
SPELL_EARTH_ELEMENTAL_SCALING_03 = 65227,
SPELL_EARTH_ELEMENTAL_SCALING_04 = 65228,
// Priest
SPELL_SHADOWFIEND_SCALING_01 = 35661,
SPELL_SHADOWFIEND_SCALING_02 = 35662,
SPELL_SHADOWFIEND_SCALING_03 = 35663,
SPELL_SHADOWFIEND_SCALING_04 = 35664,
// Druid
SPELL_TREANT_SCALING_01 = 35669,
SPELL_TREANT_SCALING_02 = 35670,
SPELL_TREANT_SCALING_03 = 35671,
SPELL_TREANT_SCALING_04 = 35672,
// Mage
SPELL_MAGE_PET_SCALING_01 = 35657,
SPELL_MAGE_PET_SCALING_02 = 35658,
SPELL_MAGE_PET_SCALING_03 = 35659,
SPELL_MAGE_PET_SCALING_04 = 35660,
// Death Knight
SPELL_ORC_RACIAL_COMMAND = 65221,
SPELL_NIGHT_OF_THE_DEAD_AVOIDANCE = 62137,
SPELL_DK_PET_SCALING_01 = 51996,
SPELL_DK_PET_SCALING_02 = 54566,
SPELL_DK_PET_SCALING_03 = 61697
};
#define PET_FOLLOW_DIST 1.0f
#define PET_FOLLOW_ANGLE (M_PI/2)
#endif