aboutsummaryrefslogtreecommitdiff
path: root/src/game/NPCHandler.cpp
diff options
context:
space:
mode:
authormegamage <none@none>2009-01-14 00:35:13 -0600
committermegamage <none@none>2009-01-14 00:35:13 -0600
commit83e7f653fe6a1aad6121fa7606da620d14938e0c (patch)
tree3c470663f44d1b7949ead9091a615a81f8d14128 /src/game/NPCHandler.cpp
parent78e92e9023eff0bffb1bdb1a4f110ba9fcb3c5a8 (diff)
*Update to Mangos 7083.
--HG-- branch : trunk
Diffstat (limited to 'src/game/NPCHandler.cpp')
-rw-r--r--src/game/NPCHandler.cpp36
1 files changed, 21 insertions, 15 deletions
diff --git a/src/game/NPCHandler.cpp b/src/game/NPCHandler.cpp
index c6751512e02..19de60c6b53 100644
--- a/src/game/NPCHandler.cpp
+++ b/src/game/NPCHandler.cpp
@@ -166,17 +166,17 @@ void WorldSession::SendTrainerList( uint64 guid, const std::string& strTitle )
{
TrainerSpell const* tSpell = *itr;
- if(!_player->IsSpellFitByClassAndRace(tSpell->spell))
+ if(!_player->IsSpellFitByClassAndRace(tSpell->learned_spell))
continue;
++count;
- bool primary_prof_first_rank = spellmgr.IsPrimaryProfessionFirstRankSpell(tSpell->spell);
+ bool primary_prof_first_rank = spellmgr.IsPrimaryProfessionFirstRankSpell(tSpell->learned_spell);
- SpellChainNode const* chain_node = spellmgr.GetSpellChainNode(tSpell->spell);
+ SpellChainNode const* chain_node = spellmgr.GetSpellChainNode(tSpell->learned_spell);
uint32 req_spell = spellmgr.GetSpellRequired(tSpell->spell);
- data << uint32(tSpell->spell);
+ data << uint32(tSpell->spell); // learned spell (or cast-spell in profession case)
data << uint8(_player->GetTrainerSpellState(tSpell));
data << uint32(floor(tSpell->spellcost * fDiscountMod));
@@ -241,21 +241,27 @@ void WorldSession::HandleTrainerBuySpellOpcode( WorldPacket & recv_data )
if(_player->GetMoney() < nSpellCost )
return;
- WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 12); // visual effect on trainer
- data << uint64(guid) << uint32(0xB3);
- SendPacket(&data);
+ _player->ModifyMoney( -int32(nSpellCost) );
- data.Initialize(SMSG_PLAY_SPELL_IMPACT, 12); // visual effect on player
- data << uint64(_player->GetGUID()) << uint32(0x016A);
- SendPacket(&data);
+ // learn explicitly or cast explicitly
+ if(trainer_spell->IsCastable ())
+ //FIXME: prof. spell entry in trainer list not marked gray until list re-open.
+ unit->CastSpell(_player,trainer_spell->spell,true);
+ else
+ {
+ WorldPacket data(SMSG_PLAY_SPELL_VISUAL, 12); // visual effect on trainer
+ data << uint64(guid) << uint32(0xB3);
+ SendPacket(&data);
- _player->ModifyMoney( -int32(nSpellCost) );
+ data.Initialize(SMSG_PLAY_SPELL_IMPACT, 12); // visual effect on player
+ data << uint64(_player->GetGUID()) << uint32(0x016A);
+ SendPacket(&data);
- // learn explicitly to prevent lost money at lags, learning spell will be only show spell animation
- _player->learnSpell(trainer_spell->spell);
+ _player->learnSpell(spellId);
+ }
- data.Initialize(SMSG_TRAINER_BUY_SUCCEEDED, 12);
- data << uint64(guid) << uint32(spellId);
+ WorldPacket data(SMSG_TRAINER_BUY_SUCCEEDED, 12);
+ data << uint64(guid) << uint32(trainer_spell->spell);
SendPacket(&data);
}