вывод из самбомудлей модов для азероткор

This commit is contained in:
2026-03-07 22:28:31 +04:00
parent 5877ea78cd
commit adcfe8e31d
1720 changed files with 1941740 additions and 40 deletions
@@ -0,0 +1,8 @@
#include "mod_learnspells.h"
LearnSpells::LearnSpells() : PlayerScript("LearnSpellsPlayerScript"), WorldScript("LearnSpellsWorldScript") {}
void Addmod_learnspellsScripts()
{
new LearnSpells();
}
@@ -0,0 +1,79 @@
#ifndef MOD_LEARNSPELLS
#define MOD_LEARNSPELLS
#include "ScriptMgr.h"
enum SpellType
{
TYPE_CLASS = 0,
TYPE_PROFICIENCIES = 1,
TYPE_MOUNTS = 2,
TYPE_MAX = 3
};
enum SpellColumn
{
SPELL_ID = 0,
SPELL_REQUIRED_TEAM = 1,
SPELL_REQUIRED_RACE = 2,
SPELL_REQUIRED_CLASS = 3,
SPELL_REQUIRED_LEVEL = 4,
SPELL_REQUIRED_SPELL_ID = 5,
SPELL_REQUIRES_QUEST = 6
};
struct SpellList
{
uint32 spellId;
int8 teamId;
int8 raceId;
int8 classId;
uint32 requiredLevel;
int32 requiredSpellId;
uint8 requiresQuest;
};
enum Riding
{
SPELL_APPRENTICE_RIDING = 33388,
SPELL_JOURNEYMAN_RIDING = 33391,
SPELL_EXPERT_RIDING = 34090,
SPELL_ARTISAN_RIDING = 34091,
SPELL_COLD_WEATHER_FLYING = 54197
};
class LearnSpells : public PlayerScript, WorldScript
{
public:
LearnSpells();
// PlayerScript
void OnPlayerLevelChanged(Player* /*player*/, uint8 /*oldLevel*/) override;
void OnPlayerLogin(Player* /*player*/) override;
void OnPlayerLearnTalents(Player* /*player*/, uint32 /*talentId*/, uint32 /*talentRank*/, uint32 /*spellid*/) override;
// WorldScript
void OnAfterConfigLoad(bool /*reload*/) override;
void OnLoadCustomDatabaseTable() override;
private:
bool EnableGamemasters;
bool EnableClassSpells;
bool EnableProficiencies;
bool EnableFromQuests;
bool EnableApprenticeRiding;
bool EnableJourneymanRiding;
bool EnableExpertRiding;
bool EnableArtisanRiding;
bool EnableColdWeatherFlying;
void LearnAllSpells(Player* /*player*/);
void LearnClassSpells(Player* /*player*/);
void LearnProficiencies(Player* /*player*/);
void LearnMounts(Player* /*player*/);
void AddTotems(Player* /*player*/);
std::array<std::vector<SpellList>, TYPE_MAX> SpellsList;
};
#endif
@@ -0,0 +1,16 @@
#include "Config.h"
#include "mod_learnspells.h"
void LearnSpells::OnAfterConfigLoad(bool /*reload*/)
{
EnableGamemasters = sConfigMgr->GetOption<bool>("LearnSpells.Gamemasters", false);
EnableClassSpells = sConfigMgr->GetOption<bool>("LearnSpells.ClassSpells", true);
EnableProficiencies = sConfigMgr->GetOption<bool>("LearnSpells.Proficiencies", true);
EnableFromQuests = sConfigMgr->GetOption<bool>("LearnSpells.SpellsFromQuests", true);
EnableApprenticeRiding = sConfigMgr->GetOption<bool>("LearnSpells.Riding.Apprentice", false);
EnableJourneymanRiding = sConfigMgr->GetOption<bool>("LearnSpells.Riding.Journeyman", false);
EnableExpertRiding = sConfigMgr->GetOption<bool>("LearnSpells.Riding.Expert", false);
EnableArtisanRiding = sConfigMgr->GetOption<bool>("LearnSpells.Riding.Artisan", false);
EnableColdWeatherFlying = sConfigMgr->GetOption<bool>("LearnSpells.Riding.ColdWeatherFlying", false);
}
@@ -0,0 +1,114 @@
#include "Player.h"
#include "mod_learnspells.h"
void LearnSpells::OnPlayerLevelChanged(Player* player, uint8 /*oldLevel*/)
{
LearnAllSpells(player);
}
void LearnSpells::OnPlayerLogin(Player* player)
{
LearnAllSpells(player);
}
void LearnSpells::OnPlayerLearnTalents(Player* player, uint32 /*talentId*/, uint32 /*talentRank*/, uint32 /*spellid*/)
{
LearnAllSpells(player);
}
void LearnSpells::LearnAllSpells(Player* player)
{
if (player->IsGameMaster() && !EnableGamemasters)
return;
if (player->getClass() == CLASS_DEATH_KNIGHT && player->GetMapId() == 609)
return;
LearnClassSpells(player);
LearnProficiencies(player);
LearnMounts(player);
AddTotems(player);
}
void LearnSpells::LearnClassSpells(Player* player)
{
if (!EnableClassSpells && !EnableFromQuests)
return;
for (auto& spell : SpellsList[TYPE_CLASS])
{
if (spell.requiresQuest == 0 && !EnableClassSpells)
continue;
if (spell.requiresQuest == 1 && !EnableFromQuests)
continue;
if (spell.raceId == -1 || spell.raceId == player->getRace())
if (spell.classId == player->getClass())
if (spell.teamId == -1 || spell.teamId == player->GetTeamId())
if (player->GetLevel() >= spell.requiredLevel)
if (spell.requiredSpellId == -1 || player->HasSpell(spell.requiredSpellId))
if (!player->HasSpell(spell.spellId))
player->learnSpell(spell.spellId);
}
}
void LearnSpells::LearnProficiencies(Player* player)
{
if (!EnableProficiencies)
return;
for (auto& spell : SpellsList[TYPE_PROFICIENCIES])
if (spell.classId == player->getClass())
if (player->GetLevel() >= spell.requiredLevel)
if (!player->HasSpell(spell.spellId))
player->learnSpell(spell.spellId);
}
void LearnSpells::LearnMounts(Player* player)
{
if (!EnableApprenticeRiding && !EnableJourneymanRiding && !EnableExpertRiding && !EnableArtisanRiding && !EnableColdWeatherFlying)
return;
for (auto& spell : SpellsList[TYPE_MOUNTS])
{
if (((spell.spellId == SPELL_APPRENTICE_RIDING || spell.requiredSpellId == SPELL_APPRENTICE_RIDING) && !EnableApprenticeRiding) ||
((spell.spellId == SPELL_JOURNEYMAN_RIDING || spell.requiredSpellId == SPELL_JOURNEYMAN_RIDING) && !EnableJourneymanRiding) ||
((spell.spellId == SPELL_EXPERT_RIDING || spell.requiredSpellId == SPELL_EXPERT_RIDING) && !EnableExpertRiding) ||
((spell.spellId == SPELL_ARTISAN_RIDING || spell.requiredSpellId == SPELL_ARTISAN_RIDING) && !EnableArtisanRiding) ||
(spell.spellId == SPELL_COLD_WEATHER_FLYING && !EnableColdWeatherFlying) ||
(spell.requiresQuest == 1 && !EnableFromQuests))
continue;
if (spell.raceId == -1 || spell.raceId == player->getRace())
if (spell.classId == -1 || spell.classId == player->getClass())
if (spell.teamId == -1 || spell.teamId == player->GetTeamId())
if (spell.requiredSpellId == -1 || player->HasSpell(spell.requiredSpellId))
if (player->GetLevel() >= spell.requiredLevel)
if (!player->HasSpell(spell.spellId))
player->learnSpell(spell.spellId);
}
}
void LearnSpells::AddTotems(Player* player)
{
if (player->getClass() != CLASS_SHAMAN)
return;
if (!EnableClassSpells || !EnableFromQuests)
return;
uint32 totems[4][3] =
{
{5175, 2, 4}, // Earth Totem, TotemCategory 2, Level 4
{5176, 4, 10}, // Fire Totem, TotemCategory 4, Level 10
{5177, 5, 20}, // Water Totem, TotemCategory 5, Level 20
{5178, 3, 30} // Air Totem, TotemCategory 3, Level 30
};
for (int i = 0; i <= 3; i++)
if (player->GetLevel() >= totems[i][2])
if (!player->HasItemTotemCategory(totems[i][1]))
player->AddItem(totems[i][0], 1);
}
@@ -0,0 +1,26 @@
#include "mod_learnspells.h"
void LearnSpells::OnLoadCustomDatabaseTable()
{
QueryResult result = WorldDatabase.Query("SELECT `type_id`, `spell_id`, `team_id`, `race_id`, `class_id`, `required_level`, `required_spell_id`, `requires_quest` FROM `mod_learnspells`");
if (!result)
return;
do
{
Field* fields = result->Fetch();
uint8 typeId = fields[0].Get<uint8>();
SpellList spell;
spell.spellId = fields[1].Get<uint32>();
spell.teamId = fields[2].Get<int8>();
spell.raceId = fields[3].Get<int8>();
spell.classId = fields[4].Get<int8>();
spell.requiredLevel = fields[5].Get<uint8>();
spell.requiredSpellId = fields[6].Get<int32>();
spell.requiresQuest = fields[7].Get<uint8>();
SpellsList[typeId].push_back(spell);
} while (result->NextRow());
}