mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 07:37:01 +00:00
[7886] Drop use table petcreateinfo_spell
This is first commit in chain for remove oudated and not used pet functionality. * Use instead dropped table CreatureSpellData.dbc if creature_template.PetSpellDataId set (mostly hunter pets) * Use creature_template.spellN if not set creature_template.PetSpellDataId (mostly different summon creatures) * Fixed bug with not removing from action bar spell icon for not ranked unlearned spells. Note: summoned controllable creatures without PetSpellDataId must have expected spells in spellN feilds for creature_template.
This commit is contained in:
parent
37f8cea0a1
commit
8171bb57dd
11 changed files with 206 additions and 58 deletions
|
|
@ -23,7 +23,7 @@ DROP TABLE IF EXISTS `db_version`;
|
|||
CREATE TABLE `db_version` (
|
||||
`version` varchar(120) default NULL,
|
||||
`creature_ai_version` varchar(120) default NULL,
|
||||
`required_7884_02_mangos_playercreateinfo_action` bit(1) default NULL
|
||||
`required_7886_01_mangos_petcreateinfo_spell` bit(1) default NULL
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=FIXED COMMENT='Used DB version notes';
|
||||
|
||||
--
|
||||
|
|
@ -3660,29 +3660,6 @@ INSERT INTO `pet_name_generation` (`word`,`entry`,`half`) VALUES
|
|||
/*!40000 ALTER TABLE `pet_name_generation` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `petcreateinfo_spell`
|
||||
--
|
||||
|
||||
DROP TABLE IF EXISTS `petcreateinfo_spell`;
|
||||
CREATE TABLE `petcreateinfo_spell` (
|
||||
`entry` mediumint(8) unsigned NOT NULL default '0',
|
||||
`Spell1` mediumint(8) unsigned NOT NULL default '0',
|
||||
`Spell2` mediumint(8) unsigned NOT NULL default '0',
|
||||
`Spell3` mediumint(8) unsigned NOT NULL default '0',
|
||||
`Spell4` mediumint(8) unsigned NOT NULL default '0',
|
||||
PRIMARY KEY (`entry`)
|
||||
) ENGINE=MyISAM DEFAULT CHARSET=utf8 ROW_FORMAT=DYNAMIC COMMENT='Pet Create Spells';
|
||||
|
||||
--
|
||||
-- Dumping data for table `petcreateinfo_spell`
|
||||
--
|
||||
|
||||
LOCK TABLES `petcreateinfo_spell` WRITE;
|
||||
/*!40000 ALTER TABLE `petcreateinfo_spell` DISABLE KEYS */;
|
||||
/*!40000 ALTER TABLE `petcreateinfo_spell` ENABLE KEYS */;
|
||||
UNLOCK TABLES;
|
||||
|
||||
--
|
||||
-- Table structure for table `pickpocketing_loot_template`
|
||||
--
|
||||
|
|
|
|||
4
sql/updates/7886_01_mangos_petcreateinfo_spell.sql
Normal file
4
sql/updates/7886_01_mangos_petcreateinfo_spell.sql
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
ALTER TABLE db_version CHANGE COLUMN required_7884_02_mangos_playercreateinfo_action required_7886_01_mangos_petcreateinfo_spell bit;
|
||||
|
||||
DROP TABLE IF EXISTS `petcreateinfo_spell`;
|
||||
|
||||
|
|
@ -197,6 +197,7 @@ pkgdata_DATA = \
|
|||
7884_03_characters_character_spell.sql \
|
||||
7884_04_characters_character_aura.sql \
|
||||
7884_05_characters_character_action.sql \
|
||||
7886_01_mangos_petcreateinfo_spell.sql \
|
||||
README
|
||||
|
||||
## Additional files to include when running 'make dist'
|
||||
|
|
@ -374,4 +375,5 @@ EXTRA_DIST = \
|
|||
7884_03_characters_character_spell.sql \
|
||||
7884_04_characters_character_aura.sql \
|
||||
7884_05_characters_character_action.sql \
|
||||
7886_01_mangos_petcreateinfo_spell.sql \
|
||||
README
|
||||
|
|
|
|||
|
|
@ -704,11 +704,13 @@ struct CreatureFamilyEntry
|
|||
// 27 m_iconFile
|
||||
};
|
||||
|
||||
#define MAX_CREATURE_SPELL_DATA_SLOT 4
|
||||
|
||||
struct CreatureSpellDataEntry
|
||||
{
|
||||
uint32 ID; // 0 m_ID
|
||||
//uint32 spellId[4]; // 1-4 m_spells[4]
|
||||
//uint32 availability[4]; // 4-7 m_availability[4]
|
||||
uint32 spellId[MAX_CREATURE_SPELL_DATA_SLOT]; // 1-4 m_spells[4]
|
||||
//uint32 availability[MAX_CREATURE_SPELL_DATA_SLOT]; // 4-7 m_availability[4]
|
||||
};
|
||||
|
||||
struct CreatureTypeEntry
|
||||
|
|
|
|||
|
|
@ -37,7 +37,7 @@ const char ChrRacesEntryfmt[]="nxixiixxixxxxissssssssssssssssxxxxxxxxxxxxxxxxxxx
|
|||
const char CinematicSequencesEntryfmt[]="nxxxxxxxxx";
|
||||
const char CreatureDisplayInfofmt[]="nxxxfxxxxxxxxxxx";
|
||||
const char CreatureFamilyfmt[]="nfifiiiiixssssssssssssssssxx";
|
||||
const char CreatureSpellDatafmt[]="nxxxxxxxx";
|
||||
const char CreatureSpellDatafmt[]="niiiixxxx";
|
||||
const char CreatureTypefmt[]="nxxxxxxxxxxxxxxxxxx";
|
||||
const char CurrencyTypesfmt[]="xnxi";
|
||||
const char DurabilityCostsfmt[]="niiiiiiiiiiiiiiiiiiiiiiiiiiiii";
|
||||
|
|
|
|||
|
|
@ -3572,7 +3572,7 @@ void ObjectMgr::LoadPetCreateSpells()
|
|||
|
||||
sLog.outString();
|
||||
sLog.outString( ">> Loaded 0 pet create spells" );
|
||||
sLog.outErrorDb("`petcreateinfo_spell` table is empty!");
|
||||
//sLog.outErrorDb("`petcreateinfo_spell` table is empty!");
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
@ -3644,6 +3644,7 @@ void ObjectMgr::LoadPetCreateSpells()
|
|||
|
||||
sLog.outString();
|
||||
sLog.outString( ">> Loaded %u pet create spells", count );
|
||||
sLog.outErrorDb("`petcreateinfo_spell` table use deprecated! Must be empty!");
|
||||
}
|
||||
|
||||
void ObjectMgr::LoadScripts(ScriptMapMap& scripts, char const* tablename)
|
||||
|
|
|
|||
|
|
@ -1437,25 +1437,40 @@ bool Pet::learnSpell(uint32 spell_id)
|
|||
|
||||
void Pet::InitLevelupSpellsForLevel()
|
||||
{
|
||||
uint32 family = GetCreatureInfo()->family;
|
||||
if(!family)
|
||||
return;
|
||||
|
||||
PetLevelupSpellSet const *levelupSpells = spellmgr.GetPetLevelupSpellList(family);
|
||||
if(!levelupSpells)
|
||||
return;
|
||||
|
||||
uint32 level = getLevel();
|
||||
|
||||
// PetLevelupSpellSet ordered by levels, process in reversed order
|
||||
for(PetLevelupSpellSet::const_reverse_iterator itr = levelupSpells->rbegin(); itr != levelupSpells->rend(); ++itr)
|
||||
if(PetLevelupSpellSet const *levelupSpells = GetCreatureInfo()->family ? spellmgr.GetPetLevelupSpellList(GetCreatureInfo()->family) : NULL)
|
||||
{
|
||||
// will called first if level down
|
||||
if(itr->first > level)
|
||||
unlearnSpell(itr->second,true); // will learn prev rank if any
|
||||
// will called if level up
|
||||
else
|
||||
learnSpell(itr->second); // will unlearn prev rank if any
|
||||
// PetLevelupSpellSet ordered by levels, process in reversed order
|
||||
for(PetLevelupSpellSet::const_reverse_iterator itr = levelupSpells->rbegin(); itr != levelupSpells->rend(); ++itr)
|
||||
{
|
||||
// will called first if level down
|
||||
if(itr->first > level)
|
||||
unlearnSpell(itr->second,true); // will learn prev rank if any
|
||||
// will called if level up
|
||||
else
|
||||
learnSpell(itr->second); // will unlearn prev rank if any
|
||||
}
|
||||
}
|
||||
|
||||
int32 petSpellsId = GetCreatureInfo()->PetSpellDataId ? -(int32)GetCreatureInfo()->PetSpellDataId : GetEntry();
|
||||
|
||||
// default spells (can be not learned if pet level (as owner level decrease result for example) less first possible in normal game)
|
||||
if(PetDefaultSpellsEntry const *defSpells = spellmgr.GetPetDefaultSpellsEntry(petSpellsId))
|
||||
{
|
||||
for(int i = 0; i < MAX_CREATURE_SPELL_DATA_SLOT; ++i)
|
||||
{
|
||||
SpellEntry const* spellEntry = sSpellStore.LookupEntry(defSpells->spellid[i]);
|
||||
if(!spellEntry)
|
||||
continue;
|
||||
|
||||
// will called first if level down
|
||||
if(spellEntry->spellLevel > level)
|
||||
unlearnSpell(spellEntry->Id,false);
|
||||
// will called if level up
|
||||
else
|
||||
learnSpell(spellEntry->Id);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1516,14 +1531,16 @@ bool Pet::removeSpell(uint32 spell_id, bool learn_prev)
|
|||
learnSpell(prev_id);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_charmInfo->AddSpellToAB(spell_id, 0);
|
||||
learn_prev = false;
|
||||
}
|
||||
|
||||
// need update action bar for last removed rank
|
||||
if (Unit* owner = GetOwner())
|
||||
if (owner->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)owner)->PetSpellInitialize();
|
||||
}
|
||||
// if remove last rank or non-ranked then update action bar at server and client if need
|
||||
if(!learn_prev && m_charmInfo->AddSpellToAB(spell_id, 0))
|
||||
{
|
||||
// need update action bar for last removed rank
|
||||
if (Unit* owner = GetOwner())
|
||||
if (owner->GetTypeId() == TYPEID_PLAYER)
|
||||
((Player*)owner)->PetSpellInitialize();
|
||||
}
|
||||
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -2223,6 +2223,131 @@ void SpellMgr::LoadPetLevelupSpellMap()
|
|||
sLog.outString( ">> Loaded %u pet levelup and default spells for %u families", count, family_count );
|
||||
}
|
||||
|
||||
bool LoadPetDefaultSpells_helper(CreatureInfo const* cInfo, PetDefaultSpellsEntry& petDefSpells)
|
||||
{
|
||||
// skip empty list;
|
||||
bool have_spell = false;
|
||||
for(int j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j)
|
||||
{
|
||||
if(petDefSpells.spellid[j])
|
||||
{
|
||||
have_spell = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(!have_spell)
|
||||
return false;
|
||||
|
||||
// remove duplicates with levelupSpells if any
|
||||
if(PetLevelupSpellSet const *levelupSpells = cInfo->family ? spellmgr.GetPetLevelupSpellList(cInfo->family) : NULL)
|
||||
{
|
||||
for(int j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j)
|
||||
{
|
||||
if(!petDefSpells.spellid[j])
|
||||
continue;
|
||||
|
||||
for(PetLevelupSpellSet::const_iterator itr = levelupSpells->begin(); itr != levelupSpells->end(); ++itr)
|
||||
{
|
||||
if (itr->second == petDefSpells.spellid[j])
|
||||
{
|
||||
petDefSpells.spellid[j] = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// skip empty list;
|
||||
have_spell = false;
|
||||
for(int j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j)
|
||||
{
|
||||
if(petDefSpells.spellid[j])
|
||||
{
|
||||
have_spell = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return have_spell;
|
||||
}
|
||||
|
||||
void SpellMgr::LoadPetDefaultSpells()
|
||||
{
|
||||
assert(MAX_CREATURE_SPELL_DATA_SLOT==CREATURE_MAX_SPELLS);
|
||||
|
||||
mPetDefaultSpellsMap.clear();
|
||||
|
||||
uint32 countCreature = 0;
|
||||
uint32 countData = 0;
|
||||
|
||||
for(uint32 i = 0; i < sCreatureStorage.MaxEntry; ++i )
|
||||
{
|
||||
CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(i);
|
||||
if(!cInfo)
|
||||
continue;
|
||||
|
||||
if(!cInfo->PetSpellDataId)
|
||||
continue;
|
||||
|
||||
// for creature with PetSpellDataId get default pet spells from dbc
|
||||
CreatureSpellDataEntry const* spellDataEntry = sCreatureSpellDataStore.LookupEntry(cInfo->PetSpellDataId);
|
||||
if(!spellDataEntry)
|
||||
continue;
|
||||
|
||||
int32 petSpellsId = -(int32)cInfo->PetSpellDataId;
|
||||
PetDefaultSpellsEntry petDefSpells;
|
||||
for(int j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j)
|
||||
petDefSpells.spellid[j] = spellDataEntry->spellId[j];
|
||||
|
||||
if(LoadPetDefaultSpells_helper(cInfo, petDefSpells))
|
||||
{
|
||||
mPetDefaultSpellsMap[petSpellsId] = petDefSpells;
|
||||
++countData;
|
||||
}
|
||||
}
|
||||
|
||||
// different summon spells
|
||||
for(uint32 i = 0; i < sSpellStore.GetNumRows(); ++i )
|
||||
{
|
||||
SpellEntry const* spellEntry = sSpellStore.LookupEntry(i);
|
||||
if(!spellEntry)
|
||||
continue;
|
||||
|
||||
for(int k = 0; k < 3; ++k)
|
||||
{
|
||||
if(spellEntry->Effect[k]==SPELL_EFFECT_SUMMON || spellEntry->Effect[k]==SPELL_EFFECT_SUMMON_PET)
|
||||
{
|
||||
uint32 creature_id = spellEntry->EffectMiscValue[k];
|
||||
CreatureInfo const* cInfo = sCreatureStorage.LookupEntry<CreatureInfo>(creature_id);
|
||||
if(!cInfo)
|
||||
continue;
|
||||
|
||||
// already loaded
|
||||
if(cInfo->PetSpellDataId)
|
||||
continue;
|
||||
|
||||
// for creature without PetSpellDataId get default pet spells from creature_template
|
||||
int32 petSpellsId = cInfo->Entry;
|
||||
if(mPetDefaultSpellsMap.find(cInfo->Entry) != mPetDefaultSpellsMap.end())
|
||||
continue;
|
||||
|
||||
PetDefaultSpellsEntry petDefSpells;
|
||||
for(int j = 0; j < MAX_CREATURE_SPELL_DATA_SLOT; ++j)
|
||||
petDefSpells.spellid[j] = cInfo->spells[j];
|
||||
|
||||
if(LoadPetDefaultSpells_helper(cInfo, petDefSpells))
|
||||
{
|
||||
mPetDefaultSpellsMap[petSpellsId] = petDefSpells;
|
||||
++countCreature;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
sLog.outString();
|
||||
sLog.outString( ">> Loaded addition spells for %u pet spell data entries and %u summonable creature templates", countData, countCreature );
|
||||
}
|
||||
|
||||
/// Some checks for spells, to prevent adding deprecated/broken spells for trainers, spell book, etc
|
||||
bool SpellMgr::IsSpellValid(SpellEntry const* spellInfo, Player* pl, bool msg)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -564,6 +564,15 @@ typedef std::multimap<uint32, SkillLineAbilityEntry const*> SkillLineAbilityMap;
|
|||
typedef std::multimap<uint32, uint32> PetLevelupSpellSet;
|
||||
typedef std::map<uint32, PetLevelupSpellSet> PetLevelupSpellMap;
|
||||
|
||||
struct PetDefaultSpellsEntry
|
||||
{
|
||||
uint32 spellid[MAX_CREATURE_SPELL_DATA_SLOT];
|
||||
};
|
||||
|
||||
// < 0 for petspelldata id, > 0 for creature_id
|
||||
typedef std::map<int32, PetDefaultSpellsEntry> PetDefaultSpellsMap;
|
||||
|
||||
|
||||
inline bool IsPrimaryProfessionSkill(uint32 skill)
|
||||
{
|
||||
SkillLineEntry const *pSkill = sSkillLineStore.LookupEntry(skill);
|
||||
|
|
@ -814,6 +823,15 @@ class SpellMgr
|
|||
return NULL;
|
||||
}
|
||||
|
||||
// < 0 for petspelldata id, > 0 for creature_id
|
||||
PetDefaultSpellsEntry const* GetPetDefaultSpellsEntry(int32 id) const
|
||||
{
|
||||
PetDefaultSpellsMap::const_iterator itr = mPetDefaultSpellsMap.find(id);
|
||||
if(itr != mPetDefaultSpellsMap.end())
|
||||
return &itr->second;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
SpellCastResult GetSpellAllowedInLocationError(SpellEntry const *spellInfo, uint32 map_id, uint32 zone_id, uint32 area_id, Player const* player = NULL);
|
||||
|
||||
SpellAreaMapBounds GetSpellAreaMapBounds(uint32 spell_id) const
|
||||
|
|
@ -862,6 +880,7 @@ class SpellMgr
|
|||
void LoadSkillLineAbilityMap();
|
||||
void LoadSpellPetAuras();
|
||||
void LoadPetLevelupSpellMap();
|
||||
void LoadPetDefaultSpells();
|
||||
void LoadSpellAreas();
|
||||
|
||||
private:
|
||||
|
|
@ -878,6 +897,7 @@ class SpellMgr
|
|||
SkillLineAbilityMap mSkillLineAbilityMap;
|
||||
SpellPetAuraMap mSpellPetAuraMap;
|
||||
PetLevelupSpellMap mPetLevelupSpellMap;
|
||||
PetDefaultSpellsMap mPetDefaultSpellsMap; // only spells not listed in related mPetLevelupSpellMap entry
|
||||
SpellAreaMap mSpellAreaMap;
|
||||
SpellAreaForQuestMap mSpellAreaForQuestMap;
|
||||
SpellAreaForQuestMap mSpellAreaForActiveQuestMap;
|
||||
|
|
|
|||
|
|
@ -1158,12 +1158,15 @@ void World::SetInitialWorldSettings()
|
|||
sLog.outString( "Loading Points Of Interest Data..." );
|
||||
objmgr.LoadPointsOfInterest();
|
||||
|
||||
sLog.outString( "Loading Pet Create Spells..." );
|
||||
objmgr.LoadPetCreateSpells();
|
||||
|
||||
sLog.outString( "Loading Creature Data..." );
|
||||
objmgr.LoadCreatures();
|
||||
|
||||
sLog.outString( "Loading pet levelup spells..." );
|
||||
spellmgr.LoadPetLevelupSpellMap();
|
||||
|
||||
sLog.outString( "Loading pet default spell additional to levelup spells..." );
|
||||
spellmgr.LoadPetDefaultSpells();
|
||||
|
||||
sLog.outString( "Loading Creature Addon Data..." );
|
||||
sLog.outString();
|
||||
objmgr.LoadCreatureAddons(); // must be after LoadCreatureTemplates() and LoadCreatures()
|
||||
|
|
@ -1230,9 +1233,6 @@ void World::SetInitialWorldSettings()
|
|||
sLog.outString( "Loading spell pet auras..." );
|
||||
spellmgr.LoadSpellPetAuras();
|
||||
|
||||
sLog.outString( "Loading pet levelup spells..." );
|
||||
spellmgr.LoadPetLevelupSpellMap();
|
||||
|
||||
sLog.outString( "Loading Player Create Info & Level Stats..." );
|
||||
sLog.outString();
|
||||
objmgr.LoadPlayerInfo();
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "7885"
|
||||
#define REVISION_NR "7886"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue