NPC/Trainer

* add support for https://github.com/TrinityCore/TrinityCore/commit/bf3ab6d9c43
 * fixed some bugs causing conditions to not be displayed
 * fixed some trainer not being displayed for most skills
This commit is contained in:
Sarjuuk
2020-02-23 16:05:24 +01:00
parent d4c0c0535a
commit 16bd59e0cc
12 changed files with 70 additions and 127 deletions

View File

@@ -12,7 +12,7 @@ SqlGen::register(new class extends SetupScript
protected $command = 'source';
protected $tblDependancyAowow = ['spell', 'achievement'];
protected $tblDependancyTC = ['playercreateinfo_skills', 'playercreateinfo_item', 'skill_discovery_template', 'achievement_reward', 'skill_perfect_item_template', 'item_template', 'gameobject_template', 'quest_template', 'quest_template_addon', 'creature_template', 'creature', 'npc_trainer', 'npc_vendor', 'game_event_npc_vendor', 'reference_loot_template', 'item_loot_template', 'creature_loot_template', 'gameobject_loot_template', 'mail_loot_template', 'disenchant_loot_template', 'fishing_loot_template', 'skinning_loot_template', 'milling_loot_template', 'prospecting_loot_template', 'pickpocketing_loot_template'];
protected $tblDependancyTC = ['playercreateinfo_skills', 'playercreateinfo_item', 'skill_discovery_template', 'achievement_reward', 'skill_perfect_item_template', 'item_template', 'gameobject_template', 'quest_template', 'quest_template_addon', 'creature_template', 'creature', 'trainer_spell', 'npc_vendor', 'game_event_npc_vendor', 'reference_loot_template', 'item_loot_template', 'creature_loot_template', 'gameobject_loot_template', 'mail_loot_template', 'disenchant_loot_template', 'fishing_loot_template', 'skinning_loot_template', 'milling_loot_template', 'prospecting_loot_template', 'pickpocketing_loot_template'];
protected $dbcSourceFiles = ['charstartoutfit', 'talent', 'spell', 'skilllineability', 'itemextendedcost', 'lock'];
private function queryfy(array $data, string $query) : string
@@ -1043,22 +1043,16 @@ SqlGen::register(new class extends SetupScript
$buff = [];
foreach ($qSpells as $sId => $spell)
{
for ($i = 1; $i <= 3; $i++)
{
if ($spell['effect'.$i.'Id'] != 36) // effect: learnSpell
continue;
$this->pushBuffer($buff, TYPE_SPELL, $spell['effect'.$i.'TriggerSpell'], $quests[$sId]['qty'] > 1 ? 0 : TYPE_QUEST, $quests[$sId]['qty'] > 1 ? 0 : $quests[$sId]['id'], $quests[$sId]['side']);
}
}
if ($spell['effect'.$i.'Id'] == 36) // effect: learnSpell
$this->pushBuffer($buff, TYPE_SPELL, $spell['effect'.$i.'TriggerSpell'], $quests[$sId]['qty'] > 1 ? 0 : TYPE_QUEST, $quests[$sId]['qty'] > 1 ? 0 : $quests[$sId]['id'], $quests[$sId]['side']);
DB::Aowow()->query($this->queryfy($buff, $insMore), 4, 4, 4);
}
# 6: Trainer
CLI::write(' * #6 Trainer');
if ($tNpcs = DB::World()->select('SELECT SpellID AS ARRAY_KEY, ID AS entry, COUNT(1) AS qty FROM npc_trainer WHERE SpellID > 0 GROUP BY ARRAY_KEY'))
if ($tNpcs = DB::World()->select('SELECT SpellID AS ARRAY_KEY, cdt.CreatureId AS entry, COUNT(1) AS qty FROM `trainer_spell` ts JOIN `creature_default_trainer` cdt ON cdt.TrainerId = ts.TrainerId GROUP BY ARRAY_KEY'))
{
$tSpells = DB::Aowow()->select('SELECT id AS ARRAY_KEY, effect1Id, effect2Id, effect3Id, effect1TriggerSpell, effect2TriggerSpell, effect3TriggerSpell FROM dbc_spell WHERE id IN (?a)', array_keys($tNpcs));
$buff = [];
@@ -1070,20 +1064,13 @@ SqlGen::register(new class extends SetupScript
continue;
$effects = $tSpells[$spellId];
$trainerId = $npc['entry'] > 200000 || $npc['qty'] > 1 ? 0 : $npc['entry'];
$trainerId = $npc['qty'] > 1 ? 0 : $npc['entry'];
$triggered = false;
for ($i = 1; $i <= 3; $i++)
{
if ($effects['effect'.$i.'Id'] != 36) // effect: learnSpell
continue;
if ($effects['effect'.$i.'Id'] == 36) // effect: learnSpell
$this->pushBuffer($buff, TYPE_SPELL, $effects['effect'.$i.'TriggerSpell'], $trainerId ? TYPE_NPC : 0, $trainerId);
$triggered = true;
$this->pushBuffer($buff, TYPE_SPELL, $effects['effect'.$i.'TriggerSpell'], $trainerId ? TYPE_NPC : 0, $trainerId);
}
if (!$triggered)
$this->pushBuffer($buff, TYPE_SPELL, $spellId, $trainerId ? TYPE_NPC : 0, $trainerId);
$this->pushBuffer($buff, TYPE_SPELL, $spellId, $trainerId ? TYPE_NPC : 0, $trainerId);
}
DB::Aowow()->query($this->queryfy($buff, $insMore), 6, 6, 6);